[!!!][TASK] Extract testing framework for TYPO3
[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\Fluid\Core\Cache\FluidTemplateCache;
18
19 /**
20 * Test case
21 */
22 class FluidTemplateCacheTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
23 {
24 /**
25 * @test
26 */
27 public function flushCallsFlushOnBackend()
28 {
29 $backend = $this->createMock(PhpCapableBackendInterface::class);
30 $backend->expects($this->once())->method('flush');
31 $instance = new FluidTemplateCache('dummy', $backend);
32 $instance->flush();
33 }
34
35 /**
36 * @test
37 */
38 public function getDelegatesToRequireOnce()
39 {
40 $instance = $this->getMockBuilder(FluidTemplateCache::class)
41 ->setMethods(['requireOnce'])
42 ->disableOriginalConstructor()
43 ->getMock();
44 $instance->expects($this->once())->method('requireOnce')->with('foobar');
45 $instance->get('foobar');
46 }
47
48 /**
49 * @test
50 */
51 public function setCallsSetOnBackend()
52 {
53 $backend = $this->createMock(PhpCapableBackendInterface::class);
54 $backend->expects($this->once())->method('set')->with(
55 'test',
56 '<?php' . LF . 'test' . LF . '#',
57 ['foobar'],
58 $this->anything()
59 );
60 $instance = new FluidTemplateCache('dummy', $backend);
61 $instance->set('test', 'test', ['foobar']);
62 }
63
64 /**
65 * @test
66 */
67 public function setRemovesLeadingPhpTagBeforeCallingParentWhichAddsLeadingPhpTag()
68 {
69 $backend = $this->createMock(PhpCapableBackendInterface::class);
70 $backend->expects($this->once())->method('set')->with(
71 'test',
72 '<?php' . LF . 'test' . LF . '#',
73 ['foobar'],
74 $this->anything()
75 );
76 $instance = new FluidTemplateCache('dummy', $backend);
77 $instance->set('test', '<?php' . LF . 'test', ['foobar']);
78 }
79 }