‪TYPO3CMS  9.5
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 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪CachingFrameworkGarbageCollectionTest extends UnitTestCase
24 {
28  protected ‪$resetSingletonInstances = true;
29 
34  {
35  $cache = $this->createMock(\‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class);
36  $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
37  $cache->expects($this->atLeastOnce())->method('collectGarbage');
38  $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
39  $mockCacheManager->registerCache($cache);
40  GeneralUtility::setSingletonInstance(\‪TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
41  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = [
42  'cache' => [
43  'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
44  'backend' => \TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class,
45  ]
46  ];
48  $subject = $this->getMockBuilder(\‪TYPO3\CMS\‪Scheduler\Task\CachingFrameworkGarbageCollectionTask::class)
49  ->setMethods(['dummy'])
50  ->disableOriginalConstructor()
51  ->getMock();
52  $subject->selectedBackends = [\TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class];
53  $subject->execute();
54  }
55 
60  {
61  $cache = $this->createMock(\‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class);
62  $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
63  $cache->expects($this->never())->method('collectGarbage');
64  $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
65  $mockCacheManager->registerCache($cache);
66  GeneralUtility::setSingletonInstance(\‪TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
67  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = [
68  'cache' => [
69  'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
70  'backend' => \TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class,
71  ]
72  ];
74  $subject = $this->getMockBuilder(\‪TYPO3\CMS\‪Scheduler\Task\CachingFrameworkGarbageCollectionTask::class)
75  ->setMethods(['dummy'])
76  ->disableOriginalConstructor()
77  ->getMock();
78  $subject->selectedBackends = [\TYPO3\CMS\Core\Cache\Backend\NullBackend::class];
79  $subject->execute();
80  }
81 }
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest\executeCallsCollectGarbageOfConfiguredBackend
‪executeCallsCollectGarbageOfConfiguredBackend()
Definition: CachingFrameworkGarbageCollectionTest.php:32
‪TYPO3
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest\executeDoesNotCallCollectGarbageOfNotConfiguredBackend
‪executeDoesNotCallCollectGarbageOfNotConfiguredBackend()
Definition: CachingFrameworkGarbageCollectionTest.php:58
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: CachingFrameworkGarbageCollectionTest.php:27
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest
Definition: CachingFrameworkGarbageCollectionTest.php:24
‪TYPO3\CMS\Scheduler\Scheduler
Definition: Scheduler.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Scheduler\Tests\Unit\Task
Definition: CachingFrameworkGarbageCollectionTest.php:2
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45