public function testConvertXmlItemAlternate() { $xmlSearch = simplexml_load_file(FIXTURE_DIR . '/Search/carcassonne.xml'); $itemArray = SearchFactory::convertXmlItem($xmlSearch->item[5]); $expectedArray = array('bgg_id' => 58798, 'type' => 'boardgame', 'name' => array('value' => 'Carcassonne Korttipeli', 'type' => 'alternate', 'sort_index' => 1), 'year_published' => 2009); $this->assertEquals($expectedArray, $itemArray); }
/** * Converts items from the XML API into an array * * @param SimpleXMLElement $xmlItems * * @return array */ protected static function convertXmlItems(\SimpleXMLElement $xmlItems) { $arrayItems = array(); foreach ($xmlItems->item as $xmlItem) { $arrayItems[] = SearchFactory::convertXmlItem($xmlItem); } return $arrayItems; }