diff --git a/lib/View/Controllers/View.php b/lib/View/Controllers/View.php index 8bd32a6..39a619b 100644 --- a/lib/View/Controllers/View.php +++ b/lib/View/Controllers/View.php @@ -137,7 +137,7 @@ protected function getSourceData(\SimpleXMLElement $node) } else if (isset($node->permittedValues)) { $source = []; foreach ($node->permittedValues->children() as $value) { - $source[] = (string)$value; + $source[(string)$value] = (string)$value; } return $source; } diff --git a/tests/View/ViewTest.php b/tests/View/ViewTest.php index c4889e6..b0b6e24 100644 --- a/tests/View/ViewTest.php +++ b/tests/View/ViewTest.php @@ -73,8 +73,8 @@ public function testViewRendering() self::assertXpathExists($simpleXml, '//input[@type="text" and @name="section1_test_element"]'); // we do this separately to test if the element exists apart from whether it has a value. self::assertXpathExists($simpleXml, '//input[@type="text" and @name="section1_test_element" and @value="Element Value"]'); self::assertXpathExists($simpleXml, '//select[@name="section1_test_permitted"]'); - self::assertXpathExists($simpleXml, '//select[@name="section1_test_permitted"]/option[.="yes"]'); - self::assertXpathExists($simpleXml, '//select[@name="section1_test_permitted"]/option[.="no"]'); + self::assertXpathExists($simpleXml, '//select[@name="section1_test_permitted"]/option[.="yes" and @value="yes"]'); + self::assertXpathExists($simpleXml, '//select[@name="section1_test_permitted"]/option[.="no" and @value="no"]'); } public function getViewConfiguration(array $params = [], $method = 'GET')