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