[BUGFIX] Repair broken unit tests 98/21398/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 13 Jun 2013 12:35:44 +0000 (14:35 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 13 Jun 2013 20:03:22 +0000 (22:03 +0200)
In patch 21171 some tests broke due to forgotten adjustments after
code change.
This patch brings the missing adjustment.

Releases: 6.2, 6.1
Resolves: #49100
Relates: #48571
Change-Id: I9a07e14ea050fad95bcc424ad07afc54f6aea1e1
Reviewed-on: https://review.typo3.org/21398
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php

index 6eddaef..f616076 100644 (file)
@@ -154,12 +154,16 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $identifier = '42';
                $object = new \stdClass();
 
-               $mockPersistenceManager = $this->getMock('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
-               $mockPersistenceManager->expects($this->once())->method('getObjectByIdentifier')->with($identifier, 'stdClass')->will($this->returnValue($object));
+               $expectedResult = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryResultInterface');
+               $expectedResult->expects($this->once())->method('getFirst')->will($this->returnValue($object));
 
-               $repository = $this->getAccessibleMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
-               $this->inject($repository, 'persistenceManager', $mockPersistenceManager);
-               $repository->_set('objectType', 'stdClass');
+               $mockQuery = $this->getMock('TYPO3\CMS\Extbase\Persistence\QueryInterface');
+               $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));
+
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('createQuery'));
+               $repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
 
                $this->assertSame($object, $repository->findByIdentifier($identifier));
        }
@@ -350,10 +354,10 @@ class RepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        public function findByUidReturnsResultOfGetObjectByIdentifierCall() {
                $fakeUid = '123';
                $object = new \stdClass();
-               $this->repository->_set('objectType', 'someObjectType');
-               $this->mockPersistenceManager->expects($this->once())->method('getObjectByIdentifier')->with($fakeUid, 'someObjectType')->will($this->returnValue($object));
+               $repository = $this->getMock('TYPO3\CMS\Extbase\Persistence\Repository', array('findByIdentifier'));
                $expectedResult = $object;
-               $actualResult = $this->repository->findByUid($fakeUid);
+               $repository->expects($this->once())->method('findByIdentifier')->will($this->returnValue($object));
+               $actualResult = $repository->findByUid($fakeUid);
                $this->assertSame($expectedResult, $actualResult);
        }