17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
47 protected function setUp()
49 $this->query = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Persistence\Generic\Query::class, [
'getSelectorName'], [
'someType']);
50 $this->querySettings = $this->createMock(\
TYPO3\CMS\
Extbase\Persistence\Generic\QuerySettingsInterface::class);
51 $this->query->_set(
'querySettings', $this->querySettings);
52 $this->persistenceManager = $this->createMock(\
TYPO3\CMS\
Extbase\Persistence\PersistenceManagerInterface::class);
53 $this->query->_set(
'persistenceManager', $this->persistenceManager);
54 $this->dataMapFactory = $this->createMock(\
TYPO3\CMS\
Extbase\Persistence\Generic\Mapper\DataMapFactory::class);
55 $this->query->_set(
'dataMapFactory', $this->dataMapFactory);
64 $objectManager = $this->createMock(\
TYPO3\CMS\
Extbase\Object\ObjectManager::class);
65 $this->query->_set(
'objectManager', $objectManager);
66 $queryResult = $this->createMock(\
TYPO3\CMS\
Extbase\Persistence\Generic\QueryResult::class);
67 $objectManager->expects($this->once())->method(
'get')->with(\
TYPO3\CMS\
Extbase\Persistence\QueryResultInterface::class, $this->query)->will($this->returnValue($queryResult));
68 $actualResult = $this->query->execute();
69 $this->assertSame($queryResult, $actualResult);
77 $this->persistenceManager->expects($this->once())->method(
'getObjectDataByQuery')->with($this->query)->will($this->returnValue(
'rawQueryResult'));
78 $expectedResult =
'rawQueryResult';
79 $actualResult = $this->query->execute(
true);
80 $this->assertEquals($expectedResult, $actualResult);
88 $this->expectException(\InvalidArgumentException::class);
89 $this->expectExceptionCode(1245071870);
90 $this->query->setLimit(1.5);
98 $this->expectException(\InvalidArgumentException::class);
99 $this->expectExceptionCode(1245071870);
100 $this->query->setLimit(0);
108 $this->expectException(\InvalidArgumentException::class);
109 $this->expectExceptionCode(1245071872);
110 $this->query->setOffset(1.5);
118 $this->expectException(\InvalidArgumentException::class);
119 $this->expectExceptionCode(1245071872);
120 $this->query->setOffset(-1);
129 'Polish alphabet' => [
'name',
'ĄĆĘŁŃÓŚŹŻABCDEFGHIJKLMNOPRSTUWYZQXVąćęłńóśźżabcdefghijklmnoprstuwyzqxv',
'ąćęłńóśźżabcdefghijklmnoprstuwyzqxvąćęłńóśźżabcdefghijklmnoprstuwyzqxv'],
130 'German alphabet' => [
'name',
'ßÜÖÄüöä',
'ßüöäüöä'],
131 'Greek alphabet' => [
'name',
'Τάχιστη αλώπηξ βαφής ψημένη γη',
'τάχιστη αλώπηξ βαφής ψημένη γη'],
132 'Russian alphabet' => [
'name',
'АВСТРАЛИЯавстралия',
'австралияавстралия']
148 $objectManager = $this->createMock(\
TYPO3\CMS\
Extbase\Object\ObjectManager::class);
150 $dynamicOperand = $this->createMock(\
TYPO3\CMS\
Extbase\Persistence\Generic\Qom\PropertyValueInterface::class);
151 $objectManager->expects($this->any())->method(
'get')->will($this->returnValue($dynamicOperand));
153 $qomFactory = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Persistence\Generic\Qom\QueryObjectModelFactory::class, [
'comparison']);
154 $qomFactory->_set(
'objectManager', $objectManager);
155 $qomFactory->expects($this->once())->method(
'comparison')->with($this->anything(), $this->anything(), $expectedOperand);
156 $this->query->expects($this->any())->method(
'getSelectorName')->will($this->returnValue(
'someSelector'));
157 $this->query->_set(
'qomFactory', $qomFactory);
158 $this->query->equals($propertyName, $operand,
false);