/** * @dataProvider getData */ public function testAttributePathResultsInTheFirstTwoValuesReadCorrectly($data) { $xmlParser = new Parser(); $values = array(); $callback = function ($parser, $val) use(&$values) { $values[] = $val; }; $xmlParser->registerCallback('/rss/channel/item/category/@domain', $callback); $xmlParser->parse($data); $this->assertEquals(array('http://www.guardian.co.uk/publication', 'http://www.guardian.co.uk/world'), array($values[0], $values[1])); }
/** * @param Parser $xmlParser * @param string $xmlFile */ private function importXmlFile(Parser $xmlParser, $xmlFile) { $this->handle = fopen($xmlFile, 'r'); $xmlParser->parse($this->handle); fclose($this->handle); }