[CLEANUP] Remove deprecated repository constructor 75/23175/2
authorFelix Oertel <fo@lightwerk.com>
Sat, 17 Aug 2013 13:08:27 +0000 (15:08 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 18 Aug 2013 13:02:29 +0000 (15:02 +0200)
Resolves: #51142
Releases: 6.2
Change-Id: I4d7e49d564df0f59c75802a6526ca0ede1f3477c
Reviewed-on: https://review.typo3.org/23175
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/PersistenceManagerTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php
typo3/sysext/extensionmanager/Tests/Unit/Controller/UpdateFromTerControllerTest.php
typo3/sysext/extensionmanager/Tests/Unit/Domain/Repository/RepositoryRepositoryTest.php
typo3/sysext/extensionmanager/Tests/Unit/Report/ExtensionStatusTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/DependencyUtilityTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/ListUtilityTest.php

index 3cef6a4..9c8be55 100644 (file)
@@ -85,25 +85,12 @@ class Repository implements \TYPO3\CMS\Extbase\Persistence\RepositoryInterface,
         * Constructs a new Repository
         *
         * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
-        * @deprecated since Extbase 6.0.0; will be removed in Extbase 6.2 - Use objectManager to instantiate repository objects instead of GeneralUtility::makeInstance
         */
-       public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager = NULL) {
+       public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager) {
+               $this->objectManager = $objectManager;
+
                $nsSeparator = strpos($this->getRepositoryClassName(), '\\') !== FALSE ? '\\\\' : '_';
                $this->objectType = preg_replace(array('/' . $nsSeparator . 'Repository' . $nsSeparator . '(?!.*' . $nsSeparator . 'Repository' . $nsSeparator . ')/', '/Repository$/'), array($nsSeparator . 'Model' . $nsSeparator, ''), $this->getRepositoryClassName());
-               if ($objectManager === NULL) {
-                       // Legacy creation, in case the object manager is NOT injected
-                       // If ObjectManager IS there, then all properties are automatically injected
-                       // @deprecated since Extbase 6.0.0, will be removed in Extbase 6.2
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
-
-                       $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
-                       $this->identityMap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\IdentityMap');
-                       $this->persistenceManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
-                       $this->backend = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\BackendInterface');
-                       $this->session = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session');
-               } else {
-                       $this->objectManager = $objectManager;
-               }
        }
 
        /**
index ac5ebe7..e62d599 100644 (file)
@@ -36,6 +36,15 @@ require_once __DIR__ . '/../Fixture/Model/Entity2.php';
 class PersistenceManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
+        */
+       protected $mockObjectManager;
+
+       public function setUp() {
+               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
+       }
+
+       /**
         * @test
         */
        public function persistAllPassesAddedObjectsToBackend() {
@@ -234,7 +243,7 @@ class PersistenceManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
                $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
                $changedEntities = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
                $entity1 = new $classNameWithNamespace();
-               $repository = $this->getAccessibleMock($repositorClassNameWithNamespace, array('dummy'));
+               $repository = $this->getAccessibleMock($repositorClassNameWithNamespace, array('dummy'), array($this->mockObjectManager));
                $repository->_set('objectType', get_class($entity1));
                $mockBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend'), array('commit', 'setChangedEntities'), array(), '', FALSE);
                $mockBackend->expects($this->once())
index c9db820..d9f6d75 100644 (file)
@@ -105,11 +105,10 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
                $mockPersistenceManager->expects($this->once())->method('createQueryForType')->with('ExpectedType');
 
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $repository->_set('objectType', 'ExpectedType');
-               $this->inject($repository, 'persistenceManager', $mockPersistenceManager);
+               $this->repository->_set('objectType', 'ExpectedType');
+               $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
 
-               $repository->createQuery();
+               $this->repository->createQuery();
        }
 
        /**
@@ -122,14 +121,13 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
                $mockPersistenceManager->expects($this->exactly(2))->method('createQueryForType')->with('ExpectedType')->will($this->returnValue($mockQuery));
 
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $repository->_set('objectType', 'ExpectedType');
-               $this->inject($repository, 'persistenceManager', $mockPersistenceManager);
-               $repository->setDefaultOrderings($orderings);
-               $repository->createQuery();
+               $this->repository->_set('objectType', 'ExpectedType');
+               $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
+               $this->repository->setDefaultOrderings($orderings);
+               $this->repository->createQuery();
 
-               $repository->setDefaultOrderings(array());
-               $repository->createQuery();
+               $this->repository->setDefaultOrderings(array());
+               $this->repository->createQuery();
        }
 
        /**
@@ -141,7 +139,7 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
                $mockQuery->expects($this->once())->method('execute')->with()->will($this->returnValue($expectedResult));
 
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($expectedResult, $repository->findAll());
@@ -162,9 +160,12 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockQuery->expects($this->once())->method('matching')->will($this->returnValue($mockQuery));
                $mockQuery->expects($this->once())->method('execute')->will($this->returnValue($expectedResult));
 
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
-               $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
+               $session = $this->getMock('TYPO3\CMS\Extbase\Persistence\Generic\Session');
+               $session->expects($this->once())->method('hasIdentifier')->will($this->returnValue(FALSE));
 
+               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
+               $repository->_set('session', $session);
+               $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
                $this->assertSame($object, $repository->findByIdentifier($identifier));
        }
 
@@ -175,10 +176,9 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $object = new \stdClass();
                $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->once())->method('add')->with($object);
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $this->inject($repository, 'persistenceManager', $mockPersistenceManager);
-               $repository->_set('objectType', get_class($object));
-               $repository->add($object);
+               $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
+               $this->repository->_set('objectType', get_class($object));
+               $this->repository->add($object);
        }
 
        /**
@@ -188,10 +188,9 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $object = new \stdClass();
                $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->once())->method('remove')->with($object);
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $this->inject($repository, 'persistenceManager', $mockPersistenceManager);
-               $repository->_set('objectType', get_class($object));
-               $repository->remove($object);
+               $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
+               $this->repository->_set('objectType', get_class($object));
+               $this->repository->remove($object);
        }
 
        /**
@@ -201,10 +200,9 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $object = new \stdClass();
                $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->once())->method('update')->with($object);
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $this->inject($repository, 'persistenceManager', $mockPersistenceManager);
-               $repository->_set('objectType', get_class($object));
-               $repository->update($object);
+               $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
+               $this->repository->_set('objectType', get_class($object));
+               $this->repository->update($object);
        }
 
        /**
@@ -217,7 +215,7 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockQuery->expects($this->once())->method('matching')->with('matchCriteria')->will($this->returnValue($mockQuery));
                $mockQuery->expects($this->once())->method('execute')->with()->will($this->returnValue($mockQueryResult));
 
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($mockQueryResult, $repository->findByFoo('bar'));
@@ -236,7 +234,7 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockQuery->expects($this->once())->method('setLimit')->will($this->returnValue($mockQuery));
                $mockQuery->expects($this->once())->method('execute')->will($this->returnValue($mockQueryResult));
 
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($object, $repository->findOneByFoo('bar'));
@@ -253,7 +251,7 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockQuery->expects($this->once())->method('execute')->will($this->returnValue($mockQueryResult));
                $mockQueryResult->expects($this->once())->method('count')->will($this->returnValue(2));
 
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame(2, $repository->countByFoo('bar'));
@@ -264,7 +262,7 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @expectedException \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException
         */
        public function magicCallMethodTriggersAnErrorIfUnknownMethodsAreCalled() {
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
                $repository->__call('foo', array());
        }
 
