‪TYPO3CMS  9.5
CacheHashEnforcerTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪CacheHashEnforcerTest extends UnitTestCase
28 {
32  protected ‪$subject;
33 
38 
39  protected function ‪setUp()
40  {
41  $this->frontendControllerMock = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
42  $this->frontendControllerMock->id = 42;
43  $cacheHashCalculator = new ‪CacheHashCalculator();
44  $this->subject = new ‪CacheHashEnforcer(
45  $cacheHashCalculator,
46  $this->frontendControllerMock
47  );
48  }
49 
54  {
55  $request = new ‪Request();
56  $request->setArguments(['foo' => 'bar']);
57  $this->frontendControllerMock
58  ->expects($this->once())
59  ->method('reqCHash');
60 
61  $this->subject->enforceForRequest($request, 'tx_foo');
62  }
63 
68  {
69  $request = new Request();
70  $this->frontendControllerMock
71  ->expects($this->never())
72  ->method('reqCHash');
73 
74  $this->subject->enforceForRequest($request, 'tx_foo');
75  }
76 }
‪TYPO3\CMS\Extbase\Mvc\Web\CacheHashEnforcer
Definition: CacheHashEnforcer.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\CacheHashEnforcerTest\$subject
‪TYPO3 CMS Extbase Mvc Web CacheHashEnforcer $subject
Definition: CacheHashEnforcerTest.php:31
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\CacheHashEnforcerTest\$frontendControllerMock
‪TypoScriptFrontendController PHPUnit_Framework_MockObject_MockObject $frontendControllerMock
Definition: CacheHashEnforcerTest.php:35
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\CacheHashEnforcerTest\validateCallsReqCHashIfRequestArgumentsArePresent
‪validateCallsReqCHashIfRequestArgumentsArePresent()
Definition: CacheHashEnforcerTest.php:51
‪TYPO3\CMS\Extbase\Mvc\Web\Request
Definition: Request.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\CacheHashEnforcerTest\validateDoesNotCallsReqCHashIfNoRequestArgumentsArePresent
‪validateDoesNotCallsReqCHashIfNoRequestArgumentsArePresent()
Definition: CacheHashEnforcerTest.php:65
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web
Definition: CacheHashEnforcerTest.php:3
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪TYPO3\CMS\Frontend\Page\CacheHashCalculator
Definition: CacheHashCalculator.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\CacheHashEnforcerTest
Definition: CacheHashEnforcerTest.php:28
‪TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\CacheHashEnforcerTest\setUp
‪setUp()
Definition: CacheHashEnforcerTest.php:37