[TASK] Use name-resolution instead of strings where possible: 3
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Persistence / RepositoryTest.php
index e36a799..fac90a5 100644 (file)
@@ -70,18 +70,18 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        protected $mockQuerySettings;
 
        public function setUp() {
-               $this->mockIdentityMap = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\IdentityMap');
-               $this->mockQueryFactory = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QueryFactory');
-               $this->mockQuery = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\QueryInterface');
-               $this->mockQuerySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $this->mockIdentityMap = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap::class);
+               $this->mockQueryFactory = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory::class);
+               $this->mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
+               $this->mockQuerySettings = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);
                $this->mockQuery->expects($this->any())->method('getQuerySettings')->will($this->returnValue($this->mockQuerySettings));
                $this->mockQueryFactory->expects($this->any())->method('create')->will($this->returnValue($this->mockQuery));
-               $this->mockBackend = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\BackendInterface');
-               $this->mockSession = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session');
-               $this->mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
+               $this->mockBackend = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface::class);
+               $this->mockSession = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class);
+               $this->mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
                $this->mockPersistenceManager->expects($this->any())->method('createQueryForType')->will($this->returnValue($this->mockQuery));
-               $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $this->repository = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Repository', array('dummy'), array($this->mockObjectManager));
+               $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
+               $this->repository = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('dummy'), array($this->mockObjectManager));
                $this->repository->_set('persistenceManager', $this->mockPersistenceManager);
        }
 
