diff --git a/docs/authentication.md b/docs/authentication.md index e295f8e2..77e63abb 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -12,7 +12,7 @@ In order to authenticate a user (or anything else) against Doctrine, the followi #### Authentication factory -To make your life easier, DoctrineModule provides an Authentication factory through the ``DoctrineModule\Options\Authentication`` class. +To make your life easier, DoctrineModule provides an Authentication factory through the ``DoctrineModule\Options\Authentication`` class. The first task is to configure the Authentication by adding the ``authentication`` key to the ``doctrine`` key in your config file (we assume here that the entity we want to authentication is simply called `Application\Entity\User`): @@ -80,15 +80,10 @@ class Module 'factories' => array( 'Zend\Authentication\AuthenticationService' => function($serviceManager) { // If you are using DoctrineORMModule: - $authenticationAdapter = $serviceManager->get('doctrine.authenticationadapter.orm_default'); - $authenticationStorage = $serviceManager->get('doctrine.authenticationstorage.orm_default'); - + return $serviceManager->get('doctrine.authenticationservice.orm_default'); + // If you are using DoctrineODMModule: - $authenticationAdapter = $serviceManager->get('doctrine.authenticationadapter.odm_default'); - $authenticationStorage = $serviceManager->get('doctrine.authenticationstorage.odm_default'); - - // Return the fully constructed AuthenticationService - return new AuthenticationService($authenticationStorage, $authenticationAdapter); + return $serviceManager->get('doctrine.authenticationservice.odm_default'); } ) ); @@ -96,7 +91,7 @@ class Module } ``` -Please note that Iam using here a ``Zend\Authentication\AuthenticationService`` name, but it can be anything else (``my_auth_service``…). +Please note that Iam using here a ``Zend\Authentication\AuthenticationService`` name, but it can be anything else (``my_auth_service``…). However, using the name ``Zend\Authentication\AuthenticationService`` will allow it to be recognised by the ZF2 view helper. #### Using the AuthenticationService @@ -126,7 +121,7 @@ public function loginAction() )); } ``` - + Of course, doing this in the controller is not the best practice, and you'd better move that kind of logic to a service layer. But this is how it works. Note that when the authentication is valid, we first get the identity : @@ -134,167 +129,45 @@ Note that when the authentication is valid, we first get the identity : ```php $identity = $authenticationResult->getIdentity(); ``` - + This will return the full entity (in our case, an `Application\Entity\User` instance). However, storing a full entity in session is not a recommended practice. That's why, when writing the identity : ```php $authService->getStorage()->write($identity); ``` - + The storage automatically extracts ONLY the identifier values and only store this in session (this avoid to store in session a serialized entity, which is a bad practice). Later, when you want to retrieve the logged user : ```php $authenticationService = $this->serviceLocator()->get('Zend\Authentication\AuthenticationService'); $loggedUser = $authenticationService->getIdentity(); ``` - + The authentication storage will automatically handle the conversion from saved data to managed entity and the opposite. It will avoid serializing entities since that is a strongly discouraged practice. #### View helper and controller helper -You may also need to know if there is an authenticated user within your other controllers or in views. Here's examples of a controller plugin and a view helper you may use. - -Here is a sample code that shows you the Controller Plugin : - -```php -authenticationService = $authenticationService; - } - - /** - * @return \Application\Entity\User - */ - public function __invoke() - { - if ($this->authenticationService->hasIdentity()) { - return $this->authenticationService->getIdentity(); - } - - return null; - } -} -``` - -The View Helper is very similar : - -```php -authenticationService = $authenticationService; - } - - /** - * @return \Application\Entity\User - */ - public function __invoke() - { - if ($this->authenticationService->hasIdentity()) { - return $this->authenticationService->getIdentity(); - } - - return null; - } -} -``` - -You now need to tell the ServiceManager how to find the Controller Plugin and the View Helper. Add the following code in your Module.php class : - -```php -/** - * @return array - */ -public function getViewHelperConfig() -{ - return array( - 'factories' => array( - 'userIdentity' => function ($serviceManager) { - $authenticationService = $serviceManager->getServiceLocator() - ->get('Zend\Authentication\AuthenticationService'); - - return new \Application\View\Helper\UserIdentity($authenticationService); - } - ) - ); -} - -/** - * @return array - */ -public function getControllerPluginConfig() -{ - return array( - 'factories' => array( - 'userIdentity' => function ($serviceManager) { - $authenticationService = $serviceManager->getServiceLocator() - ->get('Zend\Authentication\AuthenticationService'); - - return new \Application\Controller\Plugin\UserIdentity($authenticationService); - } - ) - ); -} -``` - -This is very simple code. This code automatically handles the dependencies with the AuthenticationService. +You may also need to know if there is an authenticated user within your other controllers or in views. ZF2 provides a controller plugin and a view helper you may use. Here is how you use it in your controller : ```php public function testAction() { - if ($user = $this->userIdentity()) { + if ($user = $this->identity()) { // someone is logged ! } else { // not logged in } } ``` - + And in your view : ```php userIdentity()) { - echo 'Logged in as ' . $this->escapeHtml($user->getLogin()); + if ($user = $this->identity()) { + echo 'Logged in as ' . $this->escapeHtml($user->getUsername()); } else { echo 'Not logged in'; } diff --git a/src/DoctrineModule/Authentication/Adapter/ObjectRepository.php b/src/DoctrineModule/Authentication/Adapter/ObjectRepository.php index c0681278..3d59e03a 100644 --- a/src/DoctrineModule/Authentication/Adapter/ObjectRepository.php +++ b/src/DoctrineModule/Authentication/Adapter/ObjectRepository.php @@ -19,7 +19,7 @@ namespace DoctrineModule\Authentication\Adapter; -use DoctrineModule\Options\AuthenticationAdapter as AuthenticationOptions; +use DoctrineModule\Options\Authentication as AuthenticationOptions; use Zend\Authentication\Adapter\AdapterInterface; use Zend\Authentication\Adapter\Exception; use Zend\Authentication\Result as AuthenticationResult; diff --git a/src/DoctrineModule/Authentication/Storage/ObjectRepository.php b/src/DoctrineModule/Authentication/Storage/ObjectRepository.php index 17adb952..9e5201e7 100644 --- a/src/DoctrineModule/Authentication/Storage/ObjectRepository.php +++ b/src/DoctrineModule/Authentication/Storage/ObjectRepository.php @@ -19,8 +19,7 @@ namespace DoctrineModule\Authentication\Storage; -use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory; -use Doctrine\Common\Persistence\ObjectRepository as DoctrineRepository; +use DoctrineModule\Options\Authentication as AuthenticationOptions; use Zend\Authentication\Storage\StorageInterface; /** @@ -33,34 +32,35 @@ */ class ObjectRepository implements StorageInterface { - /** - * @var DoctrineRepository - */ - protected $objectRepository; /** - * Metadata factory * - * @var ClassMetadataFactory + * @var \DoctrineModule\Options\Authentication */ - protected $metadataFactory; + protected $options; /** - * @var StorageInterface + * @param array | \DoctrineModule\Options\Authentication $options + * @return ObjectRepository */ - protected $storage; - + public function setOptions($options) + { + if (!$options instanceof AuthenticationOptions) { + $options = new AuthenticationOptions($options); + } + $this->options = $options; + return $this; + } + /** - * @param DoctrineRepository $objectRepository - * @param ClassMetadataFactory $metadataFactory - * @param StorageInterface $storage + * Constructor + * + * @param array | \DoctrineModule\Options\Authentication $options */ - public function __construct(DoctrineRepository $objectRepository, ClassMetadataFactory $metadataFactory, StorageInterface $storage) + public function __construct($options = array()) { - $this->objectRepository = $objectRepository; - $this->storage = $storage; - $this->metadataFactory = $metadataFactory; + $this->setOptions($options); } /** @@ -68,7 +68,7 @@ public function __construct(DoctrineRepository $objectRepository, ClassMetadataF */ public function isEmpty() { - return $this->storage->isEmpty(); + return $this->options->getStorage()->isEmpty(); } /** @@ -79,23 +79,33 @@ public function isEmpty() */ public function read() { - if (($identity = $this->storage->read())) { - return $this->objectRepository->find($identity); + if (($identity = $this->options->getStorage()->read())) { + return $this->options->getObjectRepository()->find($identity); } return null; } + /** + * Will return the key of the identity. If only the key is needed, this avoids an + * unnessisary db call + * + * @return mixed + */ + public function readKeyOnly(){ + return $identity = $this->options->getStorage()->read(); + } + /** * @param object $identity * @return void */ public function write($identity) { - $metadataInfo = $this->metadataFactory->getMetadataFor(get_class($identity)); + $metadataInfo = $this->options->getClassMetadata(); $identifierValues = $metadataInfo->getIdentifierValues($identity); - $this->storage->write($identifierValues); + $this->options->getStorage()->write($identifierValues); } /** @@ -103,6 +113,6 @@ public function write($identity) */ public function clear() { - $this->storage->clear(); + $this->options->getStorage()->clear(); } } diff --git a/src/DoctrineModule/Options/AuthenticationAdapter.php b/src/DoctrineModule/Options/Authentication.php similarity index 69% rename from src/DoctrineModule/Options/AuthenticationAdapter.php rename to src/DoctrineModule/Options/Authentication.php index 39d40bb5..93503528 100644 --- a/src/DoctrineModule/Options/AuthenticationAdapter.php +++ b/src/DoctrineModule/Options/Authentication.php @@ -19,14 +19,22 @@ namespace DoctrineModule\Options; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Zend\Authentication\Adapter\Exception; +use Zend\Authentication\Storage\Session as SessionStorage; +use Zend\Authentication\Storage\StorageInterface; use Zend\Stdlib\AbstractOptions; /** - * This options class is used by both DoctrineModule\Authentication\Adapter\ObjectRepository - * and DoctrineModule\Service\AuthenticationAdapterFactory. + * This options class can be consumed by five different classes: + * + * DoctrineModule\Authentication\Adapter\ObjectRepository + * DoctrineModule\Service\Authentication\AdapterFactory + * DoctrineModule\Authentication\Storage\ObjectRepository + * DoctrineModule\Service\Authentication\ServiceFactory + * DoctrineModule\Service\Authentication\AuthenticationServiceFactory * * When using with DoctrineModule\Authentication\Adapter\ObjectRepository the following * options are required: @@ -42,12 +50,21 @@ * however, a string may be passed to $objectManager. This string must be a valid key to * retrieve an ObjectManager instance from the ServiceManager. * + * When using with DoctrineModule\Authentication\Service\Object repository the following + * options are required: + * + * Either $objectManager, or $classMetadata and $objectRepository. + * + * All remains the same using with DoctrineModule\Service\AuthenticationStorageFactory, + * however, a string may be passed to $objectManager. This string must be a valid key to + * retrieve an ObjectManager instance from the ServiceManager. + * * @license MIT * @link http://www.doctrine-project.org/ * @since 0.5.0 * @author Michaël Gallego */ -class AuthenticationAdapter extends AbstractOptions +class Authentication extends AbstractOptions { /** * A valid object implementing ObjectManager interface @@ -91,6 +108,26 @@ class AuthenticationAdapter extends AbstractOptions */ protected $credentialCallable; + /** + * + * If an objectManager is not supplied, this metadata will be used + * by DoctrineModule/Authentication/Storage/ObjectRepository + * + * @var \Doctrine\Common\Persistence\Mapping\ClassMetadata + */ + protected $classMetadata; + + /** + * When using this options class to create a DoctrineModule/Authentication/Storage/ObjectRepository + * this is the storage instance that the object key will be stored in. + * + * When useing this options class to create an AuthenticationService with and + * the option storeOnlyKeys == false, this is the storage instance that the whole + * object will be stored in. + * + * @var \Zend\Authentication\Storage\StorageInterface; + */ + protected $storage; /** * @param string | ObjectManager $objectManager @@ -230,4 +267,44 @@ public function getCredentialCallable() { return $this->credentialCallable; } + + /** + * + * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata + */ + public function getClassMetadata() { + + if ($this->classMetadata) { + return $this->classMetadata; + } + + return $this->objectManager->getClassMetadata($this->identityClass); + } + + /** + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata + */ + public function setClassMetadata(ClassMetadata $classMetadata) { + $this->classMetadata = $classMetadata; + } + + /** + * + * @return \Zend\Authentication\Storage\StorageInterface + */ + public function getStorage() { + if ( ! $this->storage instanceof StorageInterface){ + $this->storage = new SessionStorage(); + } + return $this->storage; + } + + /** + * + * @param \Zend\Authentication\Storage\StorageInterface $storage + */ + public function setStorage(StorageInterface $storage) { + $this->storage = $storage; + } } diff --git a/src/DoctrineModule/Service/AuthenticationAdapterFactory.php b/src/DoctrineModule/Service/Authentication/AdapterFactory.php similarity index 91% rename from src/DoctrineModule/Service/AuthenticationAdapterFactory.php rename to src/DoctrineModule/Service/Authentication/AdapterFactory.php index df06f353..5bb2f086 100644 --- a/src/DoctrineModule/Service/AuthenticationAdapterFactory.php +++ b/src/DoctrineModule/Service/Authentication/AdapterFactory.php @@ -16,7 +16,7 @@ * and is licensed under the MIT license. For more information, see * . */ -namespace DoctrineModule\Service; +namespace DoctrineModule\Service\Authentication; use DoctrineModule\Authentication\Adapter\ObjectRepository; use DoctrineModule\Service\AbstractFactory; @@ -30,7 +30,7 @@ * @since 0.1.0 * @author Tim Roediger */ -class AuthenticationAdapterFactory extends AbstractFactory +class AdapterFactory extends AbstractFactory { /** * @@ -39,7 +39,7 @@ class AuthenticationAdapterFactory extends AbstractFactory */ public function createService(ServiceLocatorInterface $serviceLocator) { - $options = $this->getOptions($serviceLocator, 'authenticationadapter'); + $options = $this->getOptions($serviceLocator, 'authentication'); if (is_string($options->getObjectManager())) { $options->setObjectManager($serviceLocator->get($options->getObjectManager())); } @@ -48,6 +48,6 @@ public function createService(ServiceLocatorInterface $serviceLocator) public function getOptionsClass() { - return 'DoctrineModule\Options\AuthenticationAdapter'; + return 'DoctrineModule\Options\Authentication'; } } diff --git a/src/DoctrineModule/Service/Authentication/AuthenticationServiceFactory.php b/src/DoctrineModule/Service/Authentication/AuthenticationServiceFactory.php new file mode 100644 index 00000000..5d08add0 --- /dev/null +++ b/src/DoctrineModule/Service/Authentication/AuthenticationServiceFactory.php @@ -0,0 +1,50 @@ +. + */ +namespace DoctrineModule\Service\Authentication; + +use DoctrineModule\Service\AbstractFactory; +use Zend\Authentication\AuthenticationService; +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * Factory to create authentication service object. + * + * @license MIT + * @link http://www.doctrine-project.org/ + * @since 0.1.0 + * @author Tim Roediger + */ +class AuthenticationServiceFactory extends AbstractFactory +{ + /** + * + * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator + * @return \Zend\Authentication\AuthenticationService + */ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return new AuthenticationService( + $serviceLocator->get('doctrine.authenticationstorage.' . $this->getName()), + $serviceLocator->get('doctrine.authenticationadapter.' . $this->getName()) + ); + } + + public function getOptionsClass() + {} +} diff --git a/src/DoctrineModule/Service/Authentication/StorageFactory.php b/src/DoctrineModule/Service/Authentication/StorageFactory.php new file mode 100644 index 00000000..857d2f5b --- /dev/null +++ b/src/DoctrineModule/Service/Authentication/StorageFactory.php @@ -0,0 +1,53 @@ +. + */ +namespace DoctrineModule\Service\Authentication; + +use DoctrineModule\Authentication\Storage\ObjectRepository; +use DoctrineModule\Service\AbstractFactory; +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * Factory to create authentication storage object. + * + * @license MIT + * @link http://www.doctrine-project.org/ + * @since 0.1.0 + * @author Tim Roediger + */ +class StorageFactory extends AbstractFactory +{ + /** + * + * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator + * @return \DoctrineModule\Authentication\Adapter\DoctrineObjectRepository + */ + public function createService(ServiceLocatorInterface $serviceLocator) + { + $options = $this->getOptions($serviceLocator, 'authentication'); + if (is_string($options->getObjectManager())) { + $options->setObjectManager($serviceLocator->get($options->getObjectManager())); + } + return new ObjectRepository($options); + } + + public function getOptionsClass() + { + return 'DoctrineModule\Options\Authentication'; + } +} diff --git a/tests/DoctrineModuleTest/Authentication/Adapter/ObjectRepositoryTest.php b/tests/DoctrineModuleTest/Authentication/Adapter/ObjectRepositoryTest.php index dedf635b..93b45e16 100644 --- a/tests/DoctrineModuleTest/Authentication/Adapter/ObjectRepositoryTest.php +++ b/tests/DoctrineModuleTest/Authentication/Adapter/ObjectRepositoryTest.php @@ -21,7 +21,6 @@ use PHPUnit_Framework_TestCase as BaseTestCase; use DoctrineModule\Authentication\Adapter\ObjectRepository as ObjectRepositoryAdapter; -use DoctrineModule\Options\Authentication as AuthenticationOptions; use DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject; use DoctrineModuleTest\Authentication\Adapter\TestAsset\PublicPropertiesIdentityObject; diff --git a/tests/DoctrineModuleTest/Authentication/Storage/ObjectRepositoryTest.php b/tests/DoctrineModuleTest/Authentication/Storage/ObjectRepositoryTest.php index 99b304c8..a759a1cd 100644 --- a/tests/DoctrineModuleTest/Authentication/Storage/ObjectRepositoryTest.php +++ b/tests/DoctrineModuleTest/Authentication/Storage/ObjectRepositoryTest.php @@ -21,10 +21,8 @@ use PHPUnit_Framework_TestCase as BaseTestCase; use DoctrineModule\Authentication\Storage\ObjectRepository as ObjectRepositoryStorage; -use DoctrineModule\Options\Authentication as AuthenticationOptions; use DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject; -use DoctrineModuleTest\Authentication\Adapter\TestAsset\PublicPropertiesIdentityObject; -use Zend\Authentication\Storage\Session as SessionStorage; +use Zend\Authentication\Storage\NonPersistent as NonPersistentStorage; /** * Tests for the ObjectRepository based authentication adapter @@ -53,19 +51,20 @@ public function testCanRetrieveEntityFromObjectRepositoryStorage() ->method('getIdentifierValues') ->with($this->equalTo($entity)) ->will($this->returnValue($entity->getUsername())); - - $metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory'); - $metadataFactory->expects($this->exactly(1)) - ->method('getMetadataFor') - ->with($this->equalTo('DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject')) - ->will($this->returnValue($metadata)); - - $storage = new ObjectRepositoryStorage($objectRepository, $metadataFactory, new SessionStorage()); + + $storage = new ObjectRepositoryStorage(array( + 'objectRepository' => $objectRepository, + 'classMetadata' => $metadata, + 'storage' => new NonPersistentStorage() + )); $storage->write($entity); $this->assertFalse($storage->isEmpty()); $result = $storage->read(); $this->assertEquals($entity, $result); + + $key = $storage->readKeyOnly(); + $this->assertEquals('a username', $key); } } diff --git a/tests/DoctrineModuleTest/Service/Authentication/AdapterFactoryTest.php b/tests/DoctrineModuleTest/Service/Authentication/AdapterFactoryTest.php new file mode 100644 index 00000000..30489a84 --- /dev/null +++ b/tests/DoctrineModuleTest/Service/Authentication/AdapterFactoryTest.php @@ -0,0 +1,56 @@ +. + */ + +namespace DoctrineModuleTest\Service\Authentication; + +use DoctrineModule\Service\Authentication\AdapterFactory; +use PHPUnit_Framework_TestCase as BaseTestCase; +use Zend\ServiceManager\ServiceManager; + +class AdapterFactoryTest extends BaseTestCase +{ + public function testWillInstantiateFromFQCN() + { + + $name = 'testFactory'; + $factory = new AdapterFactory($name); + + $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + + $serviceManager = new ServiceManager(); + $serviceManager->setService( + 'Configuration', + array( + 'doctrine' => array( + 'authentication' => array( + $name => array( + 'objectManager' => $objectManager, + 'identityClass' => 'DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject', + 'identityProperty' => 'username', + 'credentialProperty' => 'password' + ), + ), + ), + ) + ); + + $adapter = $factory->createService($serviceManager); + $this->assertInstanceOf('DoctrineModule\Authentication\Adapter\ObjectRepository', $adapter); + } +} diff --git a/tests/DoctrineModuleTest/Service/Authentication/AuthenticationServiceFactoryTest.php b/tests/DoctrineModuleTest/Service/Authentication/AuthenticationServiceFactoryTest.php new file mode 100644 index 00000000..02b2dc89 --- /dev/null +++ b/tests/DoctrineModuleTest/Service/Authentication/AuthenticationServiceFactoryTest.php @@ -0,0 +1,60 @@ +. + */ + +namespace DoctrineModuleTest\Service\Authentication; + +use DoctrineModule\Service\Authentication\AuthenticationServiceFactory; +use DoctrineModule\Service\Authentication\AdapterFactory; +use DoctrineModule\Service\Authentication\StorageFactory; +use PHPUnit_Framework_TestCase as BaseTestCase; +use Zend\ServiceManager\ServiceManager; + +class AuthenticationServiceFactoryTest extends BaseTestCase +{ + public function testWillInstantiateFromFQCN() + { + + $name = 'testFactory'; + $factory = new AuthenticationServiceFactory($name); + + $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + + $serviceManager = new ServiceManager(); + $serviceManager->setService( + 'Configuration', + array( + 'doctrine' => array( + 'authentication' => array( + $name => array( + 'objectManager' => $objectManager, + 'identityClass' => 'DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject', + 'identityProperty' => 'username', + 'credentialProperty' => 'password' + ), + ), + ), + ) + ); + $serviceManager->setFactory('doctrine.authenticationadapter.' . $name, new AdapterFactory($name)); + $serviceManager->setFactory('doctrine.authenticationstorage.' . $name, new StorageFactory($name)); + + $authenticationService = $factory->createService($serviceManager); + $this->assertInstanceOf('Zend\Authentication\AuthenticationService', $authenticationService); + } +} diff --git a/tests/DoctrineModuleTest/Service/Authentication/StorageFactoryTest.php b/tests/DoctrineModuleTest/Service/Authentication/StorageFactoryTest.php new file mode 100644 index 00000000..5a51dfad --- /dev/null +++ b/tests/DoctrineModuleTest/Service/Authentication/StorageFactoryTest.php @@ -0,0 +1,55 @@ +. + */ + +namespace DoctrineModuleTest\Service\Authentication; + +use DoctrineModule\Service\Authentication\StorageFactory; +use PHPUnit_Framework_TestCase as BaseTestCase; +use Zend\ServiceManager\ServiceManager; + +class StorageFactoryTest extends BaseTestCase +{ + public function testWillInstantiateFromFQCN() + { + $name = 'testFactory'; + $factory = new StorageFactory($name); + + $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + + $serviceManager = new ServiceManager(); + $serviceManager->setService( + 'Configuration', + array( + 'doctrine' => array( + 'authentication' => array( + $name => array( + 'objectManager' => $objectManager, + 'identityClass' => 'DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject', + 'identityProperty' => 'username', + 'credentialProperty' => 'password' + ), + ), + ), + ) + ); + + $adapter = $factory->createService($serviceManager); + $this->assertInstanceOf('DoctrineModule\Authentication\Storage\ObjectRepository', $adapter); + } +}