TYPO3 CMS  TYPO3_8-7
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 
26 class CacheHashEnforcerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
27 {
31  protected $subject;
32 
37 
38  protected function setUp()
39  {
40  $this->frontendControllerMock = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->getMock();
41  $this->frontendControllerMock->id = 42;
42  $cacheHashCalculator = new CacheHashCalculator();
43  $this->subject = new CacheHashEnforcer(
44  $cacheHashCalculator,
45  $this->frontendControllerMock
46  );
47  }
48 
53  {
54  $request = new Request();
55  $request->setArguments(['foo' => 'bar']);
56  $this->frontendControllerMock
57  ->expects($this->once())
58  ->method('reqCHash');
59 
60  $this->subject->enforceForRequest($request, 'tx_foo');
61  }
62 
67  {
68  $request = new Request();
69  $this->frontendControllerMock
70  ->expects($this->never())
71  ->method('reqCHash');
72 
73  $this->subject->enforceForRequest($request, 'tx_foo');
74  }
75 }