public function testSelectsCorrectDate() { $this->dateTimeForm->setDateTime('2000-01-01 01:01:01'); $xml = '<minacl>' . $this->dateTimeForm->__toString() . '</minacl>'; /* * replace the with nothing otherwise it'll cause an error * (as we are not including the html entity definitions here) */ $xml = str_replace(' ', '', $xml); $dom = new SimpleXmlElement($xml); $year = $dom->xpath("//select[@id='test_year']/option[@selected='selected']"); $this->assertEquals('2000', (string) $year[0], 'Selected year is 2000'); $month = $dom->xpath("//select[@id='test_month']/option[@selected='selected']"); $this->assertEquals('January', (string) $month[0], 'Selected month is January'); $day = $dom->xpath("//select[@id='test_day']/option[@selected='selected']"); $this->assertEquals('01', (string) $day[0], 'Selected day is 01'); $hour = $dom->xpath("//select[@id='test_hour']/option[@selected='selected']"); $this->assertEquals('01', (string) $hour[0], 'Selected hour is 01'); $minutes = $dom->xpath("//select[@id='test_minute']/option[@selected='selected']"); $this->assertEquals('01', (string) $minutes[0], 'Selected minutes is 01'); $seconds = $dom->xpath("//select[@id='test_second']/option[@selected='selected']"); $this->assertEquals('01', (string) $seconds[0], 'Selected seconds is 01'); }