<commit_before><?php
namespace RWAHS\Profile;

use DOMElement;

class ProfileElementTest extends AbstractProfileTest
{
    public function testListAttributesHaveLists()
    {
        $list_elements = $this->xpath->query('/profile/elementSets/metadataElement[@datatype="List"]');
        $this->assertEquals(17, $list_elements->length, 'Number of list attributes should match.');
        /** @var DOMElement $list_element */
        foreach ($list_elements as $list_element) {
            $list_code = $list_element->getAttribute('list');
            $element_code = $list_element->getAttribute('code');
            $this->assertNotNull($list_code, "The list attribute needs to be set for the {$list_element->getNodePath()} element");
            $this->assertEquals(1, $this->xpath->query("/profile/lists/list[@code='$list_code']")->length, "List attributes require a matching list. The list '$list_code' does not exist and is required for the $element_code element." .
                "\nHere's an xml element:\n" .
                <<<"LIST_XML"
<list code="$list_code" hierarchical="0" system="1" vocabulary="0">
  <labels><commit_msg>We now have 20 lists<commit_after><?php
namespace RWAHS\Profile;

use DOMElement;

class ProfileElementTest extends AbstractProfileTest
{
    public function testListAttributesHaveLists()
    {
        $list_elements = $this->xpath->query('/profile/elementSets/metadataElement[@datatype="List"]');
        $this->assertEquals(20, $list_elements->length, 'Number of list attributes should match.');
        /** @var DOMElement $list_element */
        foreach ($list_elements as $list_element) {
            $list_code = $list_element->getAttribute('list');
            $element_code = $list_element->getAttribute('code');
            $this->assertNotNull($list_code, "The list attribute needs to be set for the {$list_element->getNodePath()} element");
            $this->assertEquals(1, $this->xpath->query("/profile/lists/list[@code='$list_code']")->length, "List attributes require a matching list. The list '$list_code' does not exist and is required for the $element_code element." .
                "\nHere's an xml element:\n" .
                <<<"LIST_XML"
<list code="$list_code" hierarchical="0" system="1" vocabulary="0">
  <labels>
{'fraction_non_alphanumeric': 0.14116615519508988, 'fraction_numerical': 0.006137658921525646, 'mean_word_length': 3.7442827442827444, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4875430', 'n_tokens_mistral': 632, 'n_tokens_neox': 621, 'n_words': 157}