17 use Prophecy\Argument;
37 $this->importDataSet(__DIR__ .
'/../Fixtures/pages.xml');
46 $rows = $subject->getMenu(1,
'uid, title');
47 $this->assertArrayHasKey(2, $rows);
48 $this->assertArrayHasKey(3, $rows);
49 $this->assertArrayHasKey(4, $rows);
50 $this->assertCount(3, $rows);
59 $rows = $subject->getMenu(2,
'uid, title');
60 $this->assertArrayHasKey(5, $rows);
61 $this->assertArrayHasKey(7, $rows);
62 $this->assertCount(2, $rows);
71 $rows = $subject->getMenu([2, 3],
'uid, title');
72 $this->assertArrayHasKey(5, $rows);
73 $this->assertArrayHasKey(7, $rows);
74 $this->assertArrayHasKey(8, $rows);
75 $this->assertArrayHasKey(9, $rows);
76 $this->assertCount(4, $rows);
88 $rows = $subject->getMenu([2, 3],
'uid, title');
89 $this->assertEquals(
'Attrappe 1-2-5', $rows[5][
'title']);
90 $this->assertEquals(
'Dummy 1-2-7', $rows[7][
'title']);
91 $this->assertEquals(
'Dummy 1-3-8', $rows[8][
'title']);
92 $this->assertEquals(
'Attrappe 1-3-9', $rows[9][
'title']);
93 $this->assertCount(4, $rows);
102 $row = $subject->getPageOverlay(1, 1);
104 $this->assertEquals(
'Wurzel 1', $row[
'title']);
105 $this->assertEquals(
'901', $row[
'_PAGES_OVERLAY_UID']);
106 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
115 $row = $subject->getPageOverlay(4, 1);
116 $this->assertInternalType(
'array', $row);
117 $this->assertCount(0, $row);
126 $orig = $subject->getPage(1);
127 $row = $subject->getPageOverlay($orig, 1);
129 $this->assertEquals(1, $row[
'uid']);
130 $this->assertEquals(
'Wurzel 1', $row[
'title']);
131 $this->assertEquals(
'901', $row[
'_PAGES_OVERLAY_UID']);
132 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
141 $orig = $subject->getPage(4);
142 $row = $subject->getPageOverlay($orig, 1);
143 $this->assertInternalType(
'array', $row);
144 $this->assertEquals(4, $row[
'uid']);
145 $this->assertEquals(
'Dummy 1-4', $row[
'title']);
156 $rows = $subject->getPagesOverlay([1]);
157 $this->assertInternalType(
'array', $rows);
158 $this->assertCount(1, $rows);
159 $this->assertArrayHasKey(0, $rows);
163 $this->assertEquals(
'Wurzel 1', $row[
'title']);
164 $this->assertEquals(
'901', $row[
'_PAGES_OVERLAY_UID']);
165 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
176 $rows = $subject->getPagesOverlay([1, 5]);
177 $this->assertInternalType(
'array', $rows);
178 $this->assertCount(2, $rows);
179 $this->assertArrayHasKey(0, $rows);
180 $this->assertArrayHasKey(1, $rows);
184 $this->assertEquals(
'Wurzel 1', $row[
'title']);
185 $this->assertEquals(
'901', $row[
'_PAGES_OVERLAY_UID']);
186 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
190 $this->assertEquals(
'Attrappe 1-2-5', $row[
'title']);
191 $this->assertEquals(
'904', $row[
'_PAGES_OVERLAY_UID']);
192 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
203 $rows = $subject->getPagesOverlay([1, 4, 5, 8]);
204 $this->assertInternalType(
'array', $rows);
205 $this->assertCount(2, $rows);
206 $this->assertArrayHasKey(0, $rows);
207 $this->assertArrayHasKey(2, $rows);
211 $this->assertEquals(
'Wurzel 1', $row[
'title']);
215 $this->assertEquals(
'Attrappe 1-2-5', $row[
'title']);
224 $origRow = $subject->getPage(1);
229 $rows = $subject->getPagesOverlay([$origRow]);
230 $this->assertInternalType(
'array', $rows);
231 $this->assertCount(1, $rows);
232 $this->assertArrayHasKey(0, $rows);
236 $this->assertEquals(
'Wurzel 1', $row[
'title']);
237 $this->assertEquals(
'901', $row[
'_PAGES_OVERLAY_UID']);
238 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
247 $origRow = $subject->getPage(6,
true);
252 $rows = $subject->getPagesOverlay([$origRow]);
253 self::assertIsArray($rows);
254 self::assertCount(1, $rows);
255 self::assertArrayHasKey(0, $rows);
259 self::assertEquals(
'Attrappe 1-2-6', $row[
'title']);
260 self::assertEquals(
'905', $row[
'_PAGES_OVERLAY_UID']);
261 self::assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
270 $orig1 = $subject->getPage(1);
271 $orig2 = $subject->getPage(5);
276 $rows = $subject->getPagesOverlay([1 => $orig1, 5 => $orig2]);
277 $this->assertInternalType(
'array', $rows);
278 $this->assertCount(2, $rows);
279 $this->assertArrayHasKey(1, $rows);
280 $this->assertArrayHasKey(5, $rows);
284 $this->assertEquals(
'Wurzel 1', $row[
'title']);
285 $this->assertEquals(
'901', $row[
'_PAGES_OVERLAY_UID']);
286 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
290 $this->assertEquals(
'Attrappe 1-2-5', $row[
'title']);
291 $this->assertEquals(
'904', $row[
'_PAGES_OVERLAY_UID']);
292 $this->assertEquals(1, $row[
'_PAGES_OVERLAY_LANGUAGE']);
301 $orig1 = $subject->getPage(1);
302 $orig2 = $subject->getPage(7);
303 $orig3 = $subject->getPage(9);
308 $rows = $subject->getPagesOverlay([$orig1, $orig2, $orig3]);
309 $this->assertInternalType(
'array', $rows);
310 $this->assertCount(3, $rows);
311 $this->assertArrayHasKey(0, $rows);
312 $this->assertArrayHasKey(1, $rows);
313 $this->assertArrayHasKey(2, $rows);
317 $this->assertEquals(
'Wurzel 1', $row[
'title']);
321 $this->assertEquals(
'Dummy 1-2-7', $row[
'title']);
325 $this->assertEquals(
'Attrappe 1-3-9', $row[
'title']);
336 $getPageHookProphet = $this->prophesize(\stdClass::class);
337 $getPageHookProphet->willImplement(PageRepositoryGetPageHookInterface::class);
338 $getPageHookProphet->getPage_preProcess(42,
false, Argument::type(PageRepository::class))->shouldBeCalled();
339 $getPageHookMock = $getPageHookProphet->reveal();
340 $className = get_class($getPageHookMock);
343 GeneralUtility::addInstance($className, $getPageHookMock);
344 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_page.php'][
'getPage'][] = $className;
346 $subject->getPage(42,
false);
359 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(
'pages');
361 $expectedSQL = sprintf(
362 ' AND (%s = 0) AND ((%s = 0) OR (%s = 2)) AND (%s < 200)',
363 $connection->quoteIdentifier(
'pages.deleted'),
364 $connection->quoteIdentifier(
'pages.t3ver_wsid'),
365 $connection->quoteIdentifier(
'pages.t3ver_wsid'),
366 $connection->quoteIdentifier(
'pages.doktype')
369 $this->assertSame($expectedSQL, $subject->where_hid_del);
381 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(
'pages');
382 $expectedSQL = sprintf(
383 ' AND ((%s = 0) AND (%s <= 0) AND (%s = 0) AND (%s <= 1451779200) AND ((%s = 0) OR (%s > 1451779200))) AND (%s < 200)',
384 $connection->quoteIdentifier(
'pages.deleted'),
385 $connection->quoteIdentifier(
'pages.t3ver_state'),
386 $connection->quoteIdentifier(
'pages.hidden'),
387 $connection->quoteIdentifier(
'pages.starttime'),
388 $connection->quoteIdentifier(
'pages.endtime'),
389 $connection->quoteIdentifier(
'pages.endtime'),
390 $connection->quoteIdentifier(
'pages.doktype')
393 $this->assertSame($expectedSQL, $subject->where_hid_del);
412 $pageRec = $subject->getPage(11);
414 $this->assertEquals(11, $pageRec[
'uid']);
415 $this->assertEquals(11, $pageRec[
't3ver_oid']);
416 $this->assertEquals(987654321, $pageRec[
't3ver_wsid']);
417 $this->assertEquals(-1, $pageRec[
't3ver_state']);
418 $this->assertSame(
'First draft version', $pageRec[
't3ver_label']);
434 $pageRec = $subject->getWorkspaceVersionOfRecord($wsid,
'pages', 11);
436 $this->assertEquals(12, $pageRec[
'uid']);
437 $this->assertEquals(11, $pageRec[
't3ver_oid']);
438 $this->assertEquals(987654321, $pageRec[
't3ver_wsid']);
439 $this->assertEquals(-1, $pageRec[
't3ver_state']);
440 $this->assertSame(
'First draft version', $pageRec[
't3ver_label']);
452 $table = $this->getUniqueId(
'aTable');
455 'versioningWS' => true
461 $conditions = $subject->enableFields($table);
462 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
466 $this->stringContains(
' AND (' . $connection->quoteIdentifier($table .
'.t3ver_state') .
' <= 0)'),
467 'Versioning placeholders'
471 $this->stringContains(
' AND (' . $connection->quoteIdentifier($table .
'.pid') .
' <> -1)'),
472 'Records from page -1'
481 $table = $this->getUniqueId(
'aTable');
484 'versioningWS' => true
492 $conditions = $subject->enableFields($table);
493 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
497 $this->logicalNot($this->stringContains(
' AND (' . $connection->quoteIdentifier($table .
'.t3ver_state') .
' <= 0)')),
498 'No versioning placeholders'
502 $this->stringContains(
' AND (' . $connection->quoteIdentifier($table .
'.pid') .
' <> -1)'),
503 'Records from page -1'
512 $table = $this->getUniqueId(
'aTable');
515 'versioningWS' => true
523 $conditions = $subject->enableFields($table);
524 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
528 $this->stringContains(
' AND ((' . $connection->quoteIdentifier($table .
'.t3ver_wsid') .
' = 0) OR (' . $connection->quoteIdentifier($table .
'.t3ver_wsid') .
' = 2))'),
529 'No versioning placeholders'
538 $table = $this->getUniqueId(
'aTable');
541 'versioningWS' => true
549 $conditions = $subject->enableFields($table, -1, [],
true);
550 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
554 $this->logicalNot($this->stringContains(
' AND (' . $connection->quoteIdentifier($table .
'.t3ver_state') .
' <= 0)')),
555 'No versioning placeholders'
559 $this->logicalNot($this->stringContains(
' AND (' . $connection->quoteIdentifier($table .
'.pid') .
' <> -1)')),
560 'No records from page -1'
566 $this->assertInternalType(
'array', $row);
568 $this->assertArrayHasKey(
'_PAGES_OVERLAY', $row);
569 $this->assertArrayHasKey(
'_PAGES_OVERLAY_UID', $row);
570 $this->assertArrayHasKey(
'_PAGES_OVERLAY_LANGUAGE', $row);
572 $this->assertTrue($row[
'_PAGES_OVERLAY']);
577 $this->assertInternalType(
'array', $row);
579 $this->assertFalse(isset($row[
'_PAGES_OVERLAY']));
580 $this->assertFalse(isset($row[
'_PAGES_OVERLAY_UID']));
581 $this->assertFalse(isset($row[
'_PAGES_OVERLAY_LANGUAGE']));