‪TYPO3CMS  10.4
CachingFrameworkGarbageCollectionTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪CachingFrameworkGarbageCollectionTest extends UnitTestCase
30 {
34  protected ‪$resetSingletonInstances = true;
35 
40  {
41  $cache = $this->createMock(VariableFrontend::class);
42  $cache->expects(self::any())->method('getIdentifier')->willReturn('cache');
43  $cache->expects(self::atLeastOnce())->method('collectGarbage');
44  $mockCacheManager = new ‪CacheManager();
45  $mockCacheManager->registerCache($cache);
46  GeneralUtility::setSingletonInstance(CacheManager::class, $mockCacheManager);
47  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = [
48  'cache' => [
49  'frontend' => VariableFrontend::class,
50  'backend' => AbstractBackend::class,
51  ]
52  ];
54  $subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class)
55  ->setMethods(['dummy'])
56  ->disableOriginalConstructor()
57  ->getMock();
58  $subject->selectedBackends = [AbstractBackend::class];
59  $subject->execute();
60  }
61 
66  {
67  $cache = $this->createMock(VariableFrontend::class);
68  $cache->expects(self::any())->method('getIdentifier')->willReturn('cache');
69  $cache->expects(self::never())->method('collectGarbage');
70  $mockCacheManager = new ‪CacheManager();
71  $mockCacheManager->registerCache($cache);
72  GeneralUtility::setSingletonInstance(CacheManager::class, $mockCacheManager);
73  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = [
74  'cache' => [
75  'frontend' => VariableFrontend::class,
76  'backend' => AbstractBackend::class,
77  ]
78  ];
80  $subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class)
81  ->setMethods(['dummy'])
82  ->disableOriginalConstructor()
83  ->getMock();
84  $subject->selectedBackends = [NullBackend::class];
85  $subject->execute();
86  }
87 }
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest\executeCallsCollectGarbageOfConfiguredBackend
‪executeCallsCollectGarbageOfConfiguredBackend()
Definition: CachingFrameworkGarbageCollectionTest.php:38
‪TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask
Definition: CachingFrameworkGarbageCollectionTask.php:30
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest\executeDoesNotCallCollectGarbageOfNotConfiguredBackend
‪executeDoesNotCallCollectGarbageOfNotConfiguredBackend()
Definition: CachingFrameworkGarbageCollectionTest.php:64
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: CachingFrameworkGarbageCollectionTest.php:33
‪TYPO3\CMS\Scheduler\Tests\Unit\Task\CachingFrameworkGarbageCollectionTest
Definition: CachingFrameworkGarbageCollectionTest.php:30
‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend
Definition: VariableFrontend.php:25
‪TYPO3\CMS\Core\Cache\Backend\NullBackend
Definition: NullBackend.php:22
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:35
‪TYPO3\CMS\Core\Cache\Backend\AbstractBackend
Definition: AbstractBackend.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Scheduler\Tests\Unit\Task
Definition: CachingFrameworkGarbageCollectionTest.php:16
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46