[TASK] Deprecate CacheFactory 22/48322/3
authorBenni Mack <benni@typo3.org>
Fri, 27 May 2016 11:18:59 +0000 (13:18 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Mon, 30 May 2016 08:34:03 +0000 (10:34 +0200)
CacheManager and CacheFactory are tightly coupled and
a different implemenation of the CacheFactory is not
in sight and doesn't seem to be needed.
The single method from CacheFactory is moved into
CacheManager now and the factory is marked as deprecated
and unused.

Resolves: #76370
Releases: master
Change-Id: I380edef47ebfd6d2cab044a562467c3b685ec96c
Reviewed-on: https://review.typo3.org/48322
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
19 files changed:
typo3/sysext/core/Classes/Cache/CacheFactory.php
typo3/sysext/core/Classes/Cache/CacheManager.php
typo3/sysext/core/Classes/Cache/DatabaseSchemaService.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-76370-DeprecateCacheFactory.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/CacheFactoryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/CacheManagerTest.php
typo3/sysext/core/Tests/Unit/Cache/FactoryTest.php [deleted file]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendConfigurationOptionFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendDefaultFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendInitializeObjectFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendBackendInstanceFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendDefaultFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendIdentifierFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendInitializeObjectFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/last_synched_revision [deleted file]
typo3/sysext/install/Classes/Service/ClearCacheService.php

index e5d901a..265ad1f 100644 (file)
@@ -14,14 +14,15 @@ namespace TYPO3\CMS\Core\Cache;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * This cache factory takes care of instantiating a cache frontend and injecting
  * a certain cache backend. After creation of the new cache, the cache object
  * is registered at the cache manager.
  *
- * This file is a backport from FLOW3
- * @scope singleton
- * @api
+ * @deprecated This file is not in use anymore, as the functionality
+ * was moved into the CacheManager class.
  */
 class CacheFactory implements \TYPO3\CMS\Core\SingletonInterface
 {
@@ -47,12 +48,13 @@ class CacheFactory implements \TYPO3\CMS\Core\SingletonInterface
      *
      * @param string $context The current FLOW3 context
      * @param \TYPO3\CMS\Core\Cache\CacheManager $cacheManager The cache manager
+     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, as it is not needed anymore
      */
     public function __construct($context, \TYPO3\CMS\Core\Cache\CacheManager $cacheManager)
     {
+        GeneralUtility::logDeprecatedFunction();
         $this->context = $context;
         $this->cacheManager = $cacheManager;
-        $this->cacheManager->injectCacheFactory($this);
     }
 
     /**
@@ -71,7 +73,7 @@ class CacheFactory implements \TYPO3\CMS\Core\SingletonInterface
     public function create($cacheIdentifier, $cacheObjectName, $backendObjectName, array $backendOptions = array())
     {
         // New operator used on purpose: This class is required early during
-        // bootstrap before makeInstance() is propely set up
+        // bootstrap before makeInstance() is properly set up
         $backendObjectName = '\\' . ltrim($backendObjectName, '\\');
         $backend = new $backendObjectName($this->context, $backendOptions);
         if (!$backend instanceof \TYPO3\CMS\Core\Cache\Backend\BackendInterface) {
index dfce814..ed3e486 100644 (file)
@@ -14,7 +14,16 @@ namespace TYPO3\CMS\Core\Cache;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Backend\BackendInterface;
+use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
+use TYPO3\CMS\Core\Cache\Exception\DuplicateIdentifierException;
+use TYPO3\CMS\Core\Cache\Exception\InvalidBackendException;
+use TYPO3\CMS\Core\Cache\Exception\InvalidCacheException;
+use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
 use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
+use TYPO3\CMS\Core\SingletonInterface;
 
 /**
  * The Cache Manager
@@ -23,15 +32,10 @@ use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheGroupException;
  * @scope singleton
  * @api
  */
-class CacheManager implements \TYPO3\CMS\Core\SingletonInterface
+class CacheManager implements SingletonInterface
 {
     /**
-     * @var \TYPO3\CMS\Core\Cache\CacheFactory
-     */
-    protected $cacheFactory;
-
-    /**
-     * @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface[]
+     * @var FrontendInterface[]
      */
     protected $caches = array();
 
@@ -54,22 +58,13 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface
      * @var array Default cache configuration as fallback
      */
     protected $defaultCacheConfiguration = array(
-        'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
-        'backend' => \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class,
+        'frontend' => VariableFrontend::class,
+        'backend' => Typo3DatabaseBackend::class,
         'options' => array(),
         'groups' => array('all')
     );
 
     /**
-     * @param \TYPO3\CMS\Core\Cache\CacheFactory $cacheFactory
-     * @return void
-     */
-    public function injectCacheFactory(\TYPO3\CMS\Core\Cache\CacheFactory $cacheFactory)
-    {
-        $this->cacheFactory = $cacheFactory;
-    }
-
-    /**
      * Sets configurations for caches. The key of each entry specifies the
      * cache identifier and the value is an array of configuration options.
      * Possible options are:
@@ -98,16 +93,16 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * Registers a cache so it can be retrieved at a later point.
      *
-     * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The cache frontend to be registered
+     * @param FrontendInterface $cache The cache frontend to be registered
      * @return void
-     * @throws \TYPO3\CMS\Core\Cache\Exception\DuplicateIdentifierException if a cache with the given identifier has already been registered.
+     * @throws DuplicateIdentifierException if a cache with the given identifier has already been registered.
      * @api
      */
-    public function registerCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
+    public function registerCache(FrontendInterface $cache)
     {
         $identifier = $cache->getIdentifier();
         if (isset($this->caches[$identifier])) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\DuplicateIdentifierException('A cache with identifier "' . $identifier . '" has already been registered.', 1203698223);
+            throw new DuplicateIdentifierException('A cache with identifier "' . $identifier . '" has already been registered.', 1203698223);
         }
         $this->caches[$identifier] = $cache;
     }
@@ -116,14 +111,14 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface
      * Returns the cache specified by $identifier
      *
      * @param string $identifier Identifies which cache to return
-     * @return \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface The specified cache frontend
-     * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
+     * @return FrontendInterface The specified cache frontend
+     * @throws NoSuchCacheException
      * @api
      */
     public function getCache($identifier)
     {
         if ($this->hasCache($identifier) === false) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException('A cache with identifier "' . $identifier . '" does not exist.', 1203699034);
+            throw new NoSuchCacheException('A cache with identifier "' . $identifier . '" does not exist.', 1203699034);
         }
         if (!isset($this->caches[$identifier])) {
             $this->createCache($identifier);
@@ -237,7 +232,9 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface
      * Instantiates the cache for $identifier.
      *
      * @param string $identifier
-     * @return void
+     * @throws DuplicateIdentifierException
+     * @throws InvalidBackendException
+     * @throws InvalidCacheException
      */
     protected function createCache($identifier)
     {
@@ -270,6 +267,26 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface
             $this->cacheGroups[$groupIdentifier][] = $identifier;
         }
 
-        $this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions);
+        // New operator used on purpose: This class is required early during
+        // bootstrap before makeInstance() is properly set up
+        $backend = '\\' . ltrim($backend, '\\');
+        $backendInstance = new $backend('production', $backendOptions);
+        if (!$backendInstance instanceof BackendInterface) {
+            throw new InvalidBackendException('"' . $backend . '" is not a valid cache backend object.', 1464550977);
+        }
+        if (is_callable(array($backendInstance, 'initializeObject'))) {
+            $backendInstance->initializeObject();
+        }
+
+        // New used on purpose, see comment above
+        $frontendInstance = new $frontend($identifier, $backendInstance);
+        if (!$frontendInstance instanceof FrontendInterface) {
+            throw new InvalidCacheException('"' . $frontend . '" is not a valid cache frontend object.', 1464550984);
+        }
+        if (is_callable(array($frontendInstance, 'initializeObject'))) {
+            $frontendInstance->initializeObject();
+        }
+
+        $this->registerCache($frontendInstance);
     }
 }
