Ejemplo n.º 1
0
 public function testGettersAndSetters()
 {
     $this->prophet = new Prophet();
     $token = Token::create();
     $this->assertEquals(null, $token->getAuthorization());
     $this->assertEquals(null, $token->getUserName());
     $this->assertEquals(false, $token->isValid());
     $authorization = $this->prophet->prophesize('Shoko\\TwitchApiBundle\\Model\\ValueObject\\Authorization');
     $token->setAuthorization($authorization->reveal())->setUserName('some_username')->setValid(false);
     $this->assertInstanceOf('Shoko\\TwitchApiBundle\\Model\\ValueObject\\Authorization', $token->getAuthorization());
     $this->assertEquals('some_username', $token->getUserName());
     $this->assertEquals(false, $token->isValid());
 }
Ejemplo n.º 2
0
 /**
  * @param array $data
  * @param false|Token $token
  *
  * @return Token
  */
 public function createEntity(array $data, $token = false)
 {
     if (false === $token) {
         $token = Token::create();
     }
     if (isset($data['authorization'])) {
         $token = $token->setAuthorization($this->createAuthorization($data['authorization']));
     }
     if (isset($data['user_name'])) {
         $token = $token->setUserName($data['user_name']);
     }
     if (isset($data['valid'])) {
         $token = $token->setValid($data['valid']);
     }
     return $token;
 }