Skip to content
Snippets Groups Projects
Commit 90734e17 authored by Anja Leichsenring's avatar Anja Leichsenring
Browse files

[BUGFIX] Repair broken unit tests

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/21389
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Tested-by: Philipp Gampe
Reviewed-by: Philipp Gampe
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
parent c4c4b5ee
No related merge requests found
......@@ -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);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment