2 declare(strict_types = 1);
28 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
29 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
45 protected function setUp():
void
47 $cacheManagerProphecy = $this->prophesize(CacheManager::class);
48 GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
49 $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
50 $cacheManagerProphecy->getCache(
'cache_rootline')->willReturn($cacheFrontendProphecy->reveal());
52 $this->subject = $this->getAccessibleMock(
53 RootlineUtility::class,
54 [
'enrichWithRelationFields',
'resolvePageId'],
58 $this->subject->expects(static::any())->method(
'resolvePageId')->willReturnArgument(0);
67 GeneralUtility::purgeInstances();
79 protected function assertIsSubset(array $subsetCandidate, array $superset):
void
81 $this->assertSame($subsetCandidate, array_intersect_assoc($subsetCandidate, $superset));
89 $this->subject->__construct(1,
'',
new Context());
90 $this->assertFalse($this->subject->isMountedPage());
98 $this->subject->__construct(1,
'1-99',
new Context());
99 $this->assertTrue($this->subject->isMountedPage());
107 $this->subject->__construct(1,
'99-99',
new Context());
108 $this->assertFalse($this->subject->isMountedPage());
116 $this->expectException(\RuntimeException::class);
117 $this->expectExceptionCode(1343464100);
119 $this->subject->__construct(1,
'1-99',
new Context());
120 $this->subject->_call(
121 'processMountedPage',
132 $this->subject->__construct(1,
'1-99',
new Context());
133 $this->assertNotEmpty($this->subject->_call(
134 'processMountedPage',
145 $this->subject->__construct(1,
'1-99',
new Context());
146 $result = $this->subject->_call(
147 'processMountedPage',
151 $this->assertTrue(isset($result[
'_MOUNTED_FROM']));
152 $this->assertSame(1, $result[
'_MOUNTED_FROM']);
160 $this->subject->__construct(1,
'1-99',
new Context());
161 $result = $this->subject->_call(
162 'processMountedPage',
166 $this->assertTrue(isset($result[
'_MP_PARAM']));
167 $this->assertSame(
'1-99', $result[
'_MP_PARAM']);
175 $this->subject->__construct(1,
'1-99',
new Context());
176 $result = $this->subject->_call(
177 'processMountedPage',
181 $this->assertTrue(isset($result[
'_MOUNT_OL']));
182 $this->assertSame(
true, $result[
'_MOUNT_OL']);
190 $this->subject->__construct(1,
'1-99',
new Context());
191 $result = $this->subject->_call(
'processMountedPage', [
'uid' => 1], [
197 'title' =>
'TestCase'
199 $this->assertTrue(isset($result[
'_MOUNT_PAGE']));
200 $this->assertSame([
'uid' => 99,
'pid' => 5,
'title' =>
'TestCase'], $result[
'_MOUNT_PAGE']);
208 $mountPointPageData = [
214 $this->subject->__construct(1,
'1-99',
new Context());
215 $result = $this->subject->_call(
'processMountedPage', [
'uid' => 1], $mountPointPageData);
224 $this->assertFalse($this->subject->_call(
'columnHasRelationToResolve', [
234 $this->assertTrue($this->subject->_call(
'columnHasRelationToResolve', [
247 $this->assertFalse($this->subject->_call(
'columnHasRelationToResolve', [
259 $this->assertTrue($this->subject->_call(
'columnHasRelationToResolve', [
262 'foreign_field' =>
'xyz'
272 $this->assertTrue($this->subject->_call(
'columnHasRelationToResolve', [
285 $this->assertFalse($this->subject->_call(
'columnHasRelationToResolve', [
297 $this->assertTrue($this->subject->_call(
'columnHasRelationToResolve', [
310 $this->subject->expects(static::any())->method(
'resolvePageId')->willReturn(42);
315 $this->subject->__construct(42,
'47-11', $context);
316 $this->assertSame(
'42_47-11_8_15', $this->subject->getCacheIdentifier());
317 $this->subject->__construct(42,
'47-11', $context);
318 $this->assertSame(
'42_47-11_8_15', $this->subject->getCacheIdentifier());
321 $this->subject->__construct(42,
'47-11', $context);
322 $this->assertSame(
'42_47-11_8_0', $this->subject->getCacheIdentifier());
331 $this->subject->expects(static::any())->method(
'resolvePageId')->willReturn(42);
334 $cacheFrontendMock = $this->getMockForAbstractClass(
335 AbstractFrontend::class,
344 $this->subject->__construct(42,
'47-11,48-12', $context);
345 $this->assertTrue($cacheFrontendMock->isValidEntryIdentifier($this->subject->getCacheIdentifier()));