importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); $this->setUpFrontendRootPage( 1, [ __DIR__ . '/../Fixtures/TypoScript/setup.typoscript' ] ); // This part is needed for TYPO3 10 compatibility /** @var EnvironmentService|ObjectProphecy $environmentServiceProphecy */ $environmentServiceProphecy = $this->prophesize(EnvironmentService::class); $environmentServiceProphecy ->isEnvironmentInFrontendMode() ->willReturn(true); $environmentServiceProphecy ->isEnvironmentInBackendMode() ->willReturn(false); GeneralUtility::setSingletonInstance(EnvironmentService::class, $environmentServiceProphecy->reveal()); $serverRequest = new ServerRequest(); $applicationType = SystemEnvironmentBuilder::REQUESTTYPE_FE; $serverRequest = $serverRequest->withAttribute('applicationType', $applicationType); /** @var TypoScriptFrontendController|ObjectProphecy $typoScriptFrontendControllerProphecy */ $typoScriptFrontendControllerProphecy = $this->prophesize(TypoScriptFrontendController::class); /** @var FrontendUserAuthentication|ObjectProphecy $frontendUserAuthenticationProphecy */ $frontendUserAuthenticationProphecy = $this->prophesize(FrontendUserAuthentication::class); $GLOBALS['TYPO3_REQUEST'] = $serverRequest; $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); $GLOBALS['TSFE'] = $typoScriptFrontendControllerProphecy->reveal(); $GLOBALS['TSFE']->fe_user = $frontendUserAuthenticationProphecy->reveal(); } protected function tearDown(): void { unset( $this->subject ); parent::tearDown(); } /** * @test */ public function listActionWillReturnNoNews(): void { $extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class); $content = $extbaseBootstrap->run( '', [ 'extensionName' => 'News', 'pluginName' => 'Pi1' ] ); $this->assertStringContainsString( 'No news available.', $content ); } /** * @test */ public function listActionWillShowNewsOfStoragePage1(): void { $date = new \DateTime('now'); $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable('tx_news_domain_model_news'); $connection->insert( 'tx_news_domain_model_news', [ 'uid' => 1, 'pid' => 1, 'title' => 'My first news', 'datetime' => (int)$date->format('U') ] ); $extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class); $content = $extbaseBootstrap->run( '', [ 'extensionName' => 'News', 'pluginName' => 'Pi1' ] ); $this->assertStringContainsString( 'My first news', $content ); $this->assertStringContainsString( '