@@ -273,10 +271,8 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @expectedException \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
         */
        public function addChecksObjectType() {
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $repository->_set('objectType', 'ExpectedObjectType');
-
-               $repository->add(new \stdClass());
+               $this->repository->_set('objectType', 'ExpectedObjectType');
+               $this->repository->add(new \stdClass());
        }
 
        /**
@@ -284,17 +280,15 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @expectedException \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
         */
        public function removeChecksObjectType() {
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
-               $repository->_set('objectType', 'ExpectedObjectType');
-
-               $repository->remove(new \stdClass());
+               $this->repository->_set('objectType', 'ExpectedObjectType');
+               $this->repository->remove(new \stdClass());
        }
        /**
         * @test
         * @expectedException \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
         */
        public function updateChecksObjectType() {
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'));
+               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'), array($this->mockObjectManager));
                $repository->_set('objectType', 'ExpectedObjectType');
 
                $repository->update(new \stdClass());
@@ -354,7 +348,7 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        public function findByUidReturnsResultOfGetObjectByIdentifierCall() {
                $fakeUid = '123';
                $object = new \stdClass();
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('findByIdentifier'));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('findByIdentifier'), array($this->mockObjectManager));
                $expectedResult = $object;
                $repository->expects($this->once())->method('findByIdentifier')->will($this->returnValue($object));
                $actualResult = $repository->findByUid($fakeUid);
index cf983da..7dce4bd 100644 (file)
@@ -31,24 +31,42 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Controller;
 class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
