/** * Test whether other options are unselected during selection of one * specific option in simple select boxes. */ public function testRemoveSelectedOptions() { $tag = new SelectBoxTag(); $selectedOption = new SelectBoxOptionTag(); $selectedOption->setAttribute('selected', 'selected'); $unselectedOption = new SelectBoxOptionTag(); $firstId = XmlParser::generateUniqID(); $secondId = XmlParser::generateUniqID(); $thirdId = XmlParser::generateUniqID(); // inject child structure as basis for un-selection $property = new ReflectionProperty(SelectBoxTag::class, 'children'); $property->setAccessible(true); $property->setValue($tag, [$firstId => clone $selectedOption->setObjectId($firstId), $secondId => clone $unselectedOption->setObjectId($secondId), $thirdId => clone $selectedOption->setObjectId($thirdId)]); $method = new ReflectionMethod(SelectBoxTag::class, 'removeSelectedOptions'); $method->setAccessible(true); $method->invokeArgs($tag, [$firstId]); /* @var $children DomNode[] */ $children = $property->getValue($tag); $this->assertEquals('selected', $children[$firstId]->getAttribute('selected')); $this->assertNull($children[$secondId]->getAttribute('selected')); $this->assertNull($children[$thirdId]->getAttribute('selected')); }