fda40c5d1a5554ed4062942733b54ae028a25a9c
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / Core / Cache / FluidTemplateCacheTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Cache;
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 */
16 use TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface;
17 use TYPO3\CMS\Core\Tests\UnitTestCase;
18 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
19
20 /**
21 * Test case
22 */
23 class FluidTemplateCacheTest extends UnitTestCase
24 {
25 /**
26 * @test
27 */
28 public function flushCallsFlushOnBackend()
29 {
30 $backend = $this->getMock(PhpCapableBackendInterface::class);
31 $backend->expects($this->once())->method('flush');
32 $instance = new FluidTemplateCache('dummy', $backend);
33 $instance->flush();
34 }
35
36 /**
37 * @test
38 */
39 public function getDelegatesToRequireOnce()
40 {
41 $instance = $this->getMock(FluidTemplateCache::class, array('requireOnce'), array(), '', false);
42 $instance->expects($this->once())->method('requireOnce')->with('foobar');
43 $instance->get('foobar');
44 }
45
46 /**
47 * @test
48 */
49 public function setCallsSetOnBackend()
50 {
51 $backend = $this->getMock(PhpCapableBackendInterface::class);
52 $backend->expects($this->once())->method('set')->with(
53 'test',
54 '<?php' . PHP_EOL . 'test' . PHP_EOL . '#',
55 array('foobar'),
56 $this->anything()
57 );
58 $instance = new FluidTemplateCache('dummy', $backend);
59 $instance->set('test', 'test', array('foobar'));
60 }
61
62 /**
63 * @test
64 */
65 public function setRemovesLeadingPhpTagBeforeCallingParentWhichAddsLeadingPhpTag()
66 {
67 $backend = $this->getMock(PhpCapableBackendInterface::class);
68 $backend->expects($this->once())->method('set')->with(
69 'test',
70 '<?php' . PHP_EOL . 'test' . PHP_EOL . '#',
71 array('foobar'),
72 $this->anything()
73 );
74 $instance = new FluidTemplateCache('dummy', $backend);
75 $instance->set('test', '<?php' . PHP_EOL . 'test', array('foobar'));
76 }
77 }