[TASK] Re-work/simplify copyright header in PHP files - Part 4
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Cache / FactoryTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\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
17 /**
18 * Testcase for the TYPO3\CMS\Core\Cache\CacheFactory
19 *
20 * This file is a backport from FLOW3
21 *
22 * @author Ingo Renner <ingo@typo3.org>
23 */
24 class FactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
25
26 /**
27 * @test
28 */
29 public function createReturnsInstanceOfTheSpecifiedCacheFrontend() {
30 $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('registerCache'), array(), '', FALSE);
31 $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
32 $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', 'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend');
33 $this->assertInstanceOf('TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', $cache);
34 }
35
36 /**
37 * @test
38 */
39 public function createInjectsAnInstanceOfTheSpecifiedBackendIntoTheCacheFrontend() {
40 $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('registerCache'), array(), '', FALSE);
41 $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
42 $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend');
43 $this->assertInstanceOf('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', $cache->getBackend());
44 }
45
46 /**
47 * @test
48 */
49 public function createRegistersTheCacheAtTheCacheManager() {
50 $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('registerCache'), array(), '', FALSE);
51 $mockCacheManager->expects($this->once())->method('registerCache');
52 $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
53 $factory->create('TYPO3_Cache_FactoryTest_Cache', 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend');
54 }
55
56 }