‪TYPO3CMS  10.4
FluidTemplateCacheTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class FluidTemplateCacheTest extends UnitTestCase
26 {
30  public function flushCallsFlushOnBackend()
31  {
32  $backend = $this->createMock(PhpCapableBackendInterface::class);
33  $backend->expects(self::once())->method('flush');
34  $instance = new FluidTemplateCache('dummy', $backend);
35  $instance->flush();
36  }
37 
41  public function getDelegatesToRequireOnce()
42  {
43  $instance = $this->getMockBuilder(FluidTemplateCache::class)
44  ->setMethods(['requireOnce'])
45  ->disableOriginalConstructor()
46  ->getMock();
47  $instance->expects(self::once())->method('requireOnce')->with('foobar');
48  $instance->get('foobar');
49  }
50 
54  public function setCallsSetOnBackend()
55  {
56  $backend = $this->createMock(PhpCapableBackendInterface::class);
57  $backend->expects(self::once())->method('set')->with(
58  'test',
59  '<?php' . LF . 'test' . LF . '#',
60  ['foobar'],
61  self::anything()
62  );
63  $instance = new FluidTemplateCache('dummy', $backend);
64  $instance->set('test', 'test', ['foobar']);
65  }
66 
70  public function setRemovesLeadingPhpTagBeforeCallingParentWhichAddsLeadingPhpTag()
71  {
72  $backend = $this->createMock(PhpCapableBackendInterface::class);
73  $backend->expects(self::once())->method('set')->with(
74  'test',
75  '<?php' . LF . 'test' . LF . '#',
76  ['foobar'],
77  self::anything()
78  );
79  $instance = new FluidTemplateCache('dummy', $backend);
80  $instance->set('test', '<?php' . LF . 'test', ['foobar']);
81  }
82 }
‪TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface
Definition: PhpCapableBackendInterface.php:23
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Cache
Definition: FluidTemplateCacheTest.php:16