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