public function testGetAuthenticationResponse()
 {
     $token = \Phake::mock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $resp = Authenticator::getAuthenticationResponse($token);
     $this->assertInternalType('array', $resp);
     $this->assertArrayHasKey('success', $resp);
     $this->assertFalse($resp['success']);
     $user = new User();
     $user->setFirstName('John');
     $user->setLastName('Doe');
     $user->setEmail('*****@*****.**');
     $user->setUsername('john.doe');
     $role = \Phake::mock('Symfony\\Component\\Security\\Core\\Role\\RoleInterface');
     \Phake::when($role)->getRole()->thenReturn('ROLE_USER');
     \Phake::when($token)->isAuthenticated()->thenReturn(true);
     \Phake::when($token)->getUser()->thenReturn($user);
     \Phake::when($token)->getRoles()->thenReturn(array($role));
     $resp = Authenticator::getAuthenticationResponse($token);
     $this->assertInternalType('array', $resp);
     $this->assertArrayHasKey('success', $resp);
     $this->assertTrue($resp['success']);
     $this->assertArrayHasKey('profile', $resp);
     $this->assertInternalType('array', $resp['profile']);
     $this->assertEquals(array('id' => $user->getId(), 'name' => $user->getFullName(), 'email' => $user->getEmail(), 'username' => $user->getUsername()), $resp['profile']);
 }
 private function createUser()
 {
     $u = new User();
     $u->setFirstName('Joe');
     $u->setLastName('Doe');
     $u->setUsername('djatel');
     $u->setEmail('*****@*****.**');
     $u->setPassword(1234);
     self::$em->persist($u);
     self::$em->flush();
     return $u;
 }