@@ -96,7 +96,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function createQueryCallsPersistenceManagerWithExpectedClassName() {
-               $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
+               $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
                $mockPersistenceManager->expects($this->once())->method('createQueryForType')->with('ExpectedType');
 
                $this->repository->_set('objectType', 'ExpectedType');
@@ -110,9 +110,9 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function createQuerySetsDefaultOrderingIfDefined() {
                $orderings = array('foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING);
-               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
+               $mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
                $mockQuery->expects($this->once())->method('setOrderings')->with($orderings);
-               $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
+               $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
                $mockPersistenceManager->expects($this->exactly(2))->method('createQueryForType')->with('ExpectedType')->will($this->returnValue($mockQuery));
 
                $this->repository->_set('objectType', 'ExpectedType');
@@ -128,12 +128,12 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function findAllCreatesQueryAndReturnsResultOfExecuteCall() {
-               $expectedResult = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryResultInterface');
+               $expectedResult = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface::class);
 
-               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
+               $mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
                $mockQuery->expects($this->once())->method('execute')->with()->will($this->returnValue($expectedResult));
 
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
+               $repository = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($expectedResult, $repository->findAll());
@@ -146,18 +146,18 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $identifier = '42';
                $object = new \stdClass();
 
-               $expectedResult = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryResultInterface');
+               $expectedResult = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface::class);
                $expectedResult->expects($this->once())->method('getFirst')->will($this->returnValue($object));
 
-               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
+               $mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
                $mockQuery->expects($this->any())->method('getQuerySettings')->will($this->returnValue($this->mockQuerySettings));
                $mockQuery->expects($this->once())->method('matching')->will($this->returnValue($mockQuery));
                $mockQuery->expects($this->once())->method('execute')->will($this->returnValue($expectedResult));
 
-               $session = $this->getMock('TYPO3\CMS\Extbase\Persistence\Generic\Session');
+               $session = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class);
                $session->expects($this->once())->method('hasIdentifier')->will($this->returnValue(FALSE));
 
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
+               $repository = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, 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));
@@ -168,7 +168,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function addDelegatesToPersistenceManager() {
                $object = new \stdClass();
-               $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
+               $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
                $mockPersistenceManager->expects($this->once())->method('add')->with($object);
                $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
                $this->repository->_set('objectType', get_class($object));
@@ -180,7 +180,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function removeDelegatesToPersistenceManager() {
                $object = new \stdClass();
-               $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
+               $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
                $mockPersistenceManager->expects($this->once())->method('remove')->with($object);
                $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
                $this->repository->_set('objectType', get_class($object));
@@ -192,7 +192,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function updateDelegatesToPersistenceManager() {
                $object = new \stdClass();
-               $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
+               $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
                $mockPersistenceManager->expects($this->once())->method('update')->with($object);
                $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager);
                $this->repository->_set('objectType', get_class($object));
@@ -203,13 +203,13 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function magicCallMethodAcceptsFindBySomethingCallsAndExecutesAQueryWithThatCriteria() {
-               $mockQueryResult = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryResultInterface');
-               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
+               $mockQueryResult = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface::class);
+               $mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
                $mockQuery->expects($this->once())->method('equals')->with('foo', 'bar')->will($this->returnValue('matchCriteria'));
                $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'), array($this->mockObjectManager));
+               $repository = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($mockQueryResult, $repository->findByFoo('bar'));
@@ -220,15 +220,15 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function magicCallMethodAcceptsFindOneBySomethingCallsAndExecutesAQueryWithThatCriteria() {
                $object = new \stdClass();
-               $mockQueryResult = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryResultInterface');
+               $mockQueryResult = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface::class);
                $mockQueryResult->expects($this->once())->method('getFirst')->will($this->returnValue($object));
-               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
+               $mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
                $mockQuery->expects($this->once())->method('equals')->with('foo', 'bar')->will($this->returnValue('matchCriteria'));
                $mockQuery->expects($this->once())->method('matching')->with('matchCriteria')->will($this->returnValue($mockQuery));
                $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'), array($this->mockObjectManager));
+               $repository = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($object, $repository->findOneByFoo('bar'));
@@ -238,14 +238,14 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function magicCallMethodAcceptsCountBySomethingCallsAndExecutesAQueryWithThatCriteria() {
-               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
-               $mockQueryResult = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryResultInterface');
+               $mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
+               $mockQueryResult = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface::class);
                $mockQuery->expects($this->once())->method('equals')->with('foo', 'bar')->will($this->returnValue('matchCriteria'));
                $mockQuery->expects($this->once())->method('matching')->with('matchCriteria')->will($this->returnValue($mockQuery));
                $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'), array($this->mockObjectManager));
+               $repository = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('createQuery'), array($this->mockObjectManager));
                $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame(2, $repository->countByFoo('bar'));
@@ -256,7 +256,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @expectedException \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException
         */
        public function magicCallMethodTriggersAnErrorIfUnknownMethodsAreCalled() {
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'), array($this->mockObjectManager));
+               $repository = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('createQuery'), array($this->mockObjectManager));
                $repository->__call('foo', array());
        }
 
@@ -282,7 +282,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @expectedException \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
         */
        public function updateChecksObjectType() {
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('dummy'), array($this->mockObjectManager));
+               $repository = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('dummy'), array($this->mockObjectManager));
                $repository->_set('objectType', 'ExpectedObjectType');
 
                $repository->update(new \stdClass());
@@ -328,7 +328,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function createQueryReturnsQueryWithUnmodifiedDefaultQuerySettings() {
                $this->mockQuery = new \TYPO3\CMS\Extbase\Persistence\Generic\Query('foo');
-               $mockDefaultQuerySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $mockDefaultQuerySettings = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);
                $this->repository->setDefaultQuerySettings($mockDefaultQuerySettings);
                $query = $this->repository->createQuery();
                $instanceQuerySettings = $query->getQuerySettings();
@@ -342,7 +342,7 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function findByUidReturnsResultOfGetObjectByIdentifierCall() {
                $fakeUid = '123';
                $object = new \stdClass();
-               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('findByIdentifier'), array($this->mockObjectManager));
+               $repository = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, array('findByIdentifier'), array($this->mockObjectManager));
                $expectedResult = $object;
                $repository->expects($this->once())->method('findByIdentifier')->will($this->returnValue($object));
                $actualResult = $repository->findByUid($fakeUid);