Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public function testGetName()
 {
     $search = SearchFactory::fromArray(array('name' => array('value' => 'Roads and Boats', 'sort_index' => 1)));
     $name = $search->getName();
     $this->assertInstanceOf('Shelf\\Entity\\Search\\Name', $name);
     $this->assertEquals('Roads and Boats', $name->getValue());
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * {@inheritDoc}
  */
 public static function factory(array $data)
 {
     return SearchFactory::fromArray($data);
 }