[BUGFIX] Fix ajax scripts in recycler
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / tests / Unit / Task / CachingFrameworkGarbageCollectionTest.php
1 <?php
2 namespace TYPO3\CMS\Scheduler\Tests\Unit\Task;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Testcase for class "tx_scheduler_CachingFrameworkGarbageCollection"
28 *
29 * @package TYPO3
30 * @subpackage tx_scheduler
31 * @author Christian Kuhn <lolli@schwarzbu.ch>
32 */
33 class CachingFrameworkGarbageCollectionTest extends tx_phpunit_testcase {
34
35 /**
36 * Enable backup of global and system variables
37 *
38 * @var boolean
39 */
40 protected $backupGlobals = TRUE;
41
42 /**
43 * Exclude TYPO3_DB from backup/ restore of $GLOBALS
44 * because resource types cannot be handled during serialization
45 *
46 * @var array
47 */
48 protected $backupGlobalsBlacklist = array('TYPO3_DB');
49
50 /**
51 * @test
52 */
53 public function executeCallsCollectGarbageOfConfiguredBackend() {
54 $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Cache_frontend_StringFrontend', array(), array(), '', FALSE);
55 $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
56 $cache->expects($this->atLeastOnce())->method('collectGarbage');
57 $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Cache\CacheManager();
58 $GLOBALS['typo3CacheManager']->registerCache($cache);
59 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array(
60 'cache' => array(
61 'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Cache_frontend_StringFrontend',
62 'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend'
63 )
64 );
65 $task = new \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask();
66 $task->selectedBackends = array('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend');
67 $task->execute();
68 }
69
70 /**
71 * @test
72 */
73 public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend() {
74 $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Cache_frontend_StringFrontend', array(), array(), '', FALSE);
75 $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
76 $cache->expects($this->never())->method('collectGarbage');
77 $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Cache\CacheManager();
78 $GLOBALS['typo3CacheManager']->registerCache($cache);
79 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array(
80 'cache' => array(
81 'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Cache_frontend_StringFrontend',
82 'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend'
83 )
84 );
85 $task = new \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask();
86 $task->selectedBackends = array('TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend');
87 $task->execute();
88 }
89
90 }
91
92
93 ?>