TYPO3 CMS  TYPO3_6-2
CachingFrameworkGarbageCollectionTest.php
Go to the documentation of this file.
1 <?php
3 
17 
24 
28  protected $singletonInstances = array();
29 
33  public function setUp() {
35  }
36 
40  public function tearDown() {
42  parent::tearDown();
43  }
44 
48  public function executeCallsCollectGarbageOfConfiguredBackend() {
49  $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array(), array(), '', FALSE);
50  $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
51  $cache->expects($this->atLeastOnce())->method('collectGarbage');
52  $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
53  $mockCacheManager->registerCache($cache);
54  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
55  $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array(
56  'cache' => array(
57  'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend',
58  'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend',
59  )
60  );
62  $subject = $this->getMock('TYPO3\\CMS\\Scheduler\\Task\\CachingFrameworkGarbageCollectionTask', array('dummy'), array(), '', FALSE);
63  $subject->selectedBackends = array('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend');
64  $subject->execute();
65  }
66 
70  public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend() {
71  $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array(), array(), '', FALSE);
72  $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
73  $cache->expects($this->never())->method('collectGarbage');
74  $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
75  $mockCacheManager->registerCache($cache);
76  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
77  $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array(
78  'cache' => array(
79  'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend',
80  'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend',
81  )
82  );
84  $subject = $this->getMock('TYPO3\\CMS\\Scheduler\\Task\\CachingFrameworkGarbageCollectionTask', array('dummy'), array(), '', FALSE);
85  $subject->selectedBackends = array('TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend');
86  $subject->execute();
87  }
88 
89 }
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static resetSingletonInstances(array $newSingletonInstances)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]