index e33f988..0e3b062 100644 (file)
@@ -29,10 +29,8 @@ class DatabaseSchemaService
     public function getCachingFrameworkRequiredDatabaseSchema()
     {
         // Use new to circumvent the singleton pattern of CacheManager
-        $cacheManager = new CacheManager;
+        $cacheManager = new CacheManager();
         $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
-        // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
-        new CacheFactory('production', $cacheManager);
 
         $tableDefinitions = '';
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $cacheName => $_) {
index 0e44f47..0a5e49a 100644 (file)
@@ -564,10 +564,6 @@ class Bootstrap
         $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
         $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
-
-        $cacheFactory = new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
-        GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheFactory::class, $cacheFactory);
-
         $this->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
         return $this;
     }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-76370-DeprecateCacheFactory.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-76370-DeprecateCacheFactory.rst
new file mode 100644 (file)
index 0000000..005f8d5
--- /dev/null
@@ -0,0 +1,26 @@
+============================================
+Deprecation: #76370 - Deprecate CacheFactory
+============================================
+
+Description
+===========
+
+Class :php:`CacheFactory` has been deprecated.
+
+
+Impact
+======
+
+The class is no longer used or instantiated by the core.
+
+
+Affected Installations
+======================
+
+TYPO3 instances and extensions typically make no use of this internal class.
+
+
+Migration
+=========
+
+Nothing notable, do not use this class anymore.
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/CacheFactoryTest.php b/typo3/sysext/core/Tests/Unit/Cache/CacheFactoryTest.php
new file mode 100644 (file)
index 0000000..d65c36f
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Testcase for the TYPO3\CMS\Core\Cache\CacheFactory
+ *
+ * This file is a backport from FLOW3
+ */
+class FactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function createReturnsInstanceOfTheSpecifiedCacheFrontend()
+    {
+        $mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array('registerCache'), array(), '', false);
+        $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
+        $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, \TYPO3\CMS\Core\Cache\Backend\NullBackend::class);
+        $this->assertInstanceOf(\TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, $cache);
+    }
+
+    /**
+     * @test
+     */
+    public function createInjectsAnInstanceOfTheSpecifiedBackendIntoTheCacheFrontend()
+    {
+        $mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array('registerCache'), array(), '', false);
+        $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
+        $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, \TYPO3\CMS\Core\Cache\Backend\FileBackend::class);
+        $this->assertInstanceOf(\TYPO3\CMS\Core\Cache\Backend\FileBackend::class, $cache->getBackend());
+    }
+
+    /**
+     * @test
+     */
+    public function createRegistersTheCacheAtTheCacheManager()
+    {
+        $mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array('registerCache'), array(), '', false);
+        $mockCacheManager->expects($this->once())->method('registerCache');
+        $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
+        $factory->create('TYPO3_Cache_FactoryTest_Cache', \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, \TYPO3\CMS\Core\Cache\Backend\FileBackend::class);
+    }
+}
index 6c6d19d..6c909fe 100644 (file)
@@ -14,12 +14,27 @@ namespace TYPO3\CMS\Core\Tests\Unit\Cache;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Exception\InvalidBackendException;
+use TYPO3\CMS\Core\Cache\Exception\InvalidCacheException;
+use TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\BackendConfigurationOptionFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\BackendDefaultFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\BackendFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\BackendInitializeObjectFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\FrontendBackendInstanceFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\FrontendDefaultFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\FrontendFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\FrontendIdentifierFixture;
+use TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures\FrontendInitializeObjectFixture;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
+
 /**
  * Testcase for the TYPO3\CMS\Core\Cache\CacheManager
  *
  * This file is a backport from FLOW3
  */
