示例#1
0
 /**
  * Test Get/Set, create, endpoint methods.
  */
 public function testRankEntity()
 {
     $rank = Rank::create();
     $this->assertInstanceOf('Shoko\\TwitchApiBundle\\Model\\Entity\\Rank', $rank);
     $this->assertEquals(null, $rank->getGame());
     $game = new Game();
     $this->assertEquals($game, $rank->setGame($game)->getGame());
     $this->assertEquals(0, $rank->getViewers());
     $this->assertEquals(42, $rank->setViewers(42)->getViewers());
     $this->assertEquals(0, $rank->getChannels());
     $this->assertEquals(42, $rank->setChannels(42)->getChannels());
     $this->assertEquals(array(), $rank->getLinks());
     $link = 'some_link';
     $this->assertEquals([$link], $rank->setLinks([$link])->getLinks());
 }
示例#2
0
 /**
  * @param array      $data
  * @param false|Rank $rank
  *
  * @return Rank
  */
 public function createEntity(array $data, $rank = false)
 {
     if (false === $rank) {
         $rank = Rank::create();
     }
     if (isset($data['game'])) {
         $rank->setGame((new GameFactory())->createEntity($data['game']));
     }
     if (isset($data['viewers'])) {
         $rank->setViewers($data['viewers']);
     }
     if (isset($data['channels'])) {
         $rank->setChannels($data['channels']);
     }
     if (isset($data['_links'])) {
         $rank = $rank->setLinks($data['_links']);
     }
     return $rank;
 }