public function test_UniqueNode_parser_with_pubmed_xml_and_container_extraction()
{
$file = __DIR__ . "/../../xml/pubmed-example.xml";
$stream = new File($file, 512);
$parser = new UniqueNode(array("uniqueNode" => "PubmedArticle", "extractContainer" => true));
$streamer = new XmlStringStreamer($parser, $stream);
$expectedPMIDs = array("24531174", "24529294", "24449586");
$foundPMIDs = array();
while ($node = $streamer->getNode()) {
$xmlNode = simplexml_load_string($node);
$foundPMIDs[] = (string) $xmlNode->MedlineCitation->PMID;
}
$this->assertEquals($expectedPMIDs, $foundPMIDs, "The PMID nodes should be as expected");
$containerXml = simplexml_load_string($parser->getExtractedContainer());
$this->assertEquals("PubmedArticleSet", $containerXml->getName(), "Root node should be as expected");
$this->assertEquals("bar", $containerXml->attributes()->foo, "Attributes should be extracted correctly");
$this->assertEquals("qux", $containerXml->attributes()->baz, "Attributes should be extracted correctly");
}