-class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
+class CacheManagerTest extends UnitTestCase
 {
     /**
      * @test
@@ -27,10 +42,10 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function managerThrowsExceptionOnCacheRegistrationWithAlreadyExistingIdentifier()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cache1 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $manager = new CacheManager();
+        $cache1 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('test'));
-        $cache2 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $cache2 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache2->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('test'));
         $manager->registerCache($cache1);
         $manager->registerCache($cache2);
@@ -41,10 +56,10 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function managerReturnsThePreviouslyRegisteredCache()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cache1 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $manager = new CacheManager();
+        $cache1 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache1'));
-        $cache2 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $cache2 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache2->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache2'));
         $manager->registerCache($cache1);
         $manager->registerCache($cache2);
@@ -57,8 +72,8 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getCacheThrowsExceptionForNonExistingIdentifier()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $manager = new CacheManager();
+        $cache = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('someidentifier'));
         $manager->registerCache($cache);
         $manager->getCache('someidentifier');
@@ -70,8 +85,8 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function hasCacheReturnsCorrectResult()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cache1 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $manager = new CacheManager();
+        $cache1 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache1'));
         $manager->registerCache($cache1);
         $this->assertTrue($manager->hasCache('cache1'), 'hasCache() did not return TRUE.');
@@ -83,12 +98,12 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function flushCachesByTagCallsTheFlushByTagMethodOfAllRegisteredCaches()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cache1 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $manager = new CacheManager();
+        $cache1 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache1'));
         $cache1->expects($this->once())->method('flushByTag')->with($this->equalTo('theTag'));
         $manager->registerCache($cache1);
-        $cache2 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $cache2 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache2->expects($this->once())->method('flushByTag')->with($this->equalTo('theTag'));
         $manager->registerCache($cache2);
         $manager->flushCachesByTag('theTag');
@@ -99,12 +114,12 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function flushCachesCallsTheFlushMethodOfAllRegisteredCaches()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cache1 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $manager = new CacheManager();
+        $cache1 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache1'));
         $cache1->expects($this->once())->method('flush');
         $manager->registerCache($cache1);
-        $cache2 = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
+        $cache2 = $this->getMock(AbstractFrontend::class, array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', false);
         $cache2->expects($this->once())->method('flush');
         $manager->registerCache($cache2);
         $manager->flushCaches();
@@ -116,7 +131,7 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function flushCachesInGroupThrowsExceptionForNonExistingGroup()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
+        $manager = new CacheManager();
         $manager->flushCachesInGroup('nonExistingGroup');
     }
 
@@ -126,31 +141,112 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function flushCachesInGroupByTagThrowsExceptionForNonExistingGroup()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $manager->flushCachesInGroup('nonExistingGroup', 'someTag');
+        $manager = new CacheManager();
+        $manager->flushCachesInGroup('nonExistingGroup');
     }
 
     /**
      * @test
      */
-    public function getCacheCreatesCacheInstanceWithGivenConfiguration()
+    public function getCacheThrowsExceptionIfConfiguredFrontendDoesNotImplementFrontendInterface()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cacheIdentifier = $this->getUniqueId('Test');
-        $cacheObjectName = 'testCache';
-        $backendObjectName = 'testBackend';
-        $backendOptions = array('foo');
-        $configuration = array(
-            $cacheIdentifier => array(
-                'frontend' => $cacheObjectName,
-                'backend' => $backendObjectName,
-                'options' => $backendOptions
-            )
-        );
-        $factory = $this->getMock(\TYPO3\CMS\Core\Cache\CacheFactory::class, array('create'), array(), '', false);
-        $factory->expects($this->once())->method('create')->with($cacheIdentifier, $cacheObjectName, $backendObjectName, $backendOptions);
-        $manager->injectCacheFactory($factory);
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'frontend' => \stdClass::class,
+                'backend' => BackendFixture::class,
+                'options' => [],
+            ],
+        ];
+        $manager->setCacheConfigurations($configuration);
+        $this->expectException(InvalidCacheException::class);
+        $this->expectExceptionCode(1464550984);
+        $manager->getCache($cacheIdentifier);
+    }
+
+    /**
+     * @test
+     */
+    public function getCacheThrowsExceptionIfConfiguredBackendDoesNotImplementBackendInterface()
+    {
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'frontend' => FrontendFixture::class,
+                'backend' => \stdClass::class,
+                'options' => [],
+            ],
+        ];
         $manager->setCacheConfigurations($configuration);
