コード例 #1
0
 /**
  * {@inheritDoc}
  *
  * @return Identity
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     $helper = new Identity();
     if ($container->has(AuthenticationService::class)) {
         $helper->setAuthenticationService($container->get(AuthenticationService::class));
     }
     return $helper;
 }
コード例 #2
0
 public function testGetIdentity()
 {
     $identity = new TestAsset\IdentityObject();
     $identity->setUsername('a username');
     $identity->setPassword('a password');
     $authenticationService = new AuthenticationService(new NonPersistentStorage(), new TestAsset\AuthenticationAdapter());
     $identityPlugin = new IdentityPlugin();
     $identityPlugin->setAuthenticationService($authenticationService);
     $this->assertNull($identityPlugin());
     $this->assertFalse($authenticationService->hasIdentity());
     $authenticationService->getAdapter()->setIdentity($identity);
     $result = $authenticationService->authenticate();
     $this->assertTrue($result->isValid());
     $this->assertEquals($identity, $identityPlugin());
 }