From 4234575c36dbfbf1bf13fac0c05aa8a26280398c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 12 Apr 2018 08:26:34 +0200 Subject: [PATCH] TASK: Fix broken tests caused by missing caches For some reason, which is unknown yet, caches are needed to make tests pass. We therefore configure the caches to be null. --- Tests/Unit/AbstractUnitTestCase.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Tests/Unit/AbstractUnitTestCase.php b/Tests/Unit/AbstractUnitTestCase.php index fa29d57..384236c 100644 --- a/Tests/Unit/AbstractUnitTestCase.php +++ b/Tests/Unit/AbstractUnitTestCase.php @@ -39,14 +39,9 @@ abstract class AbstractUnitTestCase extends CoreTestCase $this->singletonInstances = GeneralUtility::getSingletonInstances(); // Disable caching backends to make TYPO3 parts work in unit test mode. - \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Cache\CacheManager::class - )->setCacheConfigurations([ - 'extbase_object' => [ - 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, - ], - ]); + )->setCacheConfigurations($this->getCacheConfiguration()); } public function tearDown() @@ -100,4 +95,25 @@ abstract class AbstractUnitTestCase extends CoreTestCase { return \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 8000000; } + + protected function getCacheConfiguration() : array + { + $cacheConfiguration = [ + 'extbase_object' => [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, + ], + 'cache_runtime' => [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, + ], + ]; + + if (class_exists(\TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache::class)) { + $cacheConfiguration['fluid_template'] = [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class, + 'frontend' => \TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache::class, + ]; + } + + return $cacheConfiguration; + } }