+        $this->expectException(InvalidBackendException::class);
+        $this->expectExceptionCode(1464550977);
+        $manager->getCache($cacheIdentifier);
+    }
+
+    /**
+     * @test
+     */
+    public function getCacheCallsInitializeObjectOnFrontendInstance()
+    {
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'backend' => BackendFixture::class,
+                'frontend' => FrontendInitializeObjectFixture::class,
+                'options' => [],
+            ],
+        ];
+        $manager->setCacheConfigurations($configuration);
+        // BackendInitializeObjectFixture throws exception if initializeObject() is called, so expect this
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464553495);
+        $manager->getCache($cacheIdentifier);
+    }
+
+    /**
+     * @test
+     */
+    public function getCacheCallsInitializeObjectOnBackendInstance()
+    {
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'backend' => BackendInitializeObjectFixture::class,
+                'frontend' => FrontendFixture::class,
+                'options' => [],
+            ],
+        ];
+        $manager->setCacheConfigurations($configuration);
+        // BackendInitializeObjectFixture throws exception if initializeObject() is called, so expect this
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464552894);
+        $manager->getCache($cacheIdentifier);
+    }
+
+    /**
+     * @test
+     */
+    public function getCacheCreatesBackendWithGivenConfiguration()
+    {
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'backend' => BackendConfigurationOptionFixture::class,
+                'frontend' => FrontendFixture::class,
+                'options' => [
+                    'anOption' => 'anOptionValue',
+                ],
+            ],
+        ];
+        $manager->setCacheConfigurations($configuration);
+        // BackendInitializeObjectFixture throws exception if initializeObject() is called, so expect this
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464555007);
         $manager->getCache($cacheIdentifier);
     }
 
