2 declare(strict_types = 1);
7 use Psr\Http\Message\ServerRequestInterface;
14 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 (new \DateTime(
'2018-01-01 12:00:15 UTC'))->getTimestamp(),
23 (int)(
new \DateTime(
'2018-01-01 12:00:15 UTC'))->getTimestamp(),
24 (int)(
new \DateTime(
'2018-01-01 12:00:00 UTC'))->getTimestamp(),
27 (string)(
new \DateTime(
'1970-01-01 00:00:15 UTC'))->getTimestamp(),
28 (int)(
new \DateTime(
'1970-01-01 00:00:60 UTC'))->getTimestamp(),
29 (int)(
new \DateTime(
'1970-01-01 00:00:60 UTC'))->getTimestamp(),
43 $this->resetSingletonInstances =
true;
44 $request = $this->prophesize(ServerRequestInterface::class);
45 $tsfe = $this->prophesize(TypoScriptFrontendController::class);
47 $configurationService = $this->prophesize(ConfigurationService::class);
48 $configurationService->getMainConfiguration()->willReturn([]);
49 $configurationService->getConfigurationOption(
'preview',
'simulateDate')->willReturn($dateToSimulate);
50 $configurationService->getConfigurationOption(
'preview', Argument::any())->willReturn(
'');
52 GeneralUtility::setSingletonInstance(ConfigurationService::class, $configurationService->reveal());
55 $previewModule->initializeModule($request->reveal());
57 self::assertSame(
$GLOBALS[
'SIM_EXEC_TIME'], $expectedExecTime,
'EXEC_TIME');
58 self::assertSame(
$GLOBALS[
'SIM_ACCESS_TIME'], $expectedAccessTime,
'ACCESS_TIME');
66 $this->resetSingletonInstances =
true;
67 $request = $this->prophesize(ServerRequestInterface::class);
68 $tsfe = $this->prophesize(TypoScriptFrontendController::class);
69 $feUser = $this->prophesize(FrontendUserAuthentication::class);
70 $tsfe->fe_user = $feUser->reveal();
72 $configurationService = $this->prophesize(ConfigurationService::class);
73 $configurationService->getMainConfiguration()->willReturn([]);
74 $configurationService->getConfigurationOption(
'preview',
'showHiddenPages')->willReturn(
'0');
75 $configurationService->getConfigurationOption(
'preview',
'simulateDate')->willReturn(
'0');
76 $configurationService->getConfigurationOption(
'preview',
'showHiddenRecords')->willReturn(
'0');
77 $configurationService->getConfigurationOption(
'preview',
'showFluidDebug')->willReturn(
'0');
78 $configurationService->getConfigurationOption(
'preview',
'simulateUserGroup')->willReturn(
'1');
79 $context = $this->prophesize(Context::class);
80 GeneralUtility::setSingletonInstance(Context::class, $context->reveal());
82 GeneralUtility::setSingletonInstance(ConfigurationService::class, $configurationService->reveal());
85 $previewModule->initializeModule($request->reveal());
87 $context->setAspect(
'frontend.user', Argument::any())->shouldHaveBeenCalled();