Esempio n. 1
0
 /**
  * @test
  */
 public function executeReturnsRawObjectDataIfReturnRawQueryResultIsSet()
 {
     $this->persistenceManager->expects($this->once())->method('getObjectDataByQuery')->with($this->query)->will($this->returnValue('rawQueryResult'));
     $expectedResult = 'rawQueryResult';
     $actualResult = $this->query->execute(true);
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * Sets up this test case
  *
  * @return void
  */
 protected function setUp()
 {
     $this->query = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Query::class, array('dummy'), array('someType'));
     $this->querySettings = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);
     $this->query->_set('querySettings', $this->querySettings);
     $this->persistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
     $this->backend = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface::class);
     $this->backend->expects($this->any())->method('getQomFactory')->will($this->returnValue(null));
     $this->persistenceManager->expects($this->any())->method('getBackend')->will($this->returnValue($this->backend));
     $this->query->_set('persistenceManager', $this->persistenceManager);
     $this->dataMapper = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class);
     $this->query->_set('dataMapper', $this->dataMapper);
     $this->controller = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller\PaginateController::class, array('dummy'), array(), '', false);
     $this->controller->_set('view', $this->getMock(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class));
 }
 /**
  * @test
  * @expectedException \TYPO3\CMS\Extbase\Property\Exception\DuplicateObjectException
  */
 public function convertFromShouldThrowExceptionIfMoreThanOneObjectWasFound()
 {
     $this->setupMockQuery(2, $this->never());
     $source = array('__identity' => 666);
     $this->mockPersistenceManager->expects($this->any())->method('getObjectByIdentifier')->with(666)->will($this->throwException(new \TYPO3\CMS\Extbase\Property\Exception\DuplicateObjectException()));
     $this->converter->convertFrom($source, 'SomeType');
 }
Esempio n. 4
0
 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->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->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->repository->_set('persistenceManager', $this->mockPersistenceManager);
 }
Esempio n. 5
0
 /**
  * @test
  */
 public function initializeExecutesQueryWithArrayFetchMode()
 {
     /** @var \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
     $queryResult = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\QueryResult::class, array('dummy'), array($this->mockQuery));
     $queryResult->_set('persistenceManager', $this->mockPersistenceManager);
     $queryResult->_set('dataMapper', $this->mockDataMapper);
     $this->mockPersistenceManager->expects($this->once())->method('getObjectDataByQuery')->with($this->mockQuery)->will($this->returnValue(array('FAKERESULT')));
     $queryResult->_call('initialize');
 }
Esempio n. 6
0
 protected function setUp()
 {
     $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->mockSession = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class);
     $this->mockConfigurationManager = $this->getMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
     $this->mockBackend = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Backend::class, array('dummy'), array($this->mockConfigurationManager));
     $this->inject($this->mockBackend, 'session', $this->mockSession);
     $this->mockPersistenceManager = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class, array('createQueryForType'));
     $this->inject($this->mockBackend, 'persistenceManager', $this->mockPersistenceManager);
     $this->inject($this->mockPersistenceManager, 'persistenceSession', $this->mockSession);
     $this->inject($this->mockPersistenceManager, 'backend', $this->mockBackend);
     $this->mockPersistenceManager->expects($this->any())->method('createQueryForType')->will($this->returnValue($this->mockQuery));
     $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);
 }