[BUGFIX] Log out after running garbage collection tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / tests / tx_scheduler_cachingframeworkgarbagecollectionTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
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 /**
26 * Testcase for class "tx_scheduler_CachingFrameworkGarbageCollection"
27 *
28 * @package TYPO3
29 * @subpackage tx_scheduler
30 *
31 * @author Christian Kuhn <lolli@schwarzbu.ch>
32 */
33 class tx_scheduler_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('t3lib_cache_frontend_StringFrontend', array(), array(), '', FALSE);
55 $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
56
57 $cache->expects($this->atLeastOnce())->method('collectGarbage');
58
59 $GLOBALS['typo3CacheManager'] = new t3lib_cache_Manager();
60 $GLOBALS['typo3CacheManager']->registerCache($cache);
61 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array(
62 'cache' => array(
63 'frontend' => 't3lib_cache_frontend_StringFrontend',
64 'backend' => 't3lib_cache_backend_AbstractBackend',
65 ),
66 );
67
68 $task = new tx_scheduler_CachingFrameworkGarbageCollection();
69 $task->selectedBackends = array('t3lib_cache_backend_AbstractBackend');
70 $task->execute();
71 }
72
73 /**
74 * @test
75 */
76 public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend() {
77 $cache = $this->getMock('t3lib_cache_frontend_StringFrontend', array(), array(), '', FALSE);
78 $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
79
80 $cache->expects($this->never())->method('collectGarbage');
81
82 $GLOBALS['typo3CacheManager'] = new t3lib_cache_Manager();
83 $GLOBALS['typo3CacheManager']->registerCache($cache);
84 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array(
85 'cache' => array(
86 'frontend' => 't3lib_cache_frontend_StringFrontend',
87 'backend' => 't3lib_cache_backend_AbstractBackend',
88 ),
89 );
90
91 $task = new tx_scheduler_CachingFrameworkGarbageCollection();
92 $task->selectedBackends = array('t3lib_cache_backend_NullBackend');
93 $task->execute();
94 }
95 }
96 ?>