TYPO3 CMS  TYPO3_7-6
CachingFrameworkGarbageCollectionTest.php
Go to the documentation of this file.
1 <?php
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 
18 
23 {
27  protected $singletonInstances = [];
28 
32  protected function setUp()
33  {
35  }
36 
40  protected function tearDown()
41  {
43  parent::tearDown();
44  }
45 
49  public function executeCallsCollectGarbageOfConfiguredBackend()
50  {
51  $cache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class, [], [], '', false);
52  $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
53  $cache->expects($this->atLeastOnce())->method('collectGarbage');
54  $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
55  $mockCacheManager->registerCache($cache);
56  GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
57  $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = [
58  'cache' => [
59  'frontend' => \TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class,
60  'backend' => \TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class,
61  ]
62  ];
64  $subject = $this->getMock(\TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask::class, ['dummy'], [], '', false);
65  $subject->selectedBackends = [\TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class];
66  $subject->execute();
67  }
68 
72  public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend()
73  {
74  $cache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class, [], [], '', false);
75  $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
76  $cache->expects($this->never())->method('collectGarbage');
77  $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
78  $mockCacheManager->registerCache($cache);
79  GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
80  $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = [
81  'cache' => [
82  'frontend' => \TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class,
83  'backend' => \TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class,
84  ]
85  ];
87  $subject = $this->getMock(\TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask::class, ['dummy'], [], '', false);
88  $subject->selectedBackends = [\TYPO3\CMS\Core\Cache\Backend\NullBackend::class];
89  $subject->execute();
90  }
91 }
static setSingletonInstance($className, SingletonInterface $instance)
static resetSingletonInstances(array $newSingletonInstances)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']