@@ -159,20 +255,24 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getCacheCreatesCacheInstanceWithFallbackToDefaultFrontend()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
+        /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|CacheManager $manager */
+        $manager = $this->getAccessibleMock(CacheManager::class, ['dummy'], [], '', false);
         $cacheIdentifier = $this->getUniqueId('Test');
-        $backendObjectName = 'testBackend';
-        $backendOptions = array('foo');
         $configuration = array(
             $cacheIdentifier => array(
-                'backend' => $backendObjectName,
-                'options' => $backendOptions
+                'backend' => BackendFixture::class,
+                'options' => []
             )
         );
-        $factory = $this->getMock(\TYPO3\CMS\Core\Cache\CacheFactory::class, array('create'), array(), '', false);
-        $factory->expects($this->once())->method('create')->with($cacheIdentifier, \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, $backendObjectName, $backendOptions);
-        $manager->injectCacheFactory($factory);
+        $defaultCacheConfiguration = [
+            'frontend' => FrontendDefaultFixture::class,
+            'options' => [],
+            'groups' => [],
+        ];
+        $manager->_set('defaultCacheConfiguration', $defaultCacheConfiguration);
         $manager->setCacheConfigurations($configuration);
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464555650);
         $manager->getCache($cacheIdentifier);
     }
 
@@ -181,42 +281,82 @@ class CacheManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getCacheCreatesCacheInstanceWithFallbackToDefaultBackend()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
+        /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|CacheManager $manager */
+        $manager = $this->getAccessibleMock(CacheManager::class, ['dummy'], [], '', false);
         $cacheIdentifier = $this->getUniqueId('Test');
-        $cacheObjectName = 'testCache';
-        $backendOptions = array('foo');
         $configuration = array(
             $cacheIdentifier => array(
-                'frontend' => $cacheObjectName,
-                'options' => $backendOptions
+                'frontend' => FrontendFixture::class,
+                'options' => []
             )
         );
