Permalink
Browse files

Merge pull request #62 from bakura10/auth-fix

Remove auth factory
  • Loading branch information...
2 parents f96aef4 + 706558f commit 3b613dba73dbd79ad32131f22691020365b5aa0d @Ocramius Ocramius committed Jul 24, 2012
@@ -19,6 +19,7 @@
namespace DoctrineModule;
+use DoctrineModule\Service\AuthenticationFactory;
use DoctrineModule\Service\CacheFactory;
use DoctrineModule\Service\ZendStorageCacheFactory;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
@@ -63,8 +64,7 @@ public function getServiceConfig()
'doctrine.cache.wincache' => new CacheFactory('wincache'),
'doctrine.cache.xcache' => new CacheFactory('xcache'),
'doctrine.cache.zenddata' => new CacheFactory('zenddata'),
- 'doctrine.cache.zendcachestorage' => new ZendStorageCacheFactory('zendcachestorage'),
- 'doctrine.service.authentication' => 'DoctrineModule\Service\AuthenticationFactory',
+ 'doctrine.cache.zendcachestorage' => new ZendStorageCacheFactory('zendcachestorage')
)
);
}
@@ -1,47 +0,0 @@
-<?php
-
-namespace DoctrineModule\Service;
-
-use DoctrineModule\Authentication\Storage\ObjectRepository as ObjectRepositoryStorage;
-use DoctrineModule\Authentication\Adapter\ObjectRepository as ObjectRepositoryAdapter;
-use DoctrineModule\Options\Authentication as AuthenticationOptions;
-use DoctrineModule\Service\AbstractFactory;
-use Zend\Authentication\AuthenticationService;
-use Zend\Authentication\Storage\Session as SessionStorage;
-use Zend\ServiceManager\FactoryInterface;
-use Zend\ServiceManager\ServiceLocatorInterface;
-
-class AuthenticationFactory extends AbstractFactory
-{
- /**
- * @param ServiceLocatorInterface $sl
- * @return AuthenticationService
- */
- public function createService(ServiceLocatorInterface $sl)
- {
- /** @var $options AuthenticationOptions */
- $options = $this->getOptions($sl, 'authentication');
-
- $om = $options->getObjectManager();
- $objectRepository = $om->getRepository($options->getIdentityClass());
- $metadataFactory = $om->getMetadataFactory();
-
- $storage = new ObjectRepositoryStorage($objectRepository, $metadataFactory, new SessionStorage());
-
- $adapter = new ObjectRepositoryAdapter($options);
-
- $authenticationService = new AuthenticationService($storage, $adapter);
-
- return $authenticationService;
- }
-
- /**
- * Get the class name of the options associated with this factory.
- *
- * @return string
- */
- public function getOptionsClass()
- {
- return 'DoctrineModule\Options\Authentication';
- }
-}
@@ -1,66 +0,0 @@
-<?php
-/*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the MIT license. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
-namespace DoctrineModuleTest\Service;
-
-use PHPUnit_Framework_TestCase as BaseTestCase;
-use DoctrineModule\Service\AuthenticationFactory;
-use Zend\ServiceManager\ServiceManager;
-use DoctrineModuleTest\Service\TestAsset\DummyEventSubscriber;
-
-/**
- * Base test case to be used when a service manager instance is required
- */
-class AuthenticationFactoryTest extends BaseTestCase
-{
- public function testWillInstantiateFromFQCN()
- {
- $name = 'autenticationFactory';
- $factory = new AuthenticationFactory($name);
-
- $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
- $objectManager->expects($this->exactly(1))
- ->method('getRepository')
- ->will($this->returnValue($this->getMock('Doctrine\Common\Persistence\ObjectRepository')));
-
- $objectManager->expects($this->exactly(1))
- ->method('getMetadataFactory')
- ->will($this->returnValue($this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory')));
-
- $serviceManager = new ServiceManager();
- $serviceManager->setService(
- 'Configuration',
- array(
- 'doctrine' => array(
- 'authentication' => array(
- $name => array(
- 'object_manager' => $objectManager,
- 'identity_class' => 'DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject',
- 'identity_property' => 'username',
- 'credential_property' => 'password'
- )
- ),
- ),
- )
- );
-
- $authenticationService = $factory->createService($serviceManager);
- $this->assertInstanceOf('Zend\Authentication\AuthenticationService', $authenticationService);
- }
-}

0 comments on commit 3b613db

Please sign in to comment.