Пример #1
0
 /**
  * Test Get/Set, create, endpoint methods.
  */
 public function testTopEntity()
 {
     $top = Top::create();
     $this->assertInstanceOf('Shoko\\TwitchApiBundle\\Model\\Entity\\Top', $top);
     $this->assertEquals(array(), $top->getRanks());
     $this->assertEquals(array('some_rank'), $top->setRanks(array('some_rank'))->getRanks());
     $this->assertEquals(array(), $top->getLinks());
     $this->assertEquals(array('some_link'), $top->setLinks(array('some_link'))->getLinks());
     $this->assertEquals(0, $top->getTotal());
     $this->assertEquals(42, $top->setTotal(42)->getTotal());
 }
Пример #2
0
 /**
  * @param array      $data
  * @param false|Rank $rank
  *
  * @return Rank
  */
 public function createEntity(array $data, $rank = false)
 {
     if (false === $rank) {
         $rank = Top::create();
     }
     if (isset($data['top'])) {
         $rank = $rank->setRanks($this->createRanks($data['top']));
     }
     if (isset($data['_links'])) {
         $rank = $rank->setLinks($data['_links']);
     }
     if (isset($data['_total'])) {
         $rank = $rank->setTotal($data['_total']);
     }
     return $rank;
 }