+        */
+       protected $mockObjectManager;
+
+       /**
+        * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
+        */
+       protected $repositoryRepositoryMock;
+
+       /**
+        * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository
+        */
+       protected $extensionRepositoryMock;
+
+       public function setUp() {
+               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
+               $this->repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'), array($this->mockObjectManager));
+               $this->extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array(), array($this->mockObjectManager));
+       }
+
+       /**
         * @test
         * @return void
         */
        public function updateExtensionListFromTerCallsUpdateExtListIfExtensionListIsEmpty() {
                $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
-               $repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'));
                $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
                $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
                $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
                $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
                $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-               $repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
+               $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
                $repositoryHelperMock->expects($this->once())->method('updateExtList');
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
-               $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
-               $controllerMock->_set('extensionRepository', $extensionRepositoryMock);
-
-               $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
+               $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
+               $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
+               $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
                $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
                $controllerMock->_set('settings', array('repositoryUid' => 1));
                $controllerMock->_set('view', $viewMock);
@@ -62,19 +80,16 @@ class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
         */
        public function updateExtensionListFromTerDoesNotCallsUpdateExtListIfExtensionListIsNotEmpty() {
                $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
-               $repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'));
                $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
                $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
                $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
                $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
                $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-               $repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
+               $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
                $repositoryHelperMock->expects($this->never())->method('updateExtList');
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
-               $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
-               $controllerMock->_set('extensionRepository', $extensionRepositoryMock);
-
-               $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
+               $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
+               $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
+               $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
                $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
                $controllerMock->_set('settings', array('repositoryUid' => 1));
                $controllerMock->_set('view', $viewMock);
@@ -88,19 +103,16 @@ class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
         */
        public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
                $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
-               $repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'));
                $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
                $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
                $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
                $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
                $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-               $repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
+               $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
                $repositoryHelperMock->expects($this->once())->method('updateExtList');
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
-               $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
-               $controllerMock->_set('extensionRepository', $extensionRepositoryMock);
-
-               $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
+               $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
+               $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
+               $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
                $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
                $controllerMock->_set('settings', array('repositoryUid' => 1));
                $controllerMock->_set('view', $viewMock);
index 4b31869..f046b8d 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository;
 /***************************************************************
  * Copyright notice
  *
- * (c) 2012-2013 Chritian Kuhn, <lolli@schwarzbu.ch>
+ * (c) 2012-2013 Christian Kuhn, <lolli@schwarzbu.ch>
  * All rights reserved
  *
  * This script is part of the TYPO3 project. The TYPO3 project is
@@ -32,17 +32,32 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository;
 class RepositoryRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
+        */
+       protected $mockObjectManager;
+
+       /**
+        * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
+        */
+       protected $fixture;
+
+       public function setUp() {
+               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
+               /** @var $fixture \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
+               $this->fixture = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findAll'), array($this->mockObjectManager));
+       }
+
+       /**
         * @test
         */
        public function findOneTypo3OrgRepositoryReturnsNullIfNoRepositoryWithThisTitleExists() {
-               /** @var $fixture \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
-               $fixture = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findAll'));
-               $fixture
+
+               $this->fixture
                        ->expects($this->once())
                        ->method('findAll')
                        ->will($this->returnValue(array()));
 
-               $this->assertNull($fixture->findOneTypo3OrgRepository());
+               $this->assertNull($this->fixture->findOneTypo3OrgRepository());
        }
 
        /**
@@ -60,14 +75,12 @@ class RepositoryRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCas
                        ->method('getTitle')
                        ->will($this->returnValue('TYPO3.org Main Repository'));
 
-               /** @var $fixture \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
-               $fixture = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findAll'));
-               $fixture
+               $this->fixture
                        ->expects($this->once())
                        ->method('findAll')
                        ->will($this->returnValue(array($mockModelOne, $mockModelTwo)));
 
-               $this->assertSame($mockModelTwo, $fixture->findOneTypo3OrgRepository());
+               $this->assertSame($mockModelTwo, $this->fixture->findOneTypo3OrgRepository());
        }
 }
 
index 5131202..7bfdefa 100644 (file)
@@ -33,6 +33,22 @@ use TYPO3\CMS\Extensionmanager\Report;
 class ExtensionStatusTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
+        */
+       protected $mockObjectManager;
+
+       /**
+        * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
+        */
+       protected $mockRepositoryRepository;
+
+       public function setUp() {
+               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
+               /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
+               $this->mockRepositoryRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array(), array($this->mockObjectManager));
+       }
+
+       /**
         * @test
         */
        public function extensionStatusImplementsStatusProviderInterface() {
@@ -85,16 +101,14 @@ class ExtensionStatusTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         */
        public function getMainRepositoryStatusReturnsErrorStatusIfRepositoryIsNotFound() {
-               /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
-               $mockRepositoryRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository');
-               $mockRepositoryRepository
+               $this->mockRepositoryRepository
                        ->expects($this->once())
                        ->method('findOneTypo3OrgRepository')
                        ->will($this->returnValue(NULL));
 
                /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
                $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'));
-               $mockReport->_set('repositoryRepository', $mockRepositoryRepository);
+               $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
 
                /** @var $result \TYPO3\CMS\Reports\Status */
                $result = $mockReport->_call('getMainRepositoryStatus');
@@ -112,16 +126,14 @@ class ExtensionStatusTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        ->method('getLastUpdate')
                        ->will($this->returnValue(new \DateTime('-8 days')));
 
-               /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
-               $mockRepositoryRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository');
-               $mockRepositoryRepository
+               $this->mockRepositoryRepository
                        ->expects($this->once())
                        ->method('findOneTypo3OrgRepository')
                        ->will($this->returnValue($mockRepository));
 
                /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
                $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'));
-               $mockReport->_set('repositoryRepository', $mockRepositoryRepository);
+               $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
 
                /** @var $result \TYPO3\CMS\Reports\Status */
                $result = $mockReport->_call('getMainRepositoryStatus');
@@ -139,16 +151,14 @@ class ExtensionStatusTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        ->method('getLastUpdate')
                        ->will($this->returnValue(new \DateTime('-6 days')));
 
-               /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
-               $mockRepositoryRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository');
-               $mockRepositoryRepository
+               $this->mockRepositoryRepository
                        ->expects($this->once())
                        ->method('findOneTypo3OrgRepository')
                        ->will($this->returnValue($mockRepository));
 
                /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
                $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'));
-               $mockReport->_set('repositoryRepository', $mockRepositoryRepository);
+               $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
 
                /** @var $result \TYPO3\CMS\Reports\Status */
                $result = $mockReport->_call('getMainRepositoryStatus');
index b42a7bb..9a80f4b 100644 (file)
@@ -31,6 +31,15 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
 class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
+        */
+       protected $mockObjectManager;
+
+       public function setUp() {
+               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
+       }
+
+       /**
         * @test
         * @return void
         */
@@ -421,7 +430,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @return void
         */
        public function isExtensionDownloadableFromTerReturnsTrueIfOneVersionExists() {
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByExtensionKey'));
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByExtensionKey'), array($this->mockObjectManager));
                $extensionRepositoryMock->expects($this->once())->method('countByExtensionKey')->with('test123')->will($this->returnValue(1));
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
@@ -434,7 +443,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @return void
         */
        public function isExtensionDownloadableFromTerReturnsFalseIfNoVersionExists() {
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByExtensionKey'));
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByExtensionKey'), array($this->mockObjectManager));
                $extensionRepositoryMock->expects($this->once())->method('countByExtensionKey')->with('test123')->will($this->returnValue(0));
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
@@ -451,7 +460,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $dependencyModelMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('dummy'));
                $dependencyModelMock->expects($this->once())->method('getHighestVersion')->will($this->returnValue('10.0.0'));
                $dependencyModelMock->expects($this->once())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByVersionRangeAndExtensionKey'));
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByVersionRangeAndExtensionKey'), array($this->mockObjectManager));
                $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 10000000)->will($this->returnValue(array('1234', '5678')));
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
@@ -466,7 +475,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        public function isDownloadableVersionCompatibleReturnsFalseIfIncompatibleVersionExists() {
                $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('getIdentifier'));
                $dependencyModelMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('dummy'));
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByVersionRangeAndExtensionKey'));
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByVersionRangeAndExtensionKey'), array($this->mockObjectManager));
                $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 2000000)->will($this->returnValue(array()));
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('getLowestAndHighestIntegerVersions'));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
@@ -517,7 +526,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        'lowestIntegerVersion' => 1000000,
                        'highestIntegerVersion' => 2000000
                )));
