TYPO3 CMS  TYPO3_7-6
PhpFrontendTest.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  */
16 
23 {
29  {
30  $cache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class, ['isValidEntryIdentifier'], [], '', false);
31  $cache->expects($this->once())->method('isValidEntryIdentifier')->with('foo')->will($this->returnValue(false));
32  $cache->set('foo', 'bar');
33  }
34 
39  {
40  $originalSourceCode = 'return "hello world!";';
41  $modifiedSourceCode = '<?php' . chr(10) . $originalSourceCode . chr(10) . '#';
42  $mockBackend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface::class, [], [], '', false);
43  $mockBackend->expects($this->once())->method('set')->with('Foo-Bar', $modifiedSourceCode, ['tags'], 1234);
44  $cache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, 'PhpFrontend', $mockBackend);
45  $cache->set('Foo-Bar', $originalSourceCode, ['tags'], 1234);
46  }
47 
53  {
54  $cache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, ['dummy'], [], '', false);
55  $cache->set('Foo-Bar', []);
56  }
57 
62  {
63  $mockBackend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface::class, [], [], '', false);
64  $mockBackend->expects($this->once())->method('requireOnce')->with('Foo-Bar')->will($this->returnValue('hello world!'));
65  $cache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, 'PhpFrontend', $mockBackend);
66  $result = $cache->requireOnce('Foo-Bar');
67  $this->assertSame('hello world!', $result);
68  }
69 }