-        $factory = $this->getMock(\TYPO3\CMS\Core\Cache\CacheFactory::class, array('create'), array(), '', false);
-        $factory->expects($this->once())->method('create')->with($cacheIdentifier, $cacheObjectName, \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, $backendOptions);
-        $manager->injectCacheFactory($factory);
+        $defaultCacheConfiguration = [
+            'backend' => BackendDefaultFixture::class,
+            'options' => [],
+            'groups' => [],
+        ];
+        $manager->_set('defaultCacheConfiguration', $defaultCacheConfiguration);
         $manager->setCacheConfigurations($configuration);
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464556045);
         $manager->getCache($cacheIdentifier);
     }
 
     /**
      * @test
      */
-    public function getCacheCreatesCacheInstanceWithFallbackToDefaultBackenOptions()
+    public function getCacheReturnsInstanceOfTheSpecifiedCacheFrontend()
     {
-        $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-        $cacheIdentifier = $this->getUniqueId('Test');
-        $cacheObjectName = 'testCache';
-        $backendObjectName = 'testBackend';
-        $configuration = array(
-            $cacheIdentifier => array(
-                'frontend' => $cacheObjectName,
-                'backend' => $backendObjectName
-            )
-        );
-        $factory = $this->getMock(\TYPO3\CMS\Core\Cache\CacheFactory::class, array('create'), array(), '', false);
-        $factory->expects($this->once())->method('create')->with($cacheIdentifier, $cacheObjectName, $backendObjectName, array());
-        $manager->injectCacheFactory($factory);
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'backend' => BackendFixture::class,
+                'frontend' => FrontendFixture::class,
+                'options' => [],
+            ],
+        ];
+        $manager->setCacheConfigurations($configuration);
+        $this->assertInstanceOf(FrontendFixture::class, $manager->getCache($cacheIdentifier));
+    }
+
+    /**
+     * @test
+     */
+    public function getCacheGivesIdentifierToCacheFrontend()
+    {
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'backend' => BackendFixture::class,
+                'frontend' => FrontendIdentifierFixture::class,
+                'options' => [],
+            ],
+        ];
+        $manager->setCacheConfigurations($configuration);
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464555650);
+        $manager->getCache($cacheIdentifier);
+    }
+
+    /**
+     * @test
+     */
+    public function getCacheGivesBackendInstanceToCacheFrontend()
+    {
+        $manager = new CacheManager();
+        $cacheIdentifier = 'aCache';
+        $configuration = [
+            $cacheIdentifier => [
+                'backend' => BackendFixture::class,
+                'frontend' => FrontendBackendInstanceFixture::class,
+                'options' => [],
+            ],
+        ];
         $manager->setCacheConfigurations($configuration);
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1464557160);
         $manager->getCache($cacheIdentifier);
     }
 }
