‪TYPO3CMS  11.5
FluidTemplateCacheTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
21 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class FluidTemplateCacheTest extends UnitTestCase
28 {
32  public function flushCallsFlushOnBackend(): void
33  {
34  $backend = $this->createMock(PhpCapableBackendInterface::class);
35  $backend->expects(self::once())->method('flush');
36  $instance = new FluidTemplateCache('dummy', $backend);
37  $instance->flush();
38  }
39 
43  public function getDelegatesToRequireOnce(): void
44  {
45  $instance = $this->getMockBuilder(FluidTemplateCache::class)
46  ->onlyMethods(['requireOnce'])
47  ->disableOriginalConstructor()
48  ->getMock();
49  $instance->expects(self::once())->method('requireOnce')->with('foobar');
50  $instance->get('foobar');
51  }
52 
56  public function setCallsSetOnBackend(): void
57  {
58  $backend = $this->createMock(PhpCapableBackendInterface::class);
59  $backend->expects(self::once())->method('set')->with(
60  'test',
61  '<?php' . LF . 'test' . LF . '#',
62  ['foobar'],
63  self::anything()
64  );
65  $instance = new FluidTemplateCache('dummy', $backend);
66  $instance->set('test', 'test', ['foobar']);
67  }
68 
72  public function setRemovesLeadingPhpTagBeforeCallingParentWhichAddsLeadingPhpTag(): void
73  {
74  $backend = $this->createMock(PhpCapableBackendInterface::class);
75  $backend->expects(self::once())->method('set')->with(
76  'test',
77  '<?php' . LF . 'test' . LF . '#',
78  ['foobar'],
79  self::anything()
80  );
81  $instance = new FluidTemplateCache('dummy', $backend);
82  $instance->set('test', '<?php' . LF . 'test', ['foobar']);
83  }
84 }
‪TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface
Definition: PhpCapableBackendInterface.php:23
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Cache
Definition: FluidTemplateCacheTest.php:18