getAccessibleMock(BackendConfigurationManager::class, ['getTypoScriptSetup']); $mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock(); $backendConfigurationManager->_set('typoScriptService', $mockTypoScriptService); (new ConnectionPool())->getConnectionForTable('sys_template')->insert( 'sys_template', [ 'pid' => 123, 'deleted' => 0, 'hidden' => 0, 'root' => 1 ] ); $actualResult = $backendConfigurationManager->_call('getCurrentPageId'); $this->assertEquals(123, $actualResult); } /** * Warning: white box test * * @test */ public function getCurrentPageIdReturnsUidFromFirstRootPageIfIdIsNotSet() { $backendConfigurationManager = $this->getAccessibleMock(BackendConfigurationManager::class, ['getTypoScriptSetup']); $mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock(); $backendConfigurationManager->_set('typoScriptService', $mockTypoScriptService); (new ConnectionPool())->getConnectionForTable('pages')->insert( 'pages', [ 'deleted' => 0, 'hidden' => 0, 'is_siteroot' => 1 ] ); $actualResult = $backendConfigurationManager->_call('getCurrentPageId'); $this->assertEquals(1, $actualResult); } /** * Warning: white box test * * @test */ public function getCurrentPageIdReturnsDefaultStoragePidIfIdIsNotSetNoRootTemplateAndRootPageWasFound() { $backendConfigurationManager = $this->getAccessibleMock(BackendConfigurationManager::class, ['getTypoScriptSetup']); $mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock(); $backendConfigurationManager->_set('typoScriptService', $mockTypoScriptService); $expectedResult = AbstractConfigurationManager::DEFAULT_BACKEND_STORAGE_PID; $actualResult = $backendConfigurationManager->_call('getCurrentPageId'); $this->assertEquals($expectedResult, $actualResult); } }