diff --git a/typo3/sysext/core/Tests/Unit/Cache/FactoryTest.php b/typo3/sysext/core/Tests/Unit/Cache/FactoryTest.php
deleted file mode 100644 (file)
index d65c36f..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Unit\Cache;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Testcase for the TYPO3\CMS\Core\Cache\CacheFactory
- *
- * This file is a backport from FLOW3
- */
-class FactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
-{
-    /**
-     * @test
-     */
-    public function createReturnsInstanceOfTheSpecifiedCacheFrontend()
-    {
-        $mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array('registerCache'), array(), '', false);
-        $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
-        $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, \TYPO3\CMS\Core\Cache\Backend\NullBackend::class);
-        $this->assertInstanceOf(\TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, $cache);
-    }
-
-    /**
-     * @test
-     */
-    public function createInjectsAnInstanceOfTheSpecifiedBackendIntoTheCacheFrontend()
-    {
-        $mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array('registerCache'), array(), '', false);
-        $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
-        $cache = $factory->create('TYPO3_Cache_FactoryTest_Cache', \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, \TYPO3\CMS\Core\Cache\Backend\FileBackend::class);
-        $this->assertInstanceOf(\TYPO3\CMS\Core\Cache\Backend\FileBackend::class, $cache->getBackend());
-    }
-
-    /**
-     * @test
-     */
-    public function createRegistersTheCacheAtTheCacheManager()
-    {
-        $mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array('registerCache'), array(), '', false);
-        $mockCacheManager->expects($this->once())->method('registerCache');
-        $factory = new \TYPO3\CMS\Core\Cache\CacheFactory('Testing', $mockCacheManager);
-        $factory->create('TYPO3_Cache_FactoryTest_Cache', \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, \TYPO3\CMS\Core\Cache\Backend\FileBackend::class);
-    }
-}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendConfigurationOptionFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendConfigurationOptionFixture.php
new file mode 100644 (file)
index 0000000..eb4e6e9
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Backend fixture for CacheManager test getCacheCreatesBackendWithGivenConfiguration()
+ */
+class BackendConfigurationOptionFixture extends BackendFixture
+{
+    /**
+     * Test if constructor receives backend options
+     *
+     * @param string $context FLOW3's application context
+     * @param array $options Configuration options - depends on the actual backend
+     */
+    public function __construct($context, array $options = array())
+    {
+        $testOptions = [
+            'anOption' => 'anOptionValue',
+        ];
+        if ($options === $testOptions) {
+            // expected exception thrown
+            throw new \RuntimeException('', 1464555007);
+        }
+    }
+
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendDefaultFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendDefaultFixture.php
new file mode 100644 (file)
index 0000000..b8ad734
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+* This file is part of the TYPO3 CMS project.
+*
+* It is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, either version 2
+* of the License, or any later version.
+*
+* For the full copyright and license information, please read the
+* LICENSE.txt file that was distributed with this source code.
+*
+* The TYPO3 project - inspiring people to share!
+*/
+
+/**
+* Backend for cache manager test getCacheCreatesCacheInstanceWithFallbackToDefaultBackend
+*/
+class BackendDefaultFixture extends BackendFixture
+{
+    public function __construct()
+    {
+        throw new \RuntimeException('', 1464556045);
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendFixture.php
new file mode 100644 (file)
index 0000000..2c5e3a8
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Cache\Backend\BackendInterface;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+
+/**
+ * Backend fixture to test cache manager.
+ */
+class BackendFixture implements BackendInterface
+{
+    public function setCache(FrontendInterface $cache)
+    {
+    }
+
+    public function set($entryIdentifier, $data, array $tags = array(), $lifetime = null)
+    {
+    }
+
+    public function get($entryIdentifier)
+    {
+    }
+
+    public function has($entryIdentifier)
+    {
+    }
+
+    public function remove($entryIdentifier)
+    {
+    }
+
+    public function flush()
+    {
+    }
+
+    public function collectGarbage()
+    {
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendInitializeObjectFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/BackendInitializeObjectFixture.php
new file mode 100644 (file)
index 0000000..638aea1
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Fixture to test cache manager details
+ */
+class BackendInitializeObjectFixture extends BackendFixture
+{
+    public function initializeObject()
+    {
+        throw new \RuntimeException('', 1464552894);
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendBackendInstanceFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendBackendInstanceFixture.php
new file mode 100644 (file)
index 0000000..99cc23b
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+* This file is part of the TYPO3 CMS project.
+*
+* It is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, either version 2
+* of the License, or any later version.
+*
+* For the full copyright and license information, please read the
+* LICENSE.txt file that was distributed with this source code.
+*
+* The TYPO3 project - inspiring people to share!
+*/
+
+/**
+* Frontend for cache manager test getCacheGivesBackendInstanceToCacheFrontend
+*/
+class FrontendBackendInstanceFixture extends FrontendFixture
+{
+    public function __construct($_, $backend)
+    {
+        if ($backend instanceof BackendFixture) {
+            throw new \RuntimeException('', 1464557160);
+        }
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendDefaultFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendDefaultFixture.php
new file mode 100644 (file)
index 0000000..3ed4f39
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+* This file is part of the TYPO3 CMS project.
+*
+* It is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, either version 2
+* of the License, or any later version.
+*
+* For the full copyright and license information, please read the
+* LICENSE.txt file that was distributed with this source code.
+*
+* The TYPO3 project - inspiring people to share!
+*/
+
+/**
+* Frontend for cache manager test getCacheCreatesCacheInstanceWithFallbackToDefaultFrontend
+*/
+class FrontendDefaultFixture extends FrontendFixture
+{
+    public function __construct()
+    {
+        throw new \RuntimeException('', 1464555650);
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendFixture.php
new file mode 100644 (file)
index 0000000..c661ab5
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+* This file is part of the TYPO3 CMS project.
+*
+* It is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, either version 2
+* of the License, or any later version.
+*
+* For the full copyright and license information, please read the
+* LICENSE.txt file that was distributed with this source code.
+*
+* The TYPO3 project - inspiring people to share!
+*/
+
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+
+/**
+* Fixture implementing frontend
+*/
+class FrontendFixture implements FrontendInterface
+{
+    protected $identifier;
+
+    public function __construct($identifier)
+    {
+        $this->identifier = $identifier;
+    }
+
+    public function getIdentifier()
+    {
+        return $this->identifier;
+    }
+
+    public function getBackend()
+    {
+    }
+
+    public function set($entryIdentifier, $data, array $tags = array(), $lifetime = null)
+    {
+    }
+
+    public function get($entryIdentifier)
+    {
+    }
+
+    public function getByTag($tag)
+    {
+    }
+
+    public function has($entryIdentifier)
+    {
+    }
+
+    public function remove($entryIdentifier)
+    {
+    }
+
+    public function flush()
+    {
+    }
+
+    public function flushByTag($tag)
+    {
+    }
+
+    public function collectGarbage()
+    {
+    }
+
+    public function isValidEntryIdentifier($identifier)
+    {
+    }
+
+    public function isValidTag($tag)
+    {
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendIdentifierFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendIdentifierFixture.php
new file mode 100644 (file)
index 0000000..da764dd
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+* This file is part of the TYPO3 CMS project.
+*
+* It is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, either version 2
+* of the License, or any later version.
+*
+* For the full copyright and license information, please read the
+* LICENSE.txt file that was distributed with this source code.
+*
+* The TYPO3 project - inspiring people to share!
+*/
+
+/**
+* Frontend for cache manager test getCacheGivesIdentifierToCacheFrontend
+*/
+class FrontendIdentifierFixture extends FrontendFixture
+{
+    public function __construct($identifier)
+    {
+        if ($identifier === 'aCache') {
+            throw new \RuntimeException('', 1464555650);
+        }
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendInitializeObjectFixture.php b/typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendInitializeObjectFixture.php
new file mode 100644 (file)
index 0000000..930aad1
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Fixtures;
+
+/*
+* This file is part of the TYPO3 CMS project.
+*
+* It is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, either version 2
+* of the License, or any later version.
+*
+* For the full copyright and license information, please read the
+* LICENSE.txt file that was distributed with this source code.
+*
+* The TYPO3 project - inspiring people to share!
+*/
+
+/**
+* Fixture implementing frontend
+*/
+class FrontendInitializeObjectFixture extends FrontendFixture
+{
+    public function initializeObject()
+    {
+        throw new \RuntimeException('', 1464553495);
+    }
+}
diff --git a/typo3/sysext/core/Tests/Unit/Cache/last_synched_revision b/typo3/sysext/core/Tests/Unit/Cache/last_synched_revision
deleted file mode 100644 (file)
index a2449fd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-868e073b9877d562c6ed65a5158c1c67b3a501a8
\ No newline at end of file
index 4513bfb..7ce5f79 100644 (file)
@@ -84,9 +84,6 @@ class ClearCacheService
         // using new directly!
         $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
         $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
-        // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
-        new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
-
         $cacheManager->flushCaches();
     }