Пример #1
0
 public function testConvertXmlItemWithStatsNoRatingOrRanking()
 {
     $xmlCollection = simplexml_load_file(FIXTURE_DIR . '/Collection/janivStats.xml');
     $itemArray = CollectionFactory::convertXmlItem($xmlCollection->item[0]);
     $expectedArray = array('bgg_id' => 8257, 'type' => 'thing', 'subtype' => 'boardgame', 'coll_id' => 3736695, 'name' => array('value' => '& Cetera', 'type' => 'primary', 'sort_index' => 1), 'year_published' => 2003, 'bgg_image_url' => 'http://cf.geekdo-images.com/images/pic50966.jpg', 'bgg_thumbnail_url' => 'http://cf.geekdo-images.com/images/pic50966_t.jpg', 'own' => true, 'previously_owned' => false, 'for_trade' => false, 'want' => false, 'want_to_play' => false, 'want_to_buy' => false, 'wishlist' => false, 'wishlist_priority' => null, 'preordered' => false, 'last_modified' => new \DateTime('2006-08-23 19:05:18'), 'num_plays' => 0, 'comment' => null, 'stats' => array('min_players' => 1, 'max_players' => 6, 'playing_time' => 240, 'num_owned' => 1000, 'rating' => array('personal' => null, 'users_rated' => 158, 'average' => 7.77652, 'bayes_average' => 6.03286, 'std_dev' => 1.23528, 'median' => 0.0), 'ranks' => array(array('type' => 'subtype', 'id' => 1, 'name' => 'boardgame', 'friendly_name' => 'Board Game Rank', 'value' => null, 'bayes_average' => 6.03286), array('type' => 'family', 'id' => 5497, 'name' => 'strategygames', 'friendly_name' => 'Strategy Game Rank', 'value' => null, 'bayes_average' => 6.21333))));
     $this->assertEquals($expectedArray, $itemArray);
 }
Пример #2
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[] = CollectionFactory::convertXmlItem($xmlItem);
     }
     return $arrayItems;
 }