[TASK] Update caching framework to latest FLOW3 version
[Packages/TYPO3.CMS.git] / tests / t3lib / cache / class.t3lib_cache_factoryTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 require_once 'backend/class.t3lib_cache_backend_mockbackend.php';
26
27 /**
28 * Testcase for the Cache Factory
29 *
30 * This file is a backport from FLOW3
31 *
32 * @author Ingo Renner <ingo@typo3.org>
33 * @package TYPO3
34 * @subpackage tests
35 */
36 class t3lib_cache_FactoryTest extends tx_phpunit_testcase {
37
38 /**
39 * Sets up this testcase
40 *
41 * @return void
42 * @author Ingo Renner <ingo@typo3.org>
43 */
44 public function setUp() {
45 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackends']['t3lib_cache_backend_MockBackend'] = 't3lib_cache_backend_MockBackend';
46 }
47
48 /**
49 * @test
50 * @author Robert Lemke <robert@typo3.org>
51 * @author Karsten Dambekalns <karsten@typo3.org>
52 * @author Ingo Renner <ingo@typo3.org>
53 */
54 public function createReturnsInstanceOfTheSpecifiedCacheFrontend() {
55 $mockCacheManager = $this->getMock('t3lib_cache_Manager', array('registerCache'), array(), '', FALSE);
56 $factory = new t3lib_cache_Factory('Testing', $mockCacheManager);
57
58 $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', 't3lib_cache_frontend_VariableFrontend', 't3lib_cache_backend_NullBackend');
59 $this->assertInstanceOf('t3lib_cache_frontend_VariableFrontend', $cache);
60 }
61
62 /**
63 * @test
64 * @author Robert Lemke <robert@typo3.org>
65 * @author Ingo Renner <ingo@typo3.org>
66 */
67 public function createInjectsAnInstanceOfTheSpecifiedBackendIntoTheCacheFrontend() {
68 $mockCacheManager = $this->getMock('t3lib_cache_Manager', array('registerCache'), array(), '', FALSE);
69
70 $factory = new t3lib_cache_Factory('Testing', $mockCacheManager);
71 $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', 't3lib_cache_frontend_VariableFrontend', 't3lib_cache_backend_FileBackend');
72 $this->assertInstanceOf('t3lib_cache_backend_FileBackend', $cache->getBackend());
73 }
74
75 /**
76 * @test
77 * @author Robert Lemke <robert@typo3.org>
78 * @author Ingo Renner <ingo@typo3.org>
79 */
80 public function createRegistersTheCacheAtTheCacheManager() {
81 $mockCacheManager = $this->getMock('t3lib_cache_Manager', array('registerCache'), array(), '', FALSE);
82
83 $mockCacheManager->expects($this->once())->method('registerCache');
84
85 $factory = new t3lib_cache_Factory('Testing', $mockCacheManager);
86 $factory->create('TYPO3_Cache_FactoryTest_Cache', 't3lib_cache_frontend_VariableFrontend', 't3lib_cache_backend_FileBackend');
87 }
88 }
89
90 ?>