/**
  * test identity field
  */
 public function testIdentityField()
 {
     $dispatcher = $this->getEventDispatcherMock();
     $dispatcher->expects($this->at(0))->method('dispatch')->with($this->equalTo(Events::JWT_CREATED), $this->isInstanceOf('Aegis\\Bundle\\JWTAuthenticationBundle\\Event\\JWTCreatedEvent'));
     $dispatcher->expects($this->at(1))->method('dispatch')->with($this->equalTo(Events::JWT_ENCODED), $this->isInstanceOf('Aegis\\Bundle\\JWTAuthenticationBundle\\Event\\JWTEncodedEvent'));
     $encoder = $this->getJWTEncoderMock();
     $encoder->expects($this->once())->method('encode')->willReturn('secrettoken');
     $manager = new JWTManager($encoder, $dispatcher, 3600);
     $manager->setUserIdentityField("email");
     $this->assertEquals('secrettoken', $manager->create(new CustomUser('user', 'password', '*****@*****.**')));
 }