public function testIsNew()
 {
     $user = new UserEntity();
     $this->assertTrue($user->isNew());
     $user->setId(5);
     $this->assertFalse($user->isNew());
 }
 public function withExistingUser()
 {
     $email = '*****@*****.**';
     $id = 'existing_user_id';
     $user = new UserEntity();
     $user->exchangeArray(['id' => $id, 'email' => $email]);
     $this->mockUserMapper->expects($this->any())->method('findByEmail')->with($this->equalTo($email))->will($this->returnValue($user));
     $this->mockUserMapper->expects($this->any())->method('findById')->with($this->equalTo($id))->will($this->returnValue($user));
     return $user;
 }
 public function getLoggedInUserEntity()
 {
     $user = new UserEntity();
     $user->exchangeArray(['id' => self::LOGGED_IN_USER_ID, 'email' => '*****@*****.**']);
     return $user;
 }
 /**
  * Create an access token given a user entity
  *
  * @param  UserEntity   $user
  * @return array        Access token
  */
 public function handleLogin(UserEntity $user)
 {
     $accessToken = new AccessToken($this->tokenStorage, $this->tokenStorage);
     $token = $accessToken->createAccessToken('', $user->getId(), null, true);
     return $token;
 }