示例#1
0
 /**
  * Test Create, Endpoint, Get/Set methods.
  */
 public function testRootEntity()
 {
     $root = Root::create();
     $this->assertInstanceOf('Shoko\\TwitchApiBundle\\Model\\Entity\\Root', $root);
     $this->assertEquals(null, $root->getToken());
     $token = $this->prophet->prophesize('Shoko\\TwitchApiBundle\\Model\\ValueObject\\Token');
     $this->assertEquals($token->reveal(), $root->setToken($token->reveal())->getToken());
     $this->assertEquals(array(), $root->getLinks());
     $link = 'some_link';
     $this->assertEquals([$link], $root->setLinks([$link])->getLinks());
 }
示例#2
0
 /**
  * @param array $data
  * @param false|Root $root
  *
  * @return Root
  */
 public function createEntity(array $data, $root = false)
 {
     if (false === $root) {
         $root = Root::create();
     }
     if (isset($data['token'])) {
         $root = $root->setToken((new TokenFactory())->createEntity($data['token']));
     }
     if (isset($data['_links'])) {
         $root = $root->setLinks($data['_links']);
     }
     return $root;
 }