-               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findByVersionRangeAndExtensionKeyOrderedByVersion'));
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findByVersionRangeAndExtensionKeyOrderedByVersion'), array($this->mockObjectManager));
                $extensionRepositoryMock->expects($this->once())->method('findByVersionRangeAndExtensionKeyOrderedByVersion')->with('foobar', 1000000, 2000000)->will($this->returnValue($myStorage));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
                $extension = $dependencyUtility->_call('getLatestCompatibleExtensionByIntegerVersionDependency', $dependencyModelMock);
index 0bb8425..b59b09d 100644 (file)
@@ -38,6 +38,11 @@ class ListUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        private $loadedExtensions = array();
 
        /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
+        */
+       protected $mockObjectManager;
+
+       /**
         * @return void
         */
        public function setUp() {
@@ -50,6 +55,7 @@ class ListUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        'saltedpasswords' => 'saltedpasswords',
                        'rsaauth' => 'rsaauth'
                );
+               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
        }
 
        /**
@@ -185,7 +191,7 @@ class ListUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @return void
         */
        public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) {
-               $this->fixture->extensionRepository = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findOneByExtensionKeyAndVersion'));
+               $this->fixture->extensionRepository = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findOneByExtensionKeyAndVersion'), array($this->mockObjectManager));
                $this->fixture->emConfUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\EmConfUtility');
                $this->fixture->emConfUtility->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
                $this->assertEquals($expectedResult, $this->fixture->enrichExtensionsWithEmConfAndTerInformation($extensions));