[TASK] Namespace and move t3lib unit tests - 2
authorWouter Wolters <typo3@wouterwolters.nl>
Tue, 28 Aug 2012 17:31:34 +0000 (19:31 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 28 Aug 2012 18:42:27 +0000 (20:42 +0200)
This patch moves most unit tests of the tests/Unit/t3lib/Cache
directory to the core extensio, following the new name scheme.

Change-Id: I9b6da42a4c5f9a6bfcf9218ecc76e420b340ed6c
Resolves: #40353
Related: #40095
Releases: 6.0
Reviewed-on: http://review.typo3.org/14165
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
34 files changed:
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_abstractbackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_apcbackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_filebackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_mockbackend.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_pdobackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_redisbackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackendTest.php [deleted file]
tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_wincachebackendTest.php [deleted file]
tests/Unit/t3lib/cache/class.t3lib_cache_factoryTest.php [deleted file]
tests/Unit/t3lib/cache/class.t3lib_cache_managerTest.php [deleted file]
tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontendTest.php [deleted file]
tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_phpfrontendTest.php [deleted file]
tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontendTest.php [deleted file]
tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontendTest.php [deleted file]
tests/Unit/t3lib/cache/last_synched_revision [deleted file]
typo3/sysext/core/Tests/Unit/Cache/Backend/AbstractBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/ApcBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/DbBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/FileBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/MemcachedBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/MockBackend.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/TransientMemoryBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Backend/WincacheBackendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/CacheManagerTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/FactoryTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Frontend/AbstractFrontendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Frontend/PhpFrontendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Frontend/StringFrontendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/Frontend/VariableFrontendTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Cache/last_synched_revision [new file with mode: 0644]

diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_abstractbackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_abstractbackendTest.php
deleted file mode 100644 (file)
index db6bb5c..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the abstract cache backend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_AbstractBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
-        */
-       protected $backend;
-
-       /**
-        * @return void
-        */
-       public function setUp() {
-               $className = 'ConcreteBackend_' . md5(uniqid(mt_rand(), TRUE));
-               eval(('
-                       class ' . $className) . ' extends TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend {
-                               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 flushByTag($tag) {}
-                               public function findIdentifiersByTag($tag) {}
-                               public function collectGarbage() {}
-                               public function setSomeOption($value) {
-                                       $this->someOption = $value;
-                               }
-                               public function getSomeOption() {
-                                       return $this->someOption;
-                               }
-                       }
-               ');
-               $this->backend = new $className('Testing');
-       }
-
-       /**
-        * @test
-        */
-       public function theConstructorCallsSetterMethodsForAllSpecifiedOptions() {
-               $className = get_class($this->backend);
-               $backend = new $className('Testing', array('someOption' => 'someValue'));
-               $this->assertSame('someValue', $backend->getSomeOption());
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_apcbackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_apcbackendTest.php
deleted file mode 100644 (file)
index 9df5b54..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the APC cache backend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_ApcBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Sets up this testcase
-        *
-        * @return void
-        */
-       public function setUp() {
-               if (!extension_loaded('apc')) {
-                       $this->markTestSkipped('APC extension was not available');
-               }
-               if (ini_get('apc.slam_defense') == 1) {
-                       $this->markTestSkipped('This testcase can only be executed with apc.slam_defense = Off');
-               }
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $inCache = $backend->has($identifier);
-               $this->assertTrue($inCache, 'APC backend failed to set and check entry');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData, 'APC backend failed to set and retrieve data');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, 'Failed to set and remove data from APC backend');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $otherData = 'some other data';
-               $backend->set($identifier, $otherData);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($otherData, $fetchedData, 'APC backend failed to overwrite and retrieve data');
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsSetEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
-               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
-               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
-       }
-
-       /**
-        * @test
-        */
-       public function setRemovesTagsFromPreviousSet() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tagX'));
-               $backend->set($identifier, $data, array('UnitTestTag%tag3'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
-               $this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, '"has" did not return FALSE when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $inCache = $backend->remove($identifier);
-               $this->assertFalse($inCache, '"remove" did not return FALSE when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('BackendAPCTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendAPCTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendAPCTest3', $data, array('UnitTestTag%test'));
-               $backend->flushByTag('UnitTestTag%special');
-               $this->assertTrue($backend->has('BackendAPCTest1'), 'BackendAPCTest1');
-               $this->assertFalse($backend->has('BackendAPCTest2'), 'BackendAPCTest2');
-               $this->assertTrue($backend->has('BackendAPCTest3'), 'BackendAPCTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('BackendAPCTest1', $data);
-               $backend->set('BackendAPCTest2', $data);
-               $backend->set('BackendAPCTest3', $data);
-               $backend->flush();
-               $this->assertFalse($backend->has('BackendAPCTest1'), 'BackendAPCTest1');
-               $this->assertFalse($backend->has('BackendAPCTest2'), 'BackendAPCTest2');
-               $this->assertFalse($backend->has('BackendAPCTest3'), 'BackendAPCTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
-               $thisBackend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
-               $thisBackend->setCache($thisCache);
-               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
-               $thatBackend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
-               $thatBackend->setCache($thatCache);
-               $thisBackend->set('thisEntry', 'Hello');
-               $thatBackend->set('thatEntry', 'World!');
-               $thatBackend->flush();
-               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
-               $this->assertFalse($thatBackend->has('thatEntry'));
-       }
-
-       /**
-        * Check if we can store ~5 MB of data
-        *
-        * @test
-        */
-       public function largeDataIsStored() {
-               $backend = $this->setUpBackend();
-               $data = str_repeat('abcde', 1024 * 1024);
-               $identifier = 'tooLargeData' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $this->assertTrue($backend->has($identifier));
-               $this->assertEquals($backend->get($identifier), $data);
-       }
-
-       /**
-        * Sets up the APC backend used for testing
-        *
-        * @return \TYPO3\CMS\Core\Cache\Backend\ApcBackend
-        */
-       protected function setUpBackend() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
-               $backend->setCache($cache);
-               return $backend;
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php
deleted file mode 100644 (file)
index c462ec3..0000000
+++ /dev/null
@@ -1,517 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the DB cache backend
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_DbBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Enable backup of global and system variables
-        *
-        * @var boolean
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection Backup of original TYPO3_DB instance
-        */
-       protected $typo3DbBackup;
-
-       /**
-        * @var string Name of the testing data table
-        */
-       protected $testingCacheTable;
-
-       /**
-        * @var string Name of the testing tags table
-        */
-       protected $testingTagsTable;
-
-       /**
-        * Set up testcases
-        */
-       public function setUp() {
-               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
-               $tablePrefix = 'cf_';
-               $this->testingCacheTable = $tablePrefix . 'Testing';
-               $this->testingTagsTable = $tablePrefix . 'Testing_tags';
-       }
-
-       /**
-        * Sets up the backend used for testing
-        *
-        * @return void
-        */
-       protected function setUpBackend(array $backendOptions = array()) {
-               $GLOBALS['TYPO3_DB']->sql_query(('CREATE TABLE ' . $this->testingCacheTable) . ' (
-                       id int(11) unsigned NOT NULL auto_increment,
-                       identifier varchar(250) DEFAULT \'\' NOT NULL,
-                       expires int(11) unsigned DEFAULT \'0\' NOT NULL,
-                       content mediumblob,
-                       PRIMARY KEY (id),
-                       KEY cache_id (identifier, expires)
-               ) ENGINE=InnoDB;
-               ');
-               $GLOBALS['TYPO3_DB']->sql_query(('CREATE TABLE ' . $this->testingTagsTable) . ' (
-                       id int(11) unsigned NOT NULL auto_increment,
-                       identifier varchar(250) DEFAULT \'\' NOT NULL,
-                       tag varchar(250) DEFAULT \'\' NOT NULL,
-                       PRIMARY KEY (id),
-                       KEY cache_id (identifier),
-                       KEY cache_tag (tag)
-               ) ENGINE=InnoDB;
-               ');
-               $backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend', 'Testing', $backendOptions);
-               return $backend;
-       }
-
-       /**
-        * Helper method to inject a mock frontend to backend instance
-        *
-        * @param \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend $backend Current backend instance
-        * @return \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface Mock frontend
-        */
-       protected function setUpMockFrontendOfBackend(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend $backend) {
-               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('Testing'));
-               $backend->setCache($mockCache);
-               return $mockCache;
-       }
-
-       /**
-
-        */
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
-               $GLOBALS['TYPO3_DB']->sql_query(('DROP TABLE IF EXISTS ' . $this->testingCacheTable) . ';');
-               $GLOBALS['TYPO3_DB']->sql_query(('DROP TABLE IF EXISTS ' . $this->testingTagsTable) . ';');
-       }
-
-       /**
-        * @test
-        */
-       public function setCacheCalculatesCacheTableName() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $this->assertEquals($this->testingCacheTable, $backend->getCacheTable());
-       }
-
-       /**
-        * @test
-        */
-       public function setCacheCalculatesTagsTableName() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $this->assertEquals($this->testingTagsTable, $backend->getTagsTable());
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function setThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->set('identifier', 'data');
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
-        */
-       public function setThrowsExceptionIfDataIsNotAString() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = array('Some data');
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-       }
-
-       /**
-        * @test
-        */
-       public function setInsertsEntryInTable() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $this->assertEquals($data, $entryFound['content']);
-       }
-
-       /**
-        * @test
-        */
-       public function setRemovesAnAlreadyExistingCacheEntryForTheSameIdentifier() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data1 = 'some data' . microtime();
-               $data2 = $data1 . '_different';
-               $entryIdentifier = 'BackendDbRemoveBeforeSetTest';
-               $backend->set($entryIdentifier, $data1, array(), 500);
-               $backend->set($entryIdentifier, $data2, array(), 200);
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $this->assertEquals(1, count($entriesFound));
-       }
-
-       /**
-        * @test
-        */
-       public function setReallySavesSpecifiedTags() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingTagsTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $tags = array();
-               foreach ($entriesFound as $entry) {
-                       $tags[] = $entry['tag'];
-               }
-               $this->assertTrue(count($tags) > 0);
-               $this->assertTrue(in_array('UnitTestTag%tag1', $tags));
-               $this->assertTrue(in_array('UnitTestTag%tag2', $tags));
-       }
-
-       /**
-        * @test
-        */
-       public function setSavesCompressedDataWithEnabledCompression() {
-               $backend = $this->setUpBackend(array(
-                       'compression' => TRUE
-               ));
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data ' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('content', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $this->assertEquals($data, @gzuncompress($entry['content']));
-       }
-
-       /**
-        * @test
-        */
-       public function setSavesPlaintextDataWithEnabledCompressionAndCompressionLevel0() {
-               $backend = $this->setUpBackend(array(
-                       'compression' => TRUE,
-                       'compressionLevel' => 0
-               ));
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data ' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('content', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $this->assertGreaterThan(0, substr_count($entry['content'], $data));
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function getThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->get('identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function getReturnsContentOfTheCorrectCacheEntry() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data, array(), 500);
-               $data = 'some other data' . microtime();
-               $backend->set($entryIdentifier, $data, array(), 100);
-               $loadedData = $backend->get($entryIdentifier);
-               $this->assertEquals($data, $loadedData);
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function hasThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->has('identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsTheCorrectResult() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-               $this->assertTrue($backend->has($entryIdentifier));
-               $this->assertFalse($backend->has($entryIdentifier . 'Not'));
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function removeThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->remove('identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function removeReallyRemovesACacheEntry() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemovalTest';
-               $backend->set($entryIdentifier, $data);
-               $backend->remove($entryIdentifier);
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $this->assertTrue(count($entriesFound) == 0);
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function collectGarbageThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->collectGarbage();
-       }
-
-       /**
-        * @test
-        */
-       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
-               $backend = $this->setUpBackend();
-               $mockCache = $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemovalTest';
-               $backend->set($entryIdentifier, $data, array(), 1);
-               $GLOBALS['EXEC_TIME'] += 2;
-               // setCache calls initializeCommonReferences which recalculate expire statement
-               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
-               $backend->setCache($mockCache);
-               $backend->collectGarbage();
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
-               $this->assertTrue(count($entriesFound) == 0);
-       }
-
-       /**
-        * @test
-        */
-       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
-               $backend = $this->setUpBackend();
-               $mockCache = $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemovalTest';
-               $backend->set($entryIdentifier . 'A', $data, array(), 1);
-               $backend->set($entryIdentifier . 'B', $data, array(), 1);
-               $backend->set($entryIdentifier . 'C', $data, array(), 1);
-               $GLOBALS['EXEC_TIME'] += 2;
-               // setCache calls initializeCommonReferences which recalculate expire statement
-               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
-               $backend->setCache($mockCache);
-               $backend->collectGarbage();
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, '');
-               $this->assertTrue(count($entriesFound) == 0);
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
-               $expectedEntry = 'BackendDbTest2';
-               $actualEntries = $backend->findIdentifiersByTag('UnitTestTag%special');
-               $this->assertTrue(is_array($actualEntries));
-               $this->assertEquals($expectedEntry, array_pop($actualEntries));
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function flushThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->flush();
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $backend->set('BackendDbTest1', $data, array('UnitTestTag%test'));
-               $backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
-               $backend->flush();
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, '');
-               $this->assertTrue(count($entriesFound) == 0);
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function flushByTagThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->flushByTag(array());
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
-               $backend->flushByTag('UnitTestTag%special');
-               $this->assertTrue($backend->has('BackendDbTest1'), 'BackendDbTest1 does not exist anymore.');
-               $this->assertFalse($backend->has('BackendDbTest2'), 'BackendDbTest2 still exists.');
-               $this->assertTrue($backend->has('BackendDbTest3'), 'BackendDbTest3 does not exist anymore.');
-               $tagEntriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingTagsTable, 'tag = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('UnitTestTag%special', $this->testingTagsTable));
-               $this->assertEquals(0, count($tagEntriesFound));
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsTheCorrectResultForEntryWithExceededLifetime() {
-               $backend = $this->setUpBackend();
-               $mockCache = $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
-               $expiredData = 'some old data' . microtime();
-               $backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
-               $GLOBALS['EXEC_TIME'] += 2;
-               // setCache calls initializeCommonReferences which recalculate expire statement
-               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
-               $backend->setCache($mockCache);
-               $this->assertFalse($backend->has($expiredEntryIdentifier));
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsTrueForEntryWithUnlimitedLifetime() {
-               $backend = $this->setUpBackend();
-               $mockCache = $this->setUpMockFrontendOfBackend($backend);
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, 'data', array(), 0);
-               $GLOBALS['EXEC_TIME'] += 1;
-               // setCache calls initializeCommonReferences which recalculate expire statement
-               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
-               $backend->setCache($mockCache);
-               $this->assertTrue($backend->has($entryIdentifier));
-       }
-
-       /**
-        * @test
-        */
-       public function getReturnsFalseForEntryWithExceededLifetime() {
-               $backend = $this->setUpBackend();
-               $mockCache = $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-               $backend->set($entryIdentifier, $data);
-               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
-               $expiredData = 'some old data' . microtime();
-               $backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
-               $GLOBALS['EXEC_TIME'] += 2;
-               // setCache calls initializeCommonReferences which recalculate expire statement
-               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
-               $backend->setCache($mockCache);
-               $this->assertEquals($data, $backend->get($entryIdentifier));
-               $this->assertFalse($backend->get($expiredEntryIdentifier));
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function findIdentifiersByTagThrowsExceptionIfFrontendWasNotSet() {
-               $backend = $this->setUpBackend();
-               $backend->findIdentifiersByTag('identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagReturnsEmptyArrayForEntryWithExceededLifetime() {
-               $backend = $this->setUpBackend();
-               $mockCache = $this->setUpMockFrontendOfBackend($backend);
-               $backend->set('BackendDbTest', 'some data', array('UnitTestTag%special'), 1);
-               $GLOBALS['EXEC_TIME'] += 2;
-               // setCache calls initializeCommonReferences which recalculate expire statement
-               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
-               $backend->setCache($mockCache);
-               $this->assertEquals(array(), $backend->findIdentifiersByTag('UnitTestTag%special'));
-       }
-
-       /**
-        * @test
-        */
-       public function setWithUnlimitedLifetimeWritesCorrectEntry() {
-               $backend = $this->setUpBackend();
-               $this->setUpMockFrontendOfBackend($backend);
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileTest';
-               $backend->set($entryIdentifier, $data, array(), 0);
-               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->testingCacheTable, '');
-               $this->assertTrue(is_array($entryFound));
-               $retrievedData = $entryFound['content'];
-               $this->assertEquals($data, $retrievedData);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_filebackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_filebackendTest.php
deleted file mode 100644 (file)
index bb34bef..0000000
+++ /dev/null
@@ -1,620 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Testcase for the File cache backend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_FileBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Enable backup of global and system variables
-        *
-        * @var boolean
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serialization
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /**
-        * Sets up this testcase
-        *
-        * @return void
-        */
-       public function setUp() {
-               if (!class_exists('\vfsStreamWrapper')) {
-                       $this->markTestSkipped('File backend tests are not available with this phpunit version.');
-               }
-
-               \vfsStreamWrapper::register();
-               \vfsStreamWrapper::setRoot(new \vfsStreamDirectory('Foo'));
-       }
-
-       /**
-        * @test
-        * @expectedException \t3lib_cache_Exception
-        */
-       public function setCacheDirectoryThrowsExceptionOnNonWritableDirectory() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('http://localhost/');
-
-               $backend->setCache($mockCache);
-       }
-
-       /**
-        * @test
-        */
-       public function getCacheDirectoryReturnsTheCurrentCacheDirectory() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $this->assertEquals('vfs://Foo/Cache/Data/SomeCache/', $backend->getCacheDirectory());
-       }
-
-       /**
-        * @test
-        */
-       public function aDedicatedCacheDirectoryIsUsedForCodeCaches() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_PhpFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $this->assertEquals('vfs://Foo/Cache/Code/SomeCache/', $backend->getCacheDirectory());
-       }
-
-       /**
-        * @test
-        * @expectedException t3lib_cache_exception_InvalidData
-        */
-       public function setThrowsExceptionIfDataIsNotAString() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set('some identifier', array('not a string'));
-       }
-
-       /**
-        * @test
-        */
-       public function setReallySavesToTheSpecifiedDirectory() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileTest';
-               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set($entryIdentifier, $data);
-
-               $this->assertFileExists($pathAndFilename);
-               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data));
-               $this->assertEquals($data, $retrievedData);
-       }
-
-       /**
-        * @test
-        */
-       public function setOverwritesAnAlreadyExistingCacheEntryForTheSameIdentifier() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $data1 = 'some data' . microtime();
-               $data2 = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileRemoveBeforeSetTest';
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set($entryIdentifier, $data1, array(), 500);
-               $backend->set($entryIdentifier, $data2, array(), 200);
-
-               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
-               $this->assertFileExists($pathAndFilename);
-               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data2));
-               $this->assertEquals($data2, $retrievedData);
-       }
-
-       /**
-        * @test
-        */
-       public function setAlsoSavesSpecifiedTags() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileRemoveBeforeSetTest';
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set($entryIdentifier, $data, array('Tag1', 'Tag2'));
-
-               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
-               $this->assertFileExists($pathAndFilename);
-               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, (strlen($data) + t3lib_cache_backend_FileBackend::EXPIRYTIME_LENGTH), 9);
-               $this->assertEquals('Tag1 Tag2', $retrievedData);
-       }
-
-       /**
-        * @test
-        */
-       public function setCacheDetectsAndLoadsAFrozenCache() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileTest';
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set($entryIdentifier, $data, array('Tag1', 'Tag2'));
-
-               $backend->freeze();
-
-               unset($backend);
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $this->assertTrue($backend->isFrozen());
-               $this->assertEquals($data, $backend->get($entryIdentifier));
-       }
-
-       /**
-        * @test
-        */
-       public function getReturnsContentOfTheCorrectCacheFile() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('setTag'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $entryIdentifier = 'BackendFileTest';
-
-               $data = 'some data' . microtime();
-               $backend->set($entryIdentifier, $data, array(), 500);
-
-               $data = 'some other data' . microtime();
-               $backend->set($entryIdentifier, $data, array(), 100);
-
-               $loadedData = $backend->get($entryIdentifier);
-               $this->assertEquals($data, $loadedData);
-       }
-
-       /**
-        * @test
-        */
-       public function getReturnsFalseForExpiredEntries() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
-               $backend->expects($this->once())->method('isCacheFileExpired')->with('vfs://Foo/Cache/Data/UnitTestCache/ExpiredEntry')->will($this->returnValue(TRUE));
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $this->assertFalse($backend->get('ExpiredEntry'));
-       }
-
-       /**
-        * @test
-        */
-       public function getDoesNotCheckIfAnEntryIsExpiredIfTheCacheIsFrozen() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->expects($this->once())->method('isCacheFileExpired');
-
-               $backend->set('foo', 'some data');
-               $backend->freeze();
-               $this->assertEquals('some data', $backend->get('foo'));
-               $this->assertFalse($backend->get('bar'));
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsTrueIfAnEntryExists() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $entryIdentifier = 'BackendFileTest';
-
-               $data = 'some data' . microtime();
-               $backend->set($entryIdentifier, $data);
-
-               $this->assertTrue($backend->has($entryIdentifier), 'has() did not return TRUE.');
-               $this->assertFalse($backend->has($entryIdentifier . 'Not'), 'has() did not return FALSE.');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsFalseForExpiredEntries() {
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
-               $backend->expects($this->exactly(2))->method('isCacheFileExpired')->will($this->onConsecutiveCalls(TRUE, FALSE));
-
-               $this->assertFalse($backend->has('foo'));
-               $this->assertTrue($backend->has('bar'));
-       }
-
-       /**
-        * @test
-        */
-       public function hasDoesNotCheckIfAnEntryIsExpiredIfTheCacheIsFrozen() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->expects($this->once())->method('isCacheFileExpired'); // Indirectly called by freeze() -> get()
-
-               $backend->set('foo', 'some data');
-               $backend->freeze();
-               $this->assertTrue($backend->has('foo'));
-               $this->assertFalse($backend->has('bar'));
-       }
-
-       /**
-        * @test
-        */
-       public function removeReallyRemovesACacheEntry() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileTest';
-               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set($entryIdentifier, $data);
-               $this->assertFileExists($pathAndFilename);
-
-               $backend->remove($entryIdentifier);
-               $this->assertFileNotExists($pathAndFilename);
-       }
-
-       /**
-        */
-       public function invalidEntryIdentifiers() {
-               return array(
-                       'trailing slash' => array('/myIdentifer'),
-                       'trailing dot and slash' => array('./myIdentifer'),
-                       'trailing two dots and slash' => array('../myIdentifier'),
-                       'trailing with multiple dots and slashes' => array('.././../myIdentifier'),
-                       'slash in middle part' => array('my/Identifier'),
-                       'dot and slash in middle part' => array('my./Identifier'),
-                       'two dots and slash in middle part' => array('my../Identifier'),
-                       'multiple dots and slashes in middle part' => array('my.././../Identifier'),
-                       'pending slash' => array('myIdentifier/'),
-                       'pending dot and slash' => array('myIdentifier./'),
-                       'pending dots and slash' => array('myIdentifier../'),
-                       'pending multiple dots and slashes' => array('myIdentifier.././../'),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        */
-       public function setThrowsExceptionForInvalidIdentifier($identifier) {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array('test'), '', TRUE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->set($identifier, 'cache data', array());
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        */
-       public function getThrowsExceptionForInvalidIdentifier($identifier) {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->get($identifier);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        */
-       public function hasThrowsExceptionForInvalidIdentifier($identifier) {
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-
-               $backend->has($identifier);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        */
-       public function removeThrowsExceptionForInvalidIdentifier($identifier) {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->remove($identifier);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        */
-       public function requireOnceThrowsExceptionForInvalidIdentifier($identifier) {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->requireOnce($identifier);
-       }
-
-       /**
-        * @test
-        */
-       public function requireOnceIncludesAndReturnsResultOfIncludedPhpFile() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $entryIdentifier = 'SomePhpEntry';
-
-               $data = '<?php return "foo"; ?>';
-               $backend->set($entryIdentifier, $data);
-
-               $loadedData = $backend->requireOnce($entryIdentifier);
-               $this->assertEquals('foo', $loadedData);
-       }
-
-       /**
-        * @test
-        */
-       public function requireOnceDoesNotCheckExpiryTimeIfBackendIsFrozen() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-                               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->expects($this->once())->method('isCacheFileExpired'); // Indirectly called by freeze() -> get()
-
-               $data = '<?php return "foo"; ?>';
-               $backend->set('FooEntry', $data);
-
-               $backend->freeze();
-
-               $loadedData = $backend->requireOnce('FooEntry');
-               $this->assertEquals('foo', $loadedData);
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $data = 'some data' . microtime();
-               $backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
-
-               $expectedEntry = 'BackendFileTest2';
-
-               $actualEntries = $backend->findIdentifiersByTag('UnitTestTag%special');
-               $this->assertInternalType('array', $actualEntries);
-               $this->assertEquals($expectedEntry, array_pop($actualEntries));
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagDoesNotReturnExpiredEntries() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $data = 'some data';
-               $backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'), -100);
-               $backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
-
-               $this->assertSame(array(), $backend->findIdentifiersByTag('UnitTestTag%special'));
-               $this->assertSame(array('BackendFileTest1', 'BackendFileTest3'), $backend->findIdentifiersByTag('UnitTestTag%test'));
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $data = 'some data';
-               $backend->set('BackendFileTest1', $data);
-               $backend->set('BackendFileTest2', $data);
-
-               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
-
-               $backend->flush();
-
-               $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-               $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
-       }
-
-       /**
-        * @test
-        */
-       public function flushCreatesCacheDirectoryAgain() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->flush();
-               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/');
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('findIdentifiersByTag', 'remove'), array(), '', FALSE);
-
-               $backend->expects($this->once())->method('findIdentifiersByTag')->with('UnitTestTag%special')->will($this->returnValue(array('foo', 'bar', 'baz')));
-               $backend->expects($this->at(1))->method('remove')->with('foo');
-               $backend->expects($this->at(2))->method('remove')->with('bar');
-               $backend->expects($this->at(3))->method('remove')->with('baz');
-
-               $backend->flushByTag('UnitTestTag%special');
-       }
-
-       /**
-        * @test
-        */
-       public function collectGarbageRemovesExpiredCacheEntries() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
-               $backend->expects($this->exactly(2))->method('isCacheFileExpired')->will($this->onConsecutiveCalls(TRUE, FALSE));
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $data = 'some data';
-               $backend->set('BackendFileTest1', $data);
-               $backend->set('BackendFileTest2', $data);
-
-               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
-
-               $backend->collectGarbage();
-               $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
-               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
-       }
-
-       /**
-        * @test
-        */
-       public function flushUnfreezesTheCache() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-               $backend->setCacheDirectory('vfs://Foo/');
-               $backend->setCache($mockCache);
-
-               $backend->freeze();
-
-               $this->assertTrue($backend->isFrozen());
-               $backend->flush();
-               $this->assertFalse($backend->isFrozen());
-       }
-}
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackendTest.php
deleted file mode 100644 (file)
index a73897f..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the cache to memcached backend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_MemcachedBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Sets up this testcase
-        *
-        * @return void
-        */
-       public function setUp() {
-               if (!extension_loaded('memcache')) {
-                       $this->markTestSkipped('memcache extension was not available');
-               }
-               try {
-                       if (!fsockopen('localhost', 11211)) {
-                               $this->markTestSkipped('memcached not reachable');
-                       }
-               } catch (\Exception $e) {
-                       $this->markTestSkipped('memcached not reachable');
-               }
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backendOptions = array('servers' => array('localhost:11211'));
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
-               $backend->initializeObject();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function initializeObjectThrowsExceptionIfNoMemcacheServerIsConfigured() {
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing');
-               $backend->initializeObject();
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $inCache = $backend->has($identifier);
-               $this->assertTrue($inCache, 'Memcache failed to set and check entry');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData, 'Memcache failed to set and retrieve data');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, 'Failed to set and remove data from Memcache');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $otherData = 'some other data';
-               $backend->set($identifier, $otherData);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($otherData, $fetchedData, 'Memcache failed to overwrite and retrieve data');
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
-               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
-               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
-       }
-
-       /**
-        * @test
-        */
-       public function setRemovesTagsFromPreviousSet() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $backend->set($identifier, $data, array('UnitTestTag%tag3'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
-               $this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, '"has" did not return FALSE when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $inCache = $backend->remove($identifier);
-               $this->assertFalse($inCache, '"remove" did not return FALSE when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('BackendMemcacheTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendMemcacheTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendMemcacheTest3', $data, array('UnitTestTag%test'));
-               $backend->flushByTag('UnitTestTag%special');
-               $this->assertTrue($backend->has('BackendMemcacheTest1'), 'BackendMemcacheTest1');
-               $this->assertFalse($backend->has('BackendMemcacheTest2'), 'BackendMemcacheTest2');
-               $this->assertTrue($backend->has('BackendMemcacheTest3'), 'BackendMemcacheTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('BackendMemcacheTest1', $data);
-               $backend->set('BackendMemcacheTest2', $data);
-               $backend->set('BackendMemcacheTest3', $data);
-               $backend->flush();
-               $this->assertFalse($backend->has('BackendMemcacheTest1'), 'BackendMemcacheTest1');
-               $this->assertFalse($backend->has('BackendMemcacheTest2'), 'BackendMemcacheTest2');
-               $this->assertFalse($backend->has('BackendMemcacheTest3'), 'BackendMemcacheTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $backendOptions = array('servers' => array('localhost:11211'));
-               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
-               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
-               $thisBackend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
-               $thisBackend->setCache($thisCache);
-               $thisBackend->initializeObject();
-               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
-               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
-               $thatBackend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
-               $thatBackend->setCache($thatCache);
-               $thatBackend->initializeObject();
-               $thisBackend->set('thisEntry', 'Hello');
-               $thatBackend->set('thatEntry', 'World!');
-               $thatBackend->flush();
-               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
-               $this->assertFalse($thatBackend->has('thatEntry'));
-       }
-
-       /**
-        * Check if we can store ~5 MB of data, this gives some headroom for the
-        * reflection data.
-        *
-        * @test
-        */
-       public function largeDataIsStored() {
-               $backend = $this->setUpBackend();
-               $data = str_repeat('abcde', 1024 * 1024);
-               $backend->set('tooLargeData', $data);
-               $this->assertTrue($backend->has('tooLargeData'));
-               $this->assertEquals($backend->get('tooLargeData'), $data);
-       }
-
-       /**
-        * Sets up the memcached backend used for testing
-        *
-        * @param array $backendOptions Options for the memcache backend
-        * @return \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend
-        */
-       protected function setUpBackend(array $backendOptions = array()) {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               if ($backendOptions == array()) {
-                       $backendOptions = array('servers' => array('localhost:11211'));
-               }
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
-               $backend->setCache($cache);
-               $backend->initializeObject();
-               return $backend;
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_mockbackend.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_mockbackend.php
deleted file mode 100644 (file)
index a7ea7d8..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * A caching backend which forgets everything immediately
- * Used in t3lib_cache_FactoryTestCase
- *
- * This file is a backport from FLOW3
- *
- * @author Robert Lemke <robert@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_MockBackend extends \TYPO3\CMS\Core\Cache\Backend\NullBackend {
-
-       /**
-        * @var mixed
-        */
-       protected $someOption;
-
-       /**
-        * Sets some option
-        *
-        * @param mixed $value
-        * @return void
-        */
-       public function setSomeOption($value) {
-               $this->someOption = $value;
-       }
-
-       /**
-        * Returns the option value
-        *
-        * @return mixed
-        */
-       public function getSomeOption() {
-               return $this->someOption;
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_pdobackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_pdobackendTest.php
deleted file mode 100644 (file)
index 6965a7d..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the PDO cache backend
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_PdoBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Enable backup of global and system variables
-        *
-        * @var boolean
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /**
-        * Sets up this testcase
-        */
-       public function setUp() {
-               if (!extension_loaded('pdo_sqlite')) {
-                       $this->markTestSkipped('pdo_sqlite extension was not available');
-               }
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\PdoBackend('Testing');
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $this->assertTrue($backend->has($identifier));
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $this->assertFalse($backend->has($identifier));
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $otherData = 'some other data';
-               $backend->set($identifier, $otherData);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($otherData, $fetchedData);
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsSetEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $entryIdentifier = 'MyIdentifier';
-               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
-               $this->assertEquals($entryIdentifier, $retrieved[0]);
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
-               $this->assertEquals($entryIdentifier, $retrieved[0]);
-       }
-
-       /**
-        * @test
-        */
-       public function setRemovesTagsFromPreviousSet() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $entryIdentifier = 'MyIdentifier';
-               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag3'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
-               $this->assertEquals(array(), $retrieved);
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier';
-               $this->assertFalse($backend->has($identifier));
-       }
-
-       /**
-        * @test
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier';
-               $this->assertFalse($backend->remove($identifier));
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('PdoBackendTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('PdoBackendTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('PdoBackendTest3', $data, array('UnitTestTag%test'));
-               $backend->flushByTag('UnitTestTag%special');
-               $this->assertTrue($backend->has('PdoBackendTest1'), 'PdoBackendTest1');
-               $this->assertFalse($backend->has('PdoBackendTest2'), 'PdoBackendTest2');
-               $this->assertTrue($backend->has('PdoBackendTest3'), 'PdoBackendTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('PdoBackendTest1', $data);
-               $backend->set('PdoBackendTest2', $data);
-               $backend->set('PdoBackendTest3', $data);
-               $backend->flush();
-               $this->assertFalse($backend->has('PdoBackendTest1'), 'PdoBackendTest1');
-               $this->assertFalse($backend->has('PdoBackendTest2'), 'PdoBackendTest2');
-               $this->assertFalse($backend->has('PdoBackendTest3'), 'PdoBackendTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
-               $thisBackend = $this->setUpBackend();
-               $thisBackend->setCache($thisCache);
-               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
-               $thatBackend = $this->setUpBackend();
-               $thatBackend->setCache($thatCache);
-               $thisBackend->set('thisEntry', 'Hello');
-               $thatBackend->set('thatEntry', 'World!');
-               $thatBackend->flush();
-               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
-               $this->assertFalse($thatBackend->has('thatEntry'));
-       }
-
-       /**
-        * @test
-        */
-       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendPDORemovalTest';
-               $backend->set($entryIdentifier, $data, array(), 1);
-               $this->assertTrue($backend->has($entryIdentifier));
-               $GLOBALS['EXEC_TIME'] += 2;
-               $backend->collectGarbage();
-               $this->assertFalse($backend->has($entryIdentifier));
-       }
-
-       /**
-        * @test
-        */
-       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendPDORemovalTest';
-               $backend->set($entryIdentifier . 'A', $data, array(), NULL);
-               $backend->set($entryIdentifier . 'B', $data, array(), 10);
-               $backend->set($entryIdentifier . 'C', $data, array(), 1);
-               $backend->set($entryIdentifier . 'D', $data, array(), 1);
-               $this->assertTrue($backend->has($entryIdentifier . 'A'));
-               $this->assertTrue($backend->has($entryIdentifier . 'B'));
-               $this->assertTrue($backend->has($entryIdentifier . 'C'));
-               $this->assertTrue($backend->has($entryIdentifier . 'D'));
-               $GLOBALS['EXEC_TIME'] += 2;
-               $backend->collectGarbage();
-               $this->assertTrue($backend->has($entryIdentifier . 'A'));
-               $this->assertTrue($backend->has($entryIdentifier . 'B'));
-               $this->assertFalse($backend->has($entryIdentifier . 'C'));
-               $this->assertFalse($backend->has($entryIdentifier . 'D'));
-       }
-
-       /**
-        * Sets up the PDO backend used for testing
-        *
-        * @return \TYPO3\CMS\Core\Cache\Backend\PdoBackend
-        */
-       protected function setUpBackend() {
-               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
-               $backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\Backend\\PdoBackend', 'Testing');
-               $backend->setCache($mockCache);
-               $backend->setDataSourceName('sqlite::memory:');
-               $backend->initializeObject();
-               return $backend;
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_redisbackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_redisbackendTest.php
deleted file mode 100644 (file)
index a1560dc..0000000
+++ /dev/null
@@ -1,835 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the cache to redis backend
- *
- * This class has functional tests as well as implementation tests:
- * - The functional tests make API calls to the backend and check expected behaviour
- * - The implementation tests make additional calls with an own redis instance to
- * check stored data structures in the redis server, which can not be checked
- * by functional tests alone. Those tests will fail if any changes
- * to the internal data structure are done.
- *
- * Warning:
- * The unit tests use and flush redis database numbers 0 and 1!
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_RedisBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Enable backup of global and system variables
-        *
-        * @var boolean
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
-        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
-        * because resource types cannot be handled during serializing
-        *
-        * @var array
-        */
-       protected $backupGlobalsBlacklist = array('TYPO3_DB');
-
-       /**
-        * If set, the tearDown() method will flush the cache used by this unit test.
-        *
-        * @var \TYPO3\CMS\Core\Cache\Backend\RedisBackend
-        */
-       protected $backend = NULL;
-
-       /**
-        * Own redis instance used in implementation tests
-        *
-        * @var Redis
-        */
-       protected $redis = NULL;
-
-       /**
-        * Set up this testcase
-        */
-       public function setUp() {
-               if (!extension_loaded('redis')) {
-                       $this->markTestSkipped('redis extension was not available');
-               }
-               try {
-                       if (!@fsockopen('127.0.0.1', 6379)) {
-                               $this->markTestSkipped('redis server not reachable');
-                       }
-               } catch (\Exception $e) {
-                       $this->markTestSkipped('redis server not reachable');
-               }
-       }
-
-       /**
-        * Sets up the redis backend used for testing
-        *
-        * @param array $backendOptions Options for the redis backend
-        */
-       protected function setUpBackend(array $backendOptions = array()) {
-               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
-               $this->backend = new \TYPO3\CMS\Core\Cache\Backend\RedisBackend('Testing', $backendOptions);
-               $this->backend->setCache($mockCache);
-               $this->backend->initializeObject();
-       }
-
-       /**
-        * Sets up an own redis instance for implementation tests
-        */
-       protected function setUpRedis() {
-               $this->redis = new \Redis();
-               $this->redis->connect('127.0.0.1', 6379);
-       }
-
-       /**
-        * Tear down this testcase
-        */
-       public function tearDown() {
-               if ($this->backend instanceof \TYPO3\CMS\Core\Cache\Backend\RedisBackend) {
-                       $this->backend->flush();
-               }
-       }
-
-       /**
-        * @test Functional
-        */
-       public function initializeObjectThrowsNoExceptionIfGivenDatabaseWasSuccessfullySelected() {
-               try {
-                       $this->setUpBackend(array('database' => 1));
-               } catch (Exception $e) {
-                       $this->assertTrue();
-               }
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNotAnInteger() {
-               $this->setUpBackend(array('database' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNegative() {
-               $this->setUpBackend(array('database' => -1));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setCompressionThrowsExceptionIfCompressionParameterIsNotOfTypeBoolean() {
-               $this->setUpBackend(array('compression' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotInteger() {
-               $this->setUpBackend(array('compressionLevel' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotBetweenMinusOneAndNine() {
-               $this->setUpBackend(array('compressionLevel' => 11));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->set(array(), 'data');
-       }
-
-       /**
-        * @test Functional
-        * @expectedException t3lib_cache_Exception_InvalidData
-        */
-       public function setThrowsExceptionIfDataIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->set('identifier' . uniqid(), array());
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setThrowsExceptionIfLifetimeIsNegative() {
-               $this->setUpBackend();
-               $this->backend->set('identifier' . uniqid(), 'data', array(), -42);
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function setThrowsExceptionIfLifetimeIsNotNullOrAnInteger() {
-               $this->setUpBackend();
-               $this->backend->set('identifier' . uniqid(), 'data', array(), array());
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setStoresEntriesInSelectedDatabase() {
-               $this->setUpRedis();
-               $this->redis->select(1);
-               $this->setUpBackend(array('database' => 1));
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->assertTrue($this->redis->exists('identData:' . $identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesStringDataTypeForIdentifierToDataEntry() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->assertSame(\Redis::REDIS_STRING, $this->redis->type('identData:' . $identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesEntryWithDefaultLifeTime() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $defaultLifetime = 42;
-               $this->backend->setDefaultLifetime($defaultLifetime);
-               $this->backend->set($identifier, 'data');
-               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
-               $this->assertSame($defaultLifetime, $lifetimeRegisteredInBackend);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesEntryWithSpecifiedLifeTime() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $lifetime = 43;
-               $this->backend->set($identifier, 'data', array(), $lifetime);
-               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
-               $this->assertSame($lifetime, $lifetimeRegisteredInBackend);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesEntryWithUnlimitedLifeTime() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data', array(), 0);
-               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
-               $this->assertSame(31536000, $lifetimeRegisteredInBackend);
-       }
-
-       /**
-        * @test Functional
-        */
-       public function setOverwritesExistingEntryWithNewData() {
-               $this->setUpBackend();
-               $data = 'data 1';
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, $data);
-               $otherData = 'data 2';
-               $this->backend->set($identifier, $otherData);
-               $fetchedData = $this->backend->get($identifier);
-               $this->assertSame($otherData, $fetchedData);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setOverwritesExistingEntryWithSpecifiedLifetime() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $data = 'data';
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, $data);
-               $lifetime = 42;
-               $this->backend->set($identifier, $data, array(), $lifetime);
-               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
-               $this->assertSame($lifetime, $lifetimeRegisteredInBackend);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setOverwritesExistingEntryWithNewDefaultLifetime() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $data = 'data';
-               $identifier = 'identifier' . uniqid();
-               $lifetime = 42;
-               $this->backend->set($identifier, $data, array(), $lifetime);
-               $newDefaultLifetime = 43;
-               $this->backend->setDefaultLifetime($newDefaultLifetime);
-               $this->backend->set($identifier, $data, array(), $newDefaultLifetime);
-               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
-               $this->assertSame($newDefaultLifetime, $lifetimeRegisteredInBackend);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setOverwritesExistingEntryWithNewUnlimitedLifetime() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $data = 'data';
-               $identifier = 'identifier' . uniqid();
-               $lifetime = 42;
-               $this->backend->set($identifier, $data, array(), $lifetime);
-               $this->backend->set($identifier, $data, array(), 0);
-               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
-               $this->assertSame(31536000, $lifetimeRegisteredInBackend);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesSetDataTypeForIdentifierToTagsSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data', array('tag'));
-               $this->assertSame(\Redis::REDIS_SET, $this->redis->type('identTags:' . $identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesSpecifiedTagsInIdentifierToTagsSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tags = array('thatTag', 'thisTag');
-               $this->backend->set($identifier, 'data', $tags);
-               $savedTags = $this->redis->sMembers('identTags:' . $identifier);
-               sort($savedTags);
-               $this->assertSame($tags, $savedTags);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setRemovesAllPreviouslySetTagsFromIdentifierToTagsSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tags = array('fooTag', 'barTag');
-               $this->backend->set($identifier, 'data', $tags);
-               $this->backend->set($identifier, 'data', array());
-               $this->assertSame(array(), $this->redis->sMembers('identTags:' . $identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setRemovesMultiplePreviouslySetTagsFromIdentifierToTagsSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $firstTagSet = array('tag1', 'tag2', 'tag3', 'tag4');
-               $this->backend->set($identifier, 'data', $firstTagSet);
-               $secondTagSet = array('tag1', 'tag3');
-               $this->backend->set($identifier, 'data', $secondTagSet);
-               $actualTagSet = $this->redis->sMembers('identTags:' . $identifier);
-               sort($actualTagSet);
-               $this->assertSame($secondTagSet, $actualTagSet);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesSetDataTypeForTagToIdentifiersSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'tag';
-               $this->backend->set($identifier, 'data', array($tag));
-               $this->assertSame(\Redis::REDIS_SET, $this->redis->type('tagIdents:' . $tag));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesIdentifierInTagToIdentifiersSetOfSpecifiedTag() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'thisTag';
-               $this->backend->set($identifier, 'data', array($tag));
-               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
-               $this->assertSame(array($identifier), $savedTagToIdentifiersMemberArray);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setAppendsSecondIdentifierInTagToIdentifiersEntry() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $firstIdentifier = 'identifier' . uniqid();
-               $tag = 'thisTag';
-               $this->backend->set($firstIdentifier, 'data', array($tag));
-               $secondIdentifier = 'identifier' . uniqid();
-               $this->backend->set($secondIdentifier, 'data', array($tag));
-               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
-               sort($savedTagToIdentifiersMemberArray);
-               $identifierArray = array($firstIdentifier, $secondIdentifier);
-               sort($identifierArray);
-               $this->assertSame(array($firstIdentifier, $secondIdentifier), $savedTagToIdentifiersMemberArray);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setRemovesIdentifierFromTagToIdentifiersEntryIfTagIsOmittedOnConsecutiveSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'thisTag';
-               $this->backend->set($identifier, 'data', array($tag));
-               $this->backend->set($identifier, 'data', array());
-               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
-               $this->assertSame(array(), $savedTagToIdentifiersMemberArray);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setAddsIdentifierInTagToIdentifiersEntryIfTagIsAddedOnConsecutiveSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $tag = 'thisTag';
-               $this->backend->set($identifier, 'data', array($tag));
-               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
-               $this->assertSame(array($identifier), $savedTagToIdentifiersMemberArray);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesCompressedDataWithEnabledCompression() {
-               $this->setUpBackend(array(
-                       'compression' => TRUE
-               ));
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $data = 'some data ' . microtime();
-               $this->backend->set($identifier, $data);
-               $uncompresedStoredData = '';
-               try {
-                       $uncompresedStoredData = @gzuncompress($this->redis->get(('identData:' . $identifier)));
-               } catch (\Exception $e) {
-
-               }
-               $this->assertEquals($data, $uncompresedStoredData, 'Original and compressed data don\'t match');
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function setSavesPlaintextDataWithEnabledCompressionAndCompressionLevel0() {
-               $this->setUpBackend(array(
-                       'compression' => TRUE,
-                       'compressionLevel' => 0
-               ));
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $data = 'some data ' . microtime();
-               $this->backend->set($identifier, $data);
-               $this->assertGreaterThan(0, substr_count($this->redis->get('identData:' . $identifier), $data), 'Plaintext data not found');
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function hasThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->has(array());
-       }
-
-       /**
-        * @test Functional
-        */
-       public function hasReturnsFalseForNotExistingEntry() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->assertFalse($this->backend->has($identifier));
-       }
-
-       /**
-        * @test Functional
-        */
-       public function hasReturnsTrueForPreviouslySetEntry() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->assertTrue($this->backend->has($identifier));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function getThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->get(array());
-       }
-
-       /**
-        * @test Functional
-        */
-       public function getReturnsPreviouslyCompressedSetEntry() {
-               $this->setUpBackend(array(
-                       'compression' => TRUE
-               ));
-               $data = 'data';
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, $data);
-               $fetchedData = $this->backend->get($identifier);
-               $this->assertSame($data, $fetchedData);
-       }
-
-       /**
-        * @test Functional
-        */
-       public function getReturnsPreviouslySetEntry() {
-               $this->setUpBackend();
-               $data = 'data';
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, $data);
-               $fetchedData = $this->backend->get($identifier);
-               $this->assertSame($data, $fetchedData);
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function removeThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->remove(array());
-       }
-
-       /**
-        * @test Functional
-        */
-       public function removeReturnsFalseIfNoEntryWasDeleted() {
-               $this->setUpBackend();
-               $this->assertFalse($this->backend->remove('identifier' . uniqid()));
-       }
-
-       /**
-        * @test Functional
-        */
-       public function removeReturnsTrueIfAnEntryWasDeleted() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->assertTrue($this->backend->remove($identifier));
-       }
-
-       /**
-        * @test Functional
-        */
-       public function removeDeletesEntryFromCache() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->backend->remove($identifier);
-               $this->assertFalse($this->backend->has($identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function removeDeletesIdentifierToTagEntry() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'thisTag';
-               $this->backend->set($identifier, 'data', array($tag));
-               $this->backend->remove($identifier);
-               $this->assertFalse($this->redis->exists('identTags:' . $identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function removeDeletesIdentifierFromTagToIdentifiersSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'thisTag';
-               $this->backend->set($identifier, 'data', array($tag));
-               $this->backend->remove($identifier);
-               $tagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
-               $this->assertSame(array(), $tagToIdentifiersMemberArray);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function removeDeletesIdentifierFromTagToIdentifiersSetWithMultipleEntries() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $firstIdentifier = 'identifier' . uniqid();
-               $secondIdentifier = 'identifier' . uniqid();
-               $tag = 'thisTag';
-               $this->backend->set($firstIdentifier, 'data', array($tag));
-               $this->backend->set($secondIdentifier, 'data', array($tag));
-               $this->backend->remove($firstIdentifier);
-               $tagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
-               $this->assertSame(array($secondIdentifier), $tagToIdentifiersMemberArray);
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function findIdentifiersByTagThrowsExceptionIfTagIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->findIdentifiersByTag(array());
-       }
-
-       /**
-        * @test Functional
-        */
-       public function findIdentifiersByTagReturnsEmptyArrayForNotExistingTag() {
-               $this->setUpBackend();
-               $this->assertSame(array(), $this->backend->findIdentifiersByTag('thisTag'));
-       }
-
-       /**
-        * @test Functional
-        */
-       public function findIdentifiersByTagReturnsAllIdentifiersTagedWithSpecifiedTag() {
-               $this->setUpBackend();
-               $firstIdentifier = 'identifier' . uniqid();
-               $secondIdentifier = 'identifier' . uniqid();
-               $thirdIdentifier = 'identifier' . uniqid();
-               $tagsForFirstIdentifier = array('thisTag');
-               $tagsForSecondIdentifier = array('thatTag');
-               $tagsForThirdIdentifier = array('thisTag', 'thatTag');
-               $this->backend->set($firstIdentifier, 'data', $tagsForFirstIdentifier);
-               $this->backend->set($secondIdentifier, 'data', $tagsForSecondIdentifier);
-               $this->backend->set($thirdIdentifier, 'data', $tagsForThirdIdentifier);
-               $expectedResult = array($firstIdentifier, $thirdIdentifier);
-               $actualResult = $this->backend->findIdentifiersByTag('thisTag');
-               sort($actualResult);
-               $this->assertSame($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function flushRemovesAllEntriesFromCache() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->backend->flush();
-               $this->assertSame(array(), $this->redis->getKeys('*'));
-       }
-
-       /**
-        * @test Functional
-        * @expectedException \InvalidArgumentException
-        */
-       public function flushByTagThrowsExceptionIfTagIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->flushByTag(array());
-       }
-
-       /**
-        * @test Functional
-        */
-       public function flushByTagRemovesEntriesTaggedWithSpecifiedTag() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier . 'A', 'data', array('tag1'));
-               $this->backend->set($identifier . 'B', 'data', array('tag2'));
-               $this->backend->set($identifier . 'C', 'data', array('tag1', 'tag2'));
-               $this->backend->flushByTag('tag1');
-               $expectedResult = array(FALSE, TRUE, FALSE);
-               $actualResult = array(
-                       $this->backend->has($identifier . 'A'),
-                       $this->backend->has($identifier . 'B'),
-                       $this->backend->has($identifier . 'C')
-               );
-               $this->assertSame($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function flushByTagRemovesTemporarySet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier . 'A', 'data', array('tag1'));
-               $this->backend->set($identifier . 'C', 'data', array('tag1', 'tag2'));
-               $this->backend->flushByTag('tag1');
-               $this->assertSame(array(), $this->redis->getKeys('temp*'));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function flushByTagRemovesIdentifierToTagsSetOfEntryTaggedWithGivenTag() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'tag1';
-               $this->backend->set($identifier, 'data', array($tag));
-               $this->backend->flushByTag($tag);
-               $this->assertFalse($this->redis->exists('identTags:' . $identifier));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function flushByTagDoesNotRemoveIdentifierToTagsSetOfUnrelatedEntry() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifierToBeRemoved = 'identifier' . uniqid();
-               $tagToRemove = 'tag1';
-               $this->backend->set($identifierToBeRemoved, 'data', array($tagToRemove));
-               $identifierNotToBeRemoved = 'identifier' . uniqid();
-               $tagNotToRemove = 'tag2';
-               $this->backend->set($identifierNotToBeRemoved, 'data', array($tagNotToRemove));
-               $this->backend->flushByTag($tagToRemove);
-               $this->assertSame(array($tagNotToRemove), $this->redis->sMembers('identTags:' . $identifierNotToBeRemoved));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function flushByTagRemovesTagToIdentifiersSetOfGivenTag() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $tag = 'tag1';
-               $this->backend->set($identifier, 'data', array($tag));
-               $this->backend->flushByTag($tag);
-               $this->assertFalse($this->redis->exists('tagIdents:' . $tag));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function flushByTagRemovesIdentifiersTaggedWithGivenTagFromTagToIdentifiersSets() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2'));
-               $this->backend->set($identifier . 'B', 'data', array('tag1', 'tag2'));
-               $this->backend->set($identifier . 'C', 'data', array('tag2'));
-               $this->backend->flushByTag('tag1');
-               $this->assertSame(array($identifier . 'C'), $this->redis->sMembers('tagIdents:tag2'));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function collectGarbageDoesNotRemoveNotExpiredIdentifierToDataEntry() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier . 'A', 'data', array('tag'));
-               $this->backend->set($identifier . 'B', 'data', array('tag'));
-               $this->redis->delete(('identData:' . $identifier) . 'A');
-               $this->backend->collectGarbage();
-               $this->assertTrue($this->redis->exists(('identData:' . $identifier) . 'B'));
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function collectGarbageRemovesLeftOverIdentifierToTagsSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier . 'A', 'data', array('tag'));
-               $this->backend->set($identifier . 'B', 'data', array('tag'));
-               $this->redis->delete(('identData:' . $identifier) . 'A');
-               $this->backend->collectGarbage();
-               $expectedResult = array(FALSE, TRUE);
-               $actualResult = array(
-                       $this->redis->exists(('identTags:' . $identifier) . 'A'),
-                       $this->redis->exists(('identTags:' . $identifier) . 'B')
-               );
-               $this->assertSame($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test Implementation
-        */
-       public function collectGarbageRemovesExpiredIdentifierFromTagsToIdentifierSet() {
-               $this->setUpBackend();
-               $this->setUpRedis();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2'));
-               $this->backend->set($identifier . 'B', 'data', array('tag2'));
-               $this->redis->delete(('identData:' . $identifier) . 'A');
-               $this->backend->collectGarbage();
-               $expectedResult = array(
-                       array(),
-                       array($identifier . 'B')
-               );
-               $actualResult = array(
-                       $this->redis->sMembers('tagIdents:tag1'),
-                       $this->redis->sMembers('tagIdents:tag2')
-               );
-               $this->assertSame($expectedResult, $actualResult);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackendTest.php
deleted file mode 100644 (file)
index aa0813a..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the TransientMemory cache backend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_TransientMemoryBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        * @test
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $inCache = $backend->has($identifier);
-               $this->assertTrue($inCache);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $otherData = 'some other data';
-               $backend->set($identifier, $otherData);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($otherData, $fetchedData);
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'Some data';
-               $entryIdentifier = 'MyIdentifier';
-               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
-               $this->assertEquals($entryIdentifier, $retrieved[0]);
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
-               $this->assertEquals($entryIdentifier, $retrieved[0]);
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $identifier = 'NonExistingIdentifier';
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache);
-       }
-
-       /**
-        * @test
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $identifier = 'NonExistingIdentifier';
-               $inCache = $backend->remove($identifier);
-               $this->assertFalse($inCache);
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'some data' . microtime();
-               $backend->set('TransientMemoryBackendTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('TransientMemoryBackendTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('TransientMemoryBackendTest3', $data, array('UnitTestTag%test'));
-               $backend->flushByTag('UnitTestTag%special');
-               $this->assertTrue($backend->has('TransientMemoryBackendTest1'), 'TransientMemoryBackendTest1');
-               $this->assertFalse($backend->has('TransientMemoryBackendTest2'), 'TransientMemoryBackendTest2');
-               $this->assertTrue($backend->has('TransientMemoryBackendTest3'), 'TransientMemoryBackendTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
-               $backend->setCache($cache);
-               $data = 'some data' . microtime();
-               $backend->set('TransientMemoryBackendTest1', $data);
-               $backend->set('TransientMemoryBackendTest2', $data);
-               $backend->set('TransientMemoryBackendTest3', $data);
-               $backend->flush();
-               $this->assertFalse($backend->has('TransientMemoryBackendTest1'), 'TransientMemoryBackendTest1');
-               $this->assertFalse($backend->has('TransientMemoryBackendTest2'), 'TransientMemoryBackendTest2');
-               $this->assertFalse($backend->has('TransientMemoryBackendTest3'), 'TransientMemoryBackendTest3');
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_wincachebackendTest.php b/tests/Unit/t3lib/cache/backend/class.t3lib_cache_backend_wincachebackendTest.php
deleted file mode 100644 (file)
index fd7da22..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2012 Tobias Burger <tobias_burger@hotmail.com>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the WinCache cache backend
- *
- * @author Tobias Burger <tobias_burger@hotmail.com>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_backend_WincacheBackendTest extends tx_phpunit_testcase {
-
-       /**
-        * Sets up this testcase
-        *
-        * @return void
-        */
-       public function setUp() {
-               if (!extension_loaded('wincache')) {
-                       $this->markTestSkipped('WinCache extension was not available');
-               }
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $inCache = $backend->has($identifier);
-               $this->assertTrue($inCache, 'WinCache backend failed to set and check entry');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData, 'Winache backend failed to set and retrieve data');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, 'Failed to set and remove data from WinCache backend');
-       }
-
-       /**
-        * @test
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $otherData = 'some other data';
-               $backend->set($identifier, $otherData);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($otherData, $fetchedData, 'WinCache backend failed to overwrite and retrieve data');
-       }
-
-       /**
-        * @test
-        */
-       public function findIdentifiersByTagFindsSetEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
-               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
-               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
-       }
-
-       /**
-        * @test
-        */
-       public function setRemovesTagsFromPreviousSet() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tagX'));
-               $backend->set($identifier, $data, array('UnitTestTag%tag3'));
-               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
-               $this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, '"has" did not return FALSE when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
-               $inCache = $backend->remove($identifier);
-               $this->assertFalse($inCache, '"remove" did not return FALSE when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('BackendWincacheTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('BackendWincacheTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $backend->set('BackendWincacheTest3', $data, array('UnitTestTag%test'));
-               $backend->flushByTag('UnitTestTag%special');
-               $this->assertTrue($backend->has('BackendWincacheTest1'), 'BackendWincacheTest1');
-               $this->assertFalse($backend->has('BackendWincacheTest2'), 'BackendWincacheTest2');
-               $this->assertTrue($backend->has('BackendWincacheTest3'), 'BackendWincacheTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesAllCacheEntries() {
-               $backend = $this->setUpBackend();
-               $data = 'some data' . microtime();
-               $backend->set('BackendWincacheTest1', $data);
-               $backend->set('BackendWincacheTest2', $data);
-               $backend->set('BackendWincacheTest3', $data);
-               $backend->flush();
-               $this->assertFalse($backend->has('BackendWincacheTest1'), 'BackendWincacheTest1');
-               $this->assertFalse($backend->has('BackendWincacheTest2'), 'BackendWincacheTest2');
-               $this->assertFalse($backend->has('BackendWincacheTest3'), 'BackendWincacheTest3');
-       }
-
-       /**
-        * @test
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
-               $thisBackend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
-               $thisBackend->setCache($thisCache);
-               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
-               $thatBackend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
-               $thatBackend->setCache($thatCache);
-               $thisBackend->set('thisEntry', 'Hello');
-               $thatBackend->set('thatEntry', 'World!');
-               $thatBackend->flush();
-               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
-               $this->assertFalse($thatBackend->has('thatEntry'));
-       }
-
-       /**
-        * Check if we can store ~5 MB of data
-        *
-        * @test
-        */
-       public function largeDataIsStored() {
-               $backend = $this->setUpBackend();
-               $data = str_repeat('abcde', 1024 * 1024);
-               $identifier = 'tooLargeData' . md5(uniqid(mt_rand(), TRUE));
-               $backend->set($identifier, $data);
-               $this->assertTrue($backend->has($identifier));
-               $this->assertEquals($backend->get($identifier), $data);
-       }
-
-       /**
-        * Sets up the WinCache backend used for testing
-        *
-        * @return \TYPO3\CMS\Core\Cache\Backend\WincacheBackend
-        */
-       protected function setUpBackend() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
-               $backend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
-               $backend->setCache($cache);
-               return $backend;
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/class.t3lib_cache_factoryTest.php b/tests/Unit/t3lib/cache/class.t3lib_cache_factoryTest.php
deleted file mode 100644 (file)
index afa2814..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-require_once 'backend/class.t3lib_cache_backend_mockbackend.php';
-/**
- * Testcase for the Cache Factory
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_FactoryTest extends tx_phpunit_testcase {
-
-       /**
-        * @test
-        */
-       public function createReturnsInstanceOfTheSpecifiedCacheFrontend() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', 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', 'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend');
-               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', $cache);
-       }
-
-       /**
-        * @test
-        */
-       public function createInjectsAnInstanceOfTheSpecifiedBackendIntoTheCacheFrontend() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', 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', 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend');
-               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', $cache->getBackend());
-       }
-
-       /**
-        * @test
-        */
-       public function createRegistersTheCacheAtTheCacheManager() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', 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', 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend');
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/class.t3lib_cache_managerTest.php b/tests/Unit/t3lib/cache/class.t3lib_cache_managerTest.php
deleted file mode 100644 (file)
index cc70878..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the Cache Manager
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_ManagerTest extends tx_phpunit_testcase {
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception\DuplicateIdentifierException
-        */
-       public function managerThrowsExceptionOnCacheRegistrationWithAlreadyExistingIdentifier() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cache1 = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', 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', 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);
-       }
-
-       /**
-        * @test
-        */
-       public function managerReturnsThePreviouslyRegisteredCache() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cache1 = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', 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', 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);
-               $this->assertSame($cache2, $manager->getCache('cache2'), 'The cache returned by getCache() was not the same I registered.');
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
-        */
-       public function getCacheThrowsExceptionForNonExistingIdentifier() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', 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');
-               $manager->getCache('doesnotexist');
-       }
-
-       /**
-        * @test
-        */
-       public function hasCacheReturnsCorrectResult() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cache1 = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', 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.');
-               $this->assertFalse($manager->hasCache('cache2'), 'hasCache() did not return FALSE.');
-       }
-
-       /**
-        * @test
-        */
-       public function flushCachesByTagCallsTheFlushByTagMethodOfAllRegisteredCaches() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cache1 = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', 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', 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');
-       }
-
-       /**
-        * @test
-        */
-       public function flushCachesCallsTheFlushMethodOfAllRegisteredCaches() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cache1 = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', 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', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', FALSE);
-               $cache2->expects($this->once())->method('flush');
-               $manager->registerCache($cache2);
-               $manager->flushCaches();
-       }
-
-       /**
-        * @test
-        */
-       public function getCacheCreatesCacheInstanceWithGivenConfiguration() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cacheIdentifier = 'Test' . md5(uniqid(mt_rand(), TRUE));
-               $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', array('create'), array(), '', FALSE);
-               $factory->expects($this->once())->method('create')->with($cacheIdentifier, $cacheObjectName, $backendObjectName, $backendOptions);
-               $manager->injectCacheFactory($factory);
-               $manager->setCacheConfigurations($configuration);
-               $manager->getCache($cacheIdentifier);
-       }
-
-       /**
-        * @test
-        */
-       public function getCacheCreatesCacheInstanceWithFallbackToDefaultFrontend() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cacheIdentifier = 'Test' . md5(uniqid(mt_rand(), TRUE));
-               $backendObjectName = 'testBackend';
-               $backendOptions = array('foo');
-               $configuration = array(
-                       $cacheIdentifier => array(
-                               'backend' => $backendObjectName,
-                               'options' => $backendOptions
-                       )
-               );
-               $factory = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheFactory', array('create'), array(), '', FALSE);
-               $factory->expects($this->once())->method('create')->with($cacheIdentifier, 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', $backendObjectName, $backendOptions);
-               $manager->injectCacheFactory($factory);
-               $manager->setCacheConfigurations($configuration);
-               $manager->getCache($cacheIdentifier);
-       }
-
-       /**
-        * @test
-        */
-       public function getCacheCreatesCacheInstanceWithFallbackToDefaultBackend() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cacheIdentifier = 'Test' . md5(uniqid(mt_rand(), TRUE));
-               $cacheObjectName = 'testCache';
-               $backendOptions = array('foo');
-               $configuration = array(
-                       $cacheIdentifier => array(
-                               'frontend' => $cacheObjectName,
-                               'options' => $backendOptions
-                       )
-               );
-               $factory = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheFactory', array('create'), array(), '', FALSE);
-               $factory->expects($this->once())->method('create')->with($cacheIdentifier, $cacheObjectName, 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend', $backendOptions);
-               $manager->injectCacheFactory($factory);
-               $manager->setCacheConfigurations($configuration);
-               $manager->getCache($cacheIdentifier);
-       }
-
-       /**
-        * @test
-        */
-       public function getCacheCreatesCacheInstanceWithFallbackToDefaultBackenOptions() {
-               $manager = new \TYPO3\CMS\Core\Cache\CacheManager();
-               $cacheIdentifier = 'Test' . md5(uniqid(mt_rand(), TRUE));
-               $cacheObjectName = 'testCache';
-               $backendObjectName = 'testBackend';
-               $configuration = array(
-                       $cacheIdentifier => array(
-                               'frontend' => $cacheObjectName,
-                               'backend' => $backendObjectName
-                       )
-               );
-               $factory = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheFactory', array('create'), array(), '', FALSE);
-               $factory->expects($this->once())->method('create')->with($cacheIdentifier, $cacheObjectName, $backendObjectName, array());
-               $manager->injectCacheFactory($factory);
-               $manager->setCacheConfigurations($configuration);
-               $manager->getCache($cacheIdentifier);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontendTest.php b/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontendTest.php
deleted file mode 100644 (file)
index 7b69b4d..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the abstract cache frontend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_frontend_AbstractFrontendTest extends tx_phpunit_testcase {
-
-       /**
-        * @test
-        */
-       public function theConstructorAcceptsValidIdentifiers() {
-               $mockBackend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               foreach (array('x', 'someValue', '123fivesixseveneight', 'some&', 'ab_cd%', rawurlencode('resource://some/äöü$&% sadf'), str_repeat('x', 250)) as $identifier) {
-                       $abstractCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag', 'flush', 'flushByTag', 'collectGarbage'), array($identifier, $mockBackend));
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function theConstructorRejectsInvalidIdentifiers() {
-               $mockBackend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               foreach (array('', 'abc def', 'foo!', 'bar:', 'some/', 'bla*', 'one+', 'äöü', str_repeat('x', 251), 'x$', '\\a', 'b#') as $identifier) {
-                       try {
-                               $abstractCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag', 'flush', 'flushByTag', 'collectGarbage'), array($identifier, $mockBackend));
-                               $this->fail(('Identifier "' . $identifier) . '" was not rejected.');
-                       } catch (\InvalidArgumentException $exception) {
-
-                       }
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function flushCallsBackend() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('flush');
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               $cache->flush();
-       }
-
-       /**
-        * @test
-        * @expectedException InvalidArgumentException
-        */
-       public function flushByTagRejectsInvalidTags() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\BackendInterface', array(), array(), '', FALSE);
-               $backend->expects($this->never())->method('flushByTag');
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               $cache->flushByTag('SomeInvalid\\Tag');
-       }
-
-       /**
-        * @test
-        */
-       public function flushByTagCallsBackendIfItIsATaggableBackend() {
-               $tag = 'sometag';
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\TaggableBackendInterface', array('setCache', 'get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('flushByTag')->with($tag);
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               $cache->flushByTag($tag);
-       }
-
-       /**
-        * @test
-        */
-       public function collectGarbageCallsBackend() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('collectGarbage');
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               $cache->collectGarbage();
-       }
-
-       /**
-        * @test
-        */
-       public function getClassTagRendersTagWhichCanBeUsedToTagACacheEntryWithACertainClass() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               $this->assertEquals('%CLASS%F3_Foo_Bar_Baz', \TYPO3\CMS\Core\Cache\CacheManager::getClassTag('F3\\Foo\\Bar\\Baz'));
-       }
-
-       /**
-        * @test
-        */
-       public function invalidEntryIdentifiersAreRecognizedAsInvalid() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(), array(), '', FALSE);
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               foreach (array('', 'abc def', 'foo!', 'bar:', 'some/', 'bla*', 'one+', 'äöü', str_repeat('x', 251), 'x$', '\\a', 'b#') as $entryIdentifier) {
-                       $this->assertFalse($cache->isValidEntryIdentifier($entryIdentifier), ('Invalid identifier "' . $entryIdentifier) . '" was not rejected.');
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function validEntryIdentifiersAreRecognizedAsValid() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(), array(), '', FALSE);
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               foreach (array('_', 'abcdef', 'foo', 'bar123', '3some', '_bl_a', 'some&', 'one%TWO', str_repeat('x', 250)) as $entryIdentifier) {
-                       $this->assertTrue($cache->isValidEntryIdentifier($entryIdentifier), ('Valid identifier "' . $entryIdentifier) . '" was not accepted.');
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function invalidTagsAreRecognizedAsInvalid() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(), array(), '', FALSE);
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               foreach (array('', 'abc def', 'foo!', 'bar:', 'some/', 'bla*', 'one+', 'äöü', str_repeat('x', 251), 'x$', '\\a', 'b#') as $tag) {
-                       $this->assertFalse($cache->isValidTag($tag), ('Invalid tag "' . $tag) . '" was not rejected.');
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function validTagsAreRecognizedAsValid() {
-               $identifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(), array(), '', FALSE);
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
-               foreach (array('abcdef', 'foo-bar', 'foo_baar', 'bar123', '3some', 'file%Thing', 'some&', '%x%', str_repeat('x', 250)) as $tag) {
-                       $this->assertTrue($cache->isValidTag($tag), ('Valid tag "' . $tag) . '" was not accepted.');
-               }
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_phpfrontendTest.php b/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_phpfrontendTest.php
deleted file mode 100644 (file)
index a597677..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the PHP source code cache frontend
- *
- * This file is a backport from FLOW3
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_frontend_PhpFrontendTest extends tx_phpunit_testcase {
-
-       /**
-        * @test
-        * @expectedException InvalidArgumentException
-        */
-       public function setChecksIfTheIdentifierIsValid() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('isValidEntryIdentifier'), array(), '', FALSE);
-               $cache->expects($this->once())->method('isValidEntryIdentifier')->with('foo')->will($this->returnValue(FALSE));
-               $cache->set('foo', 'bar');
-       }
-
-       /**
-        * @test
-        */
-       public function setPassesPhpSourceCodeTagsAndLifetimeToBackend() {
-               $originalSourceCode = 'return "hello world!";';
-               $modifiedSourceCode = ((('<?php' . chr(10)) . $originalSourceCode) . chr(10)) . '#';
-               $mockBackend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\PhpCapableBackendInterface', array(), array(), '', FALSE);
-               $mockBackend->expects($this->once())->method('set')->with('Foo-Bar', $modifiedSourceCode, array('tags'), 1234);
-               $cache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', 'PhpFrontend', $mockBackend);
-               $cache->set('Foo-Bar', $originalSourceCode, array('tags'), 1234);
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
-        */
-       public function setThrowsInvalidDataExceptionOnNonStringValues() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array('dummy'), array(), '', FALSE);
-               $cache->set('Foo-Bar', array());
-       }
-
-       /**
-        * @test
-        */
-       public function requireOnceCallsTheBackendsRequireOnceMethod() {
-               $mockBackend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\PhpCapableBackendInterface', array(), array(), '', FALSE);
-               $mockBackend->expects($this->once())->method('requireOnce')->with('Foo-Bar')->will($this->returnValue('hello world!'));
-               $cache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', 'PhpFrontend', $mockBackend);
-               $result = $cache->requireOnce('Foo-Bar');
-               $this->assertSame('hello world!', $result);
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontendTest.php b/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontendTest.php
deleted file mode 100644 (file)
index be2a7a3..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Testcase for the string cache frontend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_frontend_StringFrontendTest extends tx_phpunit_testcase {
-
-       /**
-        * @expectedException \InvalidArgumentException
-        * @test
-        */
-       public function setChecksIfTheIdentifierIsValid() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('isValidEntryIdentifier'), array(), '', FALSE);
-               $cache->expects($this->once())->method('isValidEntryIdentifier')->with('foo')->will($this->returnValue(FALSE));
-               $cache->set('foo', 'bar');
-       }
-
-       /**
-        * @test
-        */
-       public function setPassesStringToBackend() {
-               $theString = 'Just some value';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('set')->with($this->equalTo('StringCacheTest'), $this->equalTo($theString));
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $cache->set('StringCacheTest', $theString);
-       }
-
-       /**
-        * @test
-        */
-       public function setPassesLifetimeToBackend() {
-               $theString = 'Just some value';
-               $theLifetime = 1234;
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('set')->with($this->equalTo('StringCacheTest'), $this->equalTo($theString), $this->equalTo(array()), $this->equalTo($theLifetime));
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $cache->set('StringCacheTest', $theString, array(), $theLifetime);
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
-        */
-       public function setThrowsInvalidDataExceptionOnNonStringValues() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $cache->set('StringCacheTest', array());
-       }
-
-       /**
-        * @test
-        */
-       public function getFetchesStringValueFromBackend() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('get')->will($this->returnValue('Just some value'));
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $this->assertEquals('Just some value', $cache->get('StringCacheTest'), 'The returned value was not the expected string.');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsResultFromBackend() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('has')->with($this->equalTo('StringCacheTest'))->will($this->returnValue(TRUE));
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $this->assertTrue($cache->has('StringCacheTest'), 'has() did not return TRUE.');
-       }
-
-       /**
-        * @test
-        */
-       public function removeCallsBackend() {
-               $cacheIdentifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('remove')->with($this->equalTo($cacheIdentifier))->will($this->returnValue(TRUE));
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $this->assertTrue($cache->remove($cacheIdentifier), 'remove() did not return TRUE');
-       }
-
-       /**
-        * @test
-        * @expectedException InvalidArgumentException
-        */
-       public function getByTagRejectsInvalidTags() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\BackendInterface', array(), array(), '', FALSE);
-               $backend->expects($this->never())->method('getByTag');
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $cache->getByTag('SomeInvalid\\Tag');
-       }
-
-       /**
-        * @test
-        */
-       public function getByTagCallsBackend() {
-               $tag = 'sometag';
-               $identifiers = array('one', 'two');
-               $entries = array('one value', 'two value');
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
-               $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls('one value', 'two value'));
-               $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend('StringFrontend', $backend);
-               $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontendTest.php b/tests/Unit/t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontendTest.php
deleted file mode 100644 (file)
index 1e78021..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Testcase for the variable cache frontend
- *
- * This file is a backport from FLOW3
- *
- * @author Ingo Renner <ingo@typo3.org>
- * @package TYPO3
- * @subpackage tests
- */
-class t3lib_cache_frontend_VariableFrontendTest extends tx_phpunit_testcase {
-
-       /**
-        * @expectedException \InvalidArgumentException
-        * @test
-        */
-       public function setChecksIfTheIdentifierIsValid() {
-               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('isValidEntryIdentifier'), array(), '', FALSE);
-               $cache->expects($this->once())->method('isValidEntryIdentifier')->with('foo')->will($this->returnValue(FALSE));
-               $cache->set('foo', 'bar');
-       }
-
-       /**
-        * @test
-        */
-       public function setPassesSerializedStringToBackend() {
-               $theString = 'Just some value';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(serialize($theString)));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->set('VariableCacheTest', $theString);
-       }
-
-       /**
-        * @test
-        */
-       public function setPassesSerializedArrayToBackend() {
-               $theArray = array('Just some value', 'and another one.');
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(serialize($theArray)));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->set('VariableCacheTest', $theArray);
-       }
-
-       /**
-        * @test
-        */
-       public function setPassesLifetimeToBackend() {
-               $theString = 'Just some value';
-               $theLifetime = 1234;
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(serialize($theString)), $this->equalTo(array()), $this->equalTo($theLifetime));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->set('VariableCacheTest', $theString, array(), $theLifetime);
-       }
-
-       /**
-        * @test
-        */
-       public function setUsesIgBinarySerializeIfAvailable() {
-               if (!extension_loaded('igbinary')) {
-                       $this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.');
-               }
-
-               $theString = 'Just some value';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(igbinary_serialize($theString)));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->initializeObject();
-               $cache->set('VariableCacheTest', $theString);
-       }
-
-       /**
-        * @test
-        */
-       public function getFetchesStringValueFromBackend() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('get')->will($this->returnValue(serialize('Just some value')));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $this->assertEquals('Just some value', $cache->get('VariableCacheTest'), 'The returned value was not the expected string.');
-       }
-
-       /**
-        * @test
-        */
-       public function getFetchesArrayValueFromBackend() {
-               $theArray = array('Just some value', 'and another one.');
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('get')->will($this->returnValue(serialize($theArray)));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $this->assertEquals($theArray, $cache->get('VariableCacheTest'), 'The returned value was not the expected unserialized array.');
-       }
-
-       /**
-        * @test
-        */
-       public function getFetchesFalseBooleanValueFromBackend() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('get')->will($this->returnValue(serialize(FALSE)));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $this->assertFalse($cache->get('VariableCacheTest'), 'The returned value was not the FALSE.');
-       }
-
-       /**
-        * @test
-        */
-       public function getUsesIgBinaryIfAvailable() {
-               if (!extension_loaded('igbinary')) {
-                       $this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.');
-               }
-
-               $theArray = array('Just some value', 'and another one.');
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('get')->will($this->returnValue(igbinary_serialize($theArray)));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->initializeObject();
-
-               $this->assertEquals($theArray, $cache->get('VariableCacheTest'), 'The returned value was not the expected unserialized array.');
-       }
-
-       /**
-        * @test
-        */
-       public function hasReturnsResultFromBackend() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-               $backend->expects($this->once())->method('has')->with($this->equalTo('VariableCacheTest'))->will($this->returnValue(TRUE));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $this->assertTrue($cache->has('VariableCacheTest'), 'has() did not return TRUE.');
-       }
-
-       /**
-        * @test
-        */
-       public function removeCallsBackend() {
-               $cacheIdentifier = 'someCacheIdentifier';
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-
-               $backend->expects($this->once())->method('remove')->with($this->equalTo($cacheIdentifier))->will($this->returnValue(TRUE));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $this->assertTrue($cache->remove($cacheIdentifier), 'remove() did not return TRUE');
-       }
-
-       /**
-        * @test
-        * @expectedException \InvalidArgumentException
-        */
-       public function getByTagRejectsInvalidTags() {
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\BackendInterface', array(), array(), '', FALSE);
-               $backend->expects($this->never())->method('getByTag');
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->getByTag('SomeInvalid\Tag');
-       }
-
-       /**
-        * @test
-        */
-       public function getByTagCallsBackend() {
-               $tag = 'sometag';
-               $identifiers = array('one', 'two');
-               $entries = array('one value', 'two value');
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-
-               $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
-               $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls(serialize('one value'), serialize('two value')));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
-       }
-
-       /**
-        * @test
-        */
-       public function getByTagUsesIgBinaryIfAvailable() {
-               if (!extension_loaded('igbinary')) {
-                       $this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.');
-               }
-
-               $tag = 'sometag';
-               $identifiers = array('one', 'two');
-               $entries = array('one value', 'two value');
-               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE);
-
-               $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
-               $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls(igbinary_serialize('one value'), igbinary_serialize('two value')));
-
-               $cache = new TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend);
-               $cache->initializeObject();
-               $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/Unit/t3lib/cache/last_synched_revision b/tests/Unit/t3lib/cache/last_synched_revision
deleted file mode 100644 (file)
index a2449fd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-868e073b9877d562c6ed65a5158c1c67b3a501a8
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/AbstractBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/AbstractBackendTest.php
new file mode 100644 (file)
index 0000000..5c24e46
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the abstract cache backend
+ *
+ * This file is a backport from FLOW3
+ *
+ * @author Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class AbstractBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * @var \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
+        */
+       protected $backend;
+
+       /**
+        * @return void
+        */
+       public function setUp() {
+               $className = 'ConcreteBackend_' . md5(uniqid(mt_rand(), TRUE));
+               eval(('
+                       class ' . $className) . ' extends TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend {
+                               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 flushByTag($tag) {}
+                               public function findIdentifiersByTag($tag) {}
+                               public function collectGarbage() {}
+                               public function setSomeOption($value) {
+                                       $this->someOption = $value;
+                               }
+                               public function getSomeOption() {
+                                       return $this->someOption;
+                               }
+                       }
+               ');
+               $this->backend = new $className('Testing');
+       }
+
+       /**
+        * @test
+        */
+       public function theConstructorCallsSetterMethodsForAllSpecifiedOptions() {
+               $className = get_class($this->backend);
+               $backend = new $className('Testing', array('someOption' => 'someValue'));
+               $this->assertSame('someValue', $backend->getSomeOption());
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/ApcBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/ApcBackendTest.php
new file mode 100644 (file)
index 0000000..df7b5a4
--- /dev/null
@@ -0,0 +1,238 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the APC cache backend
+ *
+ * This file is a backport from FLOW3
+ *
+ * @author Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class ApcBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Sets up this testcase
+        *
+        * @return void
+        */
+       public function setUp() {
+               if (!extension_loaded('apc')) {
+                       $this->markTestSkipped('APC extension was not available');
+               }
+               if (ini_get('apc.slam_defense') == 1) {
+                       $this->markTestSkipped('This testcase can only be executed with apc.slam_defense = Off');
+               }
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache, 'APC backend failed to set and check entry');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData, 'APC backend failed to set and retrieve data');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, 'Failed to set and remove data from APC backend');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $otherData = 'some other data';
+               $backend->set($identifier, $otherData);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($otherData, $fetchedData, 'APC backend failed to overwrite and retrieve data');
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsSetEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
+               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
+               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
+       }
+
+       /**
+        * @test
+        */
+       public function setRemovesTagsFromPreviousSet() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tagX'));
+               $backend->set($identifier, $data, array('UnitTestTag%tag3'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
+               $this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, '"has" did not return FALSE when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache, '"remove" did not return FALSE when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('BackendAPCTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendAPCTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendAPCTest3', $data, array('UnitTestTag%test'));
+               $backend->flushByTag('UnitTestTag%special');
+               $this->assertTrue($backend->has('BackendAPCTest1'), 'BackendAPCTest1');
+               $this->assertFalse($backend->has('BackendAPCTest2'), 'BackendAPCTest2');
+               $this->assertTrue($backend->has('BackendAPCTest3'), 'BackendAPCTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('BackendAPCTest1', $data);
+               $backend->set('BackendAPCTest2', $data);
+               $backend->set('BackendAPCTest3', $data);
+               $backend->flush();
+               $this->assertFalse($backend->has('BackendAPCTest1'), 'BackendAPCTest1');
+               $this->assertFalse($backend->has('BackendAPCTest2'), 'BackendAPCTest2');
+               $this->assertFalse($backend->has('BackendAPCTest3'), 'BackendAPCTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
+               $thisBackend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
+               $thisBackend->setCache($thisCache);
+               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
+               $thatBackend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
+               $thatBackend->setCache($thatCache);
+               $thisBackend->set('thisEntry', 'Hello');
+               $thatBackend->set('thatEntry', 'World!');
+               $thatBackend->flush();
+               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
+               $this->assertFalse($thatBackend->has('thatEntry'));
+       }
+
+       /**
+        * Check if we can store ~5 MB of data
+        *
+        * @test
+        */
+       public function largeDataIsStored() {
+               $backend = $this->setUpBackend();
+               $data = str_repeat('abcde', 1024 * 1024);
+               $identifier = 'tooLargeData' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $this->assertTrue($backend->has($identifier));
+               $this->assertEquals($backend->get($identifier), $data);
+       }
+
+       /**
+        * Sets up the APC backend used for testing
+        *
+        * @return \TYPO3\CMS\Core\Cache\Backend\ApcBackend
+        */
+       protected function setUpBackend() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\ApcBackend('Testing');
+               $backend->setCache($cache);
+               return $backend;
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/DbBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/DbBackendTest.php
new file mode 100644 (file)
index 0000000..ceb5d00
--- /dev/null
@@ -0,0 +1,520 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the DB cache backend
+ *
+ * @author Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class DbBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * @var \TYPO3\CMS\Core\Database\DatabaseConnection Backup of original TYPO3_DB instance
+        */
+       protected $typo3DbBackup;
+
+       /**
+        * @var string Name of the testing data table
+        */
+       protected $testingCacheTable;
+
+       /**
+        * @var string Name of the testing tags table
+        */
+       protected $testingTagsTable;
+
+       /**
+        * Set up testcases
+        */
+       public function setUp() {
+               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
+               $tablePrefix = 'cf_';
+               $this->testingCacheTable = $tablePrefix . 'Testing';
+               $this->testingTagsTable = $tablePrefix . 'Testing_tags';
+       }
+
+       /**
+        * Sets up the backend used for testing
+        *
+        * @return void
+        */
+       protected function setUpBackend(array $backendOptions = array()) {
+               $GLOBALS['TYPO3_DB']->sql_query(('CREATE TABLE ' . $this->testingCacheTable) . ' (
+                       id int(11) unsigned NOT NULL auto_increment,
+                       identifier varchar(250) DEFAULT \'\' NOT NULL,
+                       expires int(11) unsigned DEFAULT \'0\' NOT NULL,
+                       content mediumblob,
+                       PRIMARY KEY (id),
+                       KEY cache_id (identifier, expires)
+               ) ENGINE=InnoDB;
+               ');
+               $GLOBALS['TYPO3_DB']->sql_query(('CREATE TABLE ' . $this->testingTagsTable) . ' (
+                       id int(11) unsigned NOT NULL auto_increment,
+                       identifier varchar(250) DEFAULT \'\' NOT NULL,
+                       tag varchar(250) DEFAULT \'\' NOT NULL,
+                       PRIMARY KEY (id),
+                       KEY cache_id (identifier),
+                       KEY cache_tag (tag)
+               ) ENGINE=InnoDB;
+               ');
+               $backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend', 'Testing', $backendOptions);
+               return $backend;
+       }
+
+       /**
+        * Helper method to inject a mock frontend to backend instance
+        *
+        * @param \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend $backend Current backend instance
+        * @return \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface Mock frontend
+        */
+       protected function setUpMockFrontendOfBackend(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend $backend) {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('Testing'));
+               $backend->setCache($mockCache);
+               return $mockCache;
+       }
+
+       /**
+
+        */
+       public function tearDown() {
+               $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
+               $GLOBALS['TYPO3_DB']->sql_query(('DROP TABLE IF EXISTS ' . $this->testingCacheTable) . ';');
+               $GLOBALS['TYPO3_DB']->sql_query(('DROP TABLE IF EXISTS ' . $this->testingTagsTable) . ';');
+       }
+
+       /**
+        * @test
+        */
+       public function setCacheCalculatesCacheTableName() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $this->assertEquals($this->testingCacheTable, $backend->getCacheTable());
+       }
+
+       /**
+        * @test
+        */
+       public function setCacheCalculatesTagsTableName() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $this->assertEquals($this->testingTagsTable, $backend->getTagsTable());
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function setThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->set('identifier', 'data');
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
+        */
+       public function setThrowsExceptionIfDataIsNotAString() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = array('Some data');
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+       }
+
+       /**
+        * @test
+        */
+       public function setInsertsEntryInTable() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $this->assertEquals($data, $entryFound['content']);
+       }
+
+       /**
+        * @test
+        */
+       public function setRemovesAnAlreadyExistingCacheEntryForTheSameIdentifier() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data1 = 'some data' . microtime();
+               $data2 = $data1 . '_different';
+               $entryIdentifier = 'BackendDbRemoveBeforeSetTest';
+               $backend->set($entryIdentifier, $data1, array(), 500);
+               $backend->set($entryIdentifier, $data2, array(), 200);
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $this->assertEquals(1, count($entriesFound));
+       }
+
+       /**
+        * @test
+        */
+       public function setReallySavesSpecifiedTags() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingTagsTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $tags = array();
+               foreach ($entriesFound as $entry) {
+                       $tags[] = $entry['tag'];
+               }
+               $this->assertTrue(count($tags) > 0);
+               $this->assertTrue(in_array('UnitTestTag%tag1', $tags));
+               $this->assertTrue(in_array('UnitTestTag%tag2', $tags));
+       }
+
+       /**
+        * @test
+        */
+       public function setSavesCompressedDataWithEnabledCompression() {
+               $backend = $this->setUpBackend(array(
+                       'compression' => TRUE
+               ));
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data ' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('content', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $this->assertEquals($data, @gzuncompress($entry['content']));
+       }
+
+       /**
+        * @test
+        */
+       public function setSavesPlaintextDataWithEnabledCompressionAndCompressionLevel0() {
+               $backend = $this->setUpBackend(array(
+                       'compression' => TRUE,
+                       'compressionLevel' => 0
+               ));
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data ' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('content', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $this->assertGreaterThan(0, substr_count($entry['content'], $data));
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function getThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->get('identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function getReturnsContentOfTheCorrectCacheEntry() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data, array(), 500);
+               $data = 'some other data' . microtime();
+               $backend->set($entryIdentifier, $data, array(), 100);
+               $loadedData = $backend->get($entryIdentifier);
+               $this->assertEquals($data, $loadedData);
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function hasThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->has('identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsTheCorrectResult() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+               $this->assertTrue($backend->has($entryIdentifier));
+               $this->assertFalse($backend->has($entryIdentifier . 'Not'));
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function removeThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->remove('identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function removeReallyRemovesACacheEntry() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemovalTest';
+               $backend->set($entryIdentifier, $data);
+               $backend->remove($entryIdentifier);
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $this->assertTrue(count($entriesFound) == 0);
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function collectGarbageThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->collectGarbage();
+       }
+
+       /**
+        * @test
+        */
+       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
+               $backend = $this->setUpBackend();
+               $mockCache = $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemovalTest';
+               $backend->set($entryIdentifier, $data, array(), 1);
+               $GLOBALS['EXEC_TIME'] += 2;
+               // setCache calls initializeCommonReferences which recalculate expire statement
+               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
+               $backend->setCache($mockCache);
+               $backend->collectGarbage();
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, ('identifier = \'' . $entryIdentifier) . '\'');
+               $this->assertTrue(count($entriesFound) == 0);
+       }
+
+       /**
+        * @test
+        */
+       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
+               $backend = $this->setUpBackend();
+               $mockCache = $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemovalTest';
+               $backend->set($entryIdentifier . 'A', $data, array(), 1);
+               $backend->set($entryIdentifier . 'B', $data, array(), 1);
+               $backend->set($entryIdentifier . 'C', $data, array(), 1);
+               $GLOBALS['EXEC_TIME'] += 2;
+               // setCache calls initializeCommonReferences which recalculate expire statement
+               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
+               $backend->setCache($mockCache);
+               $backend->collectGarbage();
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, '');
+               $this->assertTrue(count($entriesFound) == 0);
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
+               $expectedEntry = 'BackendDbTest2';
+               $actualEntries = $backend->findIdentifiersByTag('UnitTestTag%special');
+               $this->assertTrue(is_array($actualEntries));
+               $this->assertEquals($expectedEntry, array_pop($actualEntries));
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function flushThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->flush();
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $backend->set('BackendDbTest1', $data, array('UnitTestTag%test'));
+               $backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
+               $backend->flush();
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingCacheTable, '');
+               $this->assertTrue(count($entriesFound) == 0);
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function flushByTagThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->flushByTag(array());
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
+               $backend->flushByTag('UnitTestTag%special');
+               $this->assertTrue($backend->has('BackendDbTest1'), 'BackendDbTest1 does not exist anymore.');
+               $this->assertFalse($backend->has('BackendDbTest2'), 'BackendDbTest2 still exists.');
+               $this->assertTrue($backend->has('BackendDbTest3'), 'BackendDbTest3 does not exist anymore.');
+               $tagEntriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $this->testingTagsTable, 'tag = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('UnitTestTag%special', $this->testingTagsTable));
+               $this->assertEquals(0, count($tagEntriesFound));
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsTheCorrectResultForEntryWithExceededLifetime() {
+               $backend = $this->setUpBackend();
+               $mockCache = $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
+               $expiredData = 'some old data' . microtime();
+               $backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
+               $GLOBALS['EXEC_TIME'] += 2;
+               // setCache calls initializeCommonReferences which recalculate expire statement
+               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
+               $backend->setCache($mockCache);
+               $this->assertFalse($backend->has($expiredEntryIdentifier));
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsTrueForEntryWithUnlimitedLifetime() {
+               $backend = $this->setUpBackend();
+               $mockCache = $this->setUpMockFrontendOfBackend($backend);
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, 'data', array(), 0);
+               $GLOBALS['EXEC_TIME'] += 1;
+               // setCache calls initializeCommonReferences which recalculate expire statement
+               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
+               $backend->setCache($mockCache);
+               $this->assertTrue($backend->has($entryIdentifier));
+       }
+
+       /**
+        * @test
+        */
+       public function getReturnsFalseForEntryWithExceededLifetime() {
+               $backend = $this->setUpBackend();
+               $mockCache = $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+               $backend->set($entryIdentifier, $data);
+               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
+               $expiredData = 'some old data' . microtime();
+               $backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
+               $GLOBALS['EXEC_TIME'] += 2;
+               // setCache calls initializeCommonReferences which recalculate expire statement
+               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
+               $backend->setCache($mockCache);
+               $this->assertEquals($data, $backend->get($entryIdentifier));
+               $this->assertFalse($backend->get($expiredEntryIdentifier));
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function findIdentifiersByTagThrowsExceptionIfFrontendWasNotSet() {
+               $backend = $this->setUpBackend();
+               $backend->findIdentifiersByTag('identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagReturnsEmptyArrayForEntryWithExceededLifetime() {
+               $backend = $this->setUpBackend();
+               $mockCache = $this->setUpMockFrontendOfBackend($backend);
+               $backend->set('BackendDbTest', 'some data', array('UnitTestTag%special'), 1);
+               $GLOBALS['EXEC_TIME'] += 2;
+               // setCache calls initializeCommonReferences which recalculate expire statement
+               // needed after manual $GLOBALS['EXEC_TIME'] manipulation
+               $backend->setCache($mockCache);
+               $this->assertEquals(array(), $backend->findIdentifiersByTag('UnitTestTag%special'));
+       }
+
+       /**
+        * @test
+        */
+       public function setWithUnlimitedLifetimeWritesCorrectEntry() {
+               $backend = $this->setUpBackend();
+               $this->setUpMockFrontendOfBackend($backend);
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileTest';
+               $backend->set($entryIdentifier, $data, array(), 0);
+               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->testingCacheTable, '');
+               $this->assertTrue(is_array($entryFound));
+               $retrievedData = $entryFound['content'];
+               $this->assertEquals($data, $retrievedData);
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/FileBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/FileBackendTest.php
new file mode 100644 (file)
index 0000000..e157298
--- /dev/null
@@ -0,0 +1,622 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Testcase for the File cache backend
+ *
+ * This file is a backport from FLOW3
+ *
+ * @author Ingo Renner <ingo@typo3.org>
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class FileBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serialization
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * Sets up this testcase
+        *
+        * @return void
+        */
+       public function setUp() {
+               if (!class_exists('\vfsStreamWrapper')) {
+                       $this->markTestSkipped('File backend tests are not available with this phpunit version.');
+               }
+
+               \vfsStreamWrapper::register();
+               \vfsStreamWrapper::setRoot(new \vfsStreamDirectory('Foo'));
+       }
+
+       /**
+        * @test
+        * @expectedException \t3lib_cache_Exception
+        */
+       public function setCacheDirectoryThrowsExceptionOnNonWritableDirectory() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('http://localhost/');
+
+               $backend->setCache($mockCache);
+       }
+
+       /**
+        * @test
+        */
+       public function getCacheDirectoryReturnsTheCurrentCacheDirectory() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $this->assertEquals('vfs://Foo/Cache/Data/SomeCache/', $backend->getCacheDirectory());
+       }
+
+       /**
+        * @test
+        */
+       public function aDedicatedCacheDirectoryIsUsedForCodeCaches() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_PhpFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $this->assertEquals('vfs://Foo/Cache/Code/SomeCache/', $backend->getCacheDirectory());
+       }
+
+       /**
+        * @test
+        * @expectedException t3lib_cache_exception_InvalidData
+        */
+       public function setThrowsExceptionIfDataIsNotAString() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set('some identifier', array('not a string'));
+       }
+
+       /**
+        * @test
+        */
+       public function setReallySavesToTheSpecifiedDirectory() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileTest';
+               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set($entryIdentifier, $data);
+
+               $this->assertFileExists($pathAndFilename);
+               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data));
+               $this->assertEquals($data, $retrievedData);
+       }
+
+       /**
+        * @test
+        */
+       public function setOverwritesAnAlreadyExistingCacheEntryForTheSameIdentifier() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $data1 = 'some data' . microtime();
+               $data2 = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileRemoveBeforeSetTest';
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set($entryIdentifier, $data1, array(), 500);
+               $backend->set($entryIdentifier, $data2, array(), 200);
+
+               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+               $this->assertFileExists($pathAndFilename);
+               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data2));
+               $this->assertEquals($data2, $retrievedData);
+       }
+
+       /**
+        * @test
+        */
+       public function setAlsoSavesSpecifiedTags() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileRemoveBeforeSetTest';
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set($entryIdentifier, $data, array('Tag1', 'Tag2'));
+
+               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+               $this->assertFileExists($pathAndFilename);
+               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, (strlen($data) + \TYPO3\CMS\Core\Cache\Backend\FileBackend::EXPIRYTIME_LENGTH), 9);
+               $this->assertEquals('Tag1 Tag2', $retrievedData);
+       }
+
+       /**
+        * @test
+        */
+       public function setCacheDetectsAndLoadsAFrozenCache() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileTest';
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set($entryIdentifier, $data, array('Tag1', 'Tag2'));
+
+               $backend->freeze();
+
+               unset($backend);
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $this->assertTrue($backend->isFrozen());
+               $this->assertEquals($data, $backend->get($entryIdentifier));
+       }
+
+       /**
+        * @test
+        */
+       public function getReturnsContentOfTheCorrectCacheFile() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('setTag'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $entryIdentifier = 'BackendFileTest';
+
+               $data = 'some data' . microtime();
+               $backend->set($entryIdentifier, $data, array(), 500);
+
+               $data = 'some other data' . microtime();
+               $backend->set($entryIdentifier, $data, array(), 100);
+
+               $loadedData = $backend->get($entryIdentifier);
+               $this->assertEquals($data, $loadedData);
+       }
+
+       /**
+        * @test
+        */
+       public function getReturnsFalseForExpiredEntries() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
+               $backend->expects($this->once())->method('isCacheFileExpired')->with('vfs://Foo/Cache/Data/UnitTestCache/ExpiredEntry')->will($this->returnValue(TRUE));
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $this->assertFalse($backend->get('ExpiredEntry'));
+       }
+
+       /**
+        * @test
+        */
+       public function getDoesNotCheckIfAnEntryIsExpiredIfTheCacheIsFrozen() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->expects($this->once())->method('isCacheFileExpired');
+
+               $backend->set('foo', 'some data');
+               $backend->freeze();
+               $this->assertEquals('some data', $backend->get('foo'));
+               $this->assertFalse($backend->get('bar'));
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsTrueIfAnEntryExists() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $entryIdentifier = 'BackendFileTest';
+
+               $data = 'some data' . microtime();
+               $backend->set($entryIdentifier, $data);
+
+               $this->assertTrue($backend->has($entryIdentifier), 'has() did not return TRUE.');
+               $this->assertFalse($backend->has($entryIdentifier . 'Not'), 'has() did not return FALSE.');
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsFalseForExpiredEntries() {
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
+               $backend->expects($this->exactly(2))->method('isCacheFileExpired')->will($this->onConsecutiveCalls(TRUE, FALSE));
+
+               $this->assertFalse($backend->has('foo'));
+               $this->assertTrue($backend->has('bar'));
+       }
+
+       /**
+        * @test
+        */
+       public function hasDoesNotCheckIfAnEntryIsExpiredIfTheCacheIsFrozen() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->expects($this->once())->method('isCacheFileExpired'); // Indirectly called by freeze() -> get()
+
+               $backend->set('foo', 'some data');
+               $backend->freeze();
+               $this->assertTrue($backend->has('foo'));
+               $this->assertFalse($backend->has('bar'));
+       }
+
+       /**
+        * @test
+        */
+       public function removeReallyRemovesACacheEntry() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileTest';
+               $pathAndFilename = 'vfs://Foo/Cache/Data/UnitTestCache/' . $entryIdentifier;
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set($entryIdentifier, $data);
+               $this->assertFileExists($pathAndFilename);
+
+               $backend->remove($entryIdentifier);
+               $this->assertFileNotExists($pathAndFilename);
+       }
+
+       /**
+        */
+       public function invalidEntryIdentifiers() {
+               return array(
+                       'trailing slash' => array('/myIdentifer'),
+                       'trailing dot and slash' => array('./myIdentifer'),
+                       'trailing two dots and slash' => array('../myIdentifier'),
+                       'trailing with multiple dots and slashes' => array('.././../myIdentifier'),
+                       'slash in middle part' => array('my/Identifier'),
+                       'dot and slash in middle part' => array('my./Identifier'),
+                       'two dots and slash in middle part' => array('my../Identifier'),
+                       'multiple dots and slashes in middle part' => array('my.././../Identifier'),
+                       'pending slash' => array('myIdentifier/'),
+                       'pending dot and slash' => array('myIdentifier./'),
+                       'pending dots and slash' => array('myIdentifier../'),
+                       'pending multiple dots and slashes' => array('myIdentifier.././../'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        */
+       public function setThrowsExceptionForInvalidIdentifier($identifier) {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array('test'), '', TRUE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->set($identifier, 'cache data', array());
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        */
+       public function getThrowsExceptionForInvalidIdentifier($identifier) {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->get($identifier);
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        */
+       public function hasThrowsExceptionForInvalidIdentifier($identifier) {
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+
+               $backend->has($identifier);
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        */
+       public function removeThrowsExceptionForInvalidIdentifier($identifier) {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->remove($identifier);
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        */
+       public function requireOnceThrowsExceptionForInvalidIdentifier($identifier) {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->requireOnce($identifier);
+       }
+
+       /**
+        * @test
+        */
+       public function requireOnceIncludesAndReturnsResultOfIncludedPhpFile() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $entryIdentifier = 'SomePhpEntry';
+
+               $data = '<?php return "foo"; ?>';
+               $backend->set($entryIdentifier, $data);
+
+               $loadedData = $backend->requireOnce($entryIdentifier);
+               $this->assertEquals('foo', $loadedData);
+       }
+
+       /**
+        * @test
+        */
+       public function requireOnceDoesNotCheckExpiryTimeIfBackendIsFrozen() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+                               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->expects($this->once())->method('isCacheFileExpired'); // Indirectly called by freeze() -> get()
+
+               $data = '<?php return "foo"; ?>';
+               $backend->set('FooEntry', $data);
+
+               $backend->freeze();
+
+               $loadedData = $backend->requireOnce('FooEntry');
+               $this->assertEquals('foo', $loadedData);
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $data = 'some data' . microtime();
+               $backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
+
+               $expectedEntry = 'BackendFileTest2';
+
+               $actualEntries = $backend->findIdentifiersByTag('UnitTestTag%special');
+               $this->assertInternalType('array', $actualEntries);
+               $this->assertEquals($expectedEntry, array_pop($actualEntries));
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagDoesNotReturnExpiredEntries() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $data = 'some data';
+               $backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'), -100);
+               $backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
+
+               $this->assertSame(array(), $backend->findIdentifiersByTag('UnitTestTag%special'));
+               $this->assertSame(array('BackendFileTest1', 'BackendFileTest3'), $backend->findIdentifiersByTag('UnitTestTag%test'));
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $data = 'some data';
+               $backend->set('BackendFileTest1', $data);
+               $backend->set('BackendFileTest2', $data);
+
+               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
+               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+
+               $backend->flush();
+
+               $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
+               $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+       }
+
+       /**
+        * @test
+        */
+       public function flushCreatesCacheDirectoryAgain() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->flush();
+               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/');
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('findIdentifiersByTag', 'remove'), array(), '', FALSE);
+
+               $backend->expects($this->once())->method('findIdentifiersByTag')->with('UnitTestTag%special')->will($this->returnValue(array('foo', 'bar', 'baz')));
+               $backend->expects($this->at(1))->method('remove')->with('foo');
+               $backend->expects($this->at(2))->method('remove')->with('bar');
+               $backend->expects($this->at(3))->method('remove')->with('baz');
+
+               $backend->flushByTag('UnitTestTag%special');
+       }
+
+       /**
+        * @test
+        */
+       public function collectGarbageRemovesExpiredCacheEntries() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('isCacheFileExpired'), array(), '', FALSE);
+               $backend->expects($this->exactly(2))->method('isCacheFileExpired')->will($this->onConsecutiveCalls(TRUE, FALSE));
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $data = 'some data';
+               $backend->set('BackendFileTest1', $data);
+               $backend->set('BackendFileTest2', $data);
+
+               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
+               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+
+               $backend->collectGarbage();
+               $this->assertFileNotExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest1');
+               $this->assertFileExists('vfs://Foo/Cache/Data/UnitTestCache/BackendFileTest2');
+       }
+
+       /**
+        * @test
+        */
+       public function flushUnfreezesTheCache() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend', array('dummy'), array(), '', FALSE);
+               $backend->setCacheDirectory('vfs://Foo/');
+               $backend->setCache($mockCache);
+
+               $backend->freeze();
+
+               $this->assertTrue($backend->isFrozen());
+               $backend->flush();
+               $this->assertFalse($backend->isFrozen());
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/MemcachedBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/MemcachedBackendTest.php
new file mode 100644 (file)
index 0000000..fa66835
--- /dev/null
@@ -0,0 +1,261 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the cache to memcached backend
+ *
+ * This file is a backport from FLOW3
+ *
+ * @author Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class MemcachedBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Sets up this testcase
+        *
+        * @return void
+        */
+       public function setUp() {
+               if (!extension_loaded('memcache')) {
+                       $this->markTestSkipped('memcache extension was not available');
+               }
+               try {
+                       if (!fsockopen('localhost', 11211)) {
+                               $this->markTestSkipped('memcached not reachable');
+                       }
+               } catch (\Exception $e) {
+                       $this->markTestSkipped('memcached not reachable');
+               }
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backendOptions = array('servers' => array('localhost:11211'));
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
+               $backend->initializeObject();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function initializeObjectThrowsExceptionIfNoMemcacheServerIsConfigured() {
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing');
+               $backend->initializeObject();
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache, 'Memcache failed to set and check entry');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData, 'Memcache failed to set and retrieve data');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, 'Failed to set and remove data from Memcache');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $otherData = 'some other data';
+               $backend->set($identifier, $otherData);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($otherData, $fetchedData, 'Memcache failed to overwrite and retrieve data');
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
+               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
+               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
+       }
+
+       /**
+        * @test
+        */
+       public function setRemovesTagsFromPreviousSet() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $backend->set($identifier, $data, array('UnitTestTag%tag3'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
+               $this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, '"has" did not return FALSE when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache, '"remove" did not return FALSE when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('BackendMemcacheTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendMemcacheTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendMemcacheTest3', $data, array('UnitTestTag%test'));
+               $backend->flushByTag('UnitTestTag%special');
+               $this->assertTrue($backend->has('BackendMemcacheTest1'), 'BackendMemcacheTest1');
+               $this->assertFalse($backend->has('BackendMemcacheTest2'), 'BackendMemcacheTest2');
+               $this->assertTrue($backend->has('BackendMemcacheTest3'), 'BackendMemcacheTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('BackendMemcacheTest1', $data);
+               $backend->set('BackendMemcacheTest2', $data);
+               $backend->set('BackendMemcacheTest3', $data);
+               $backend->flush();
+               $this->assertFalse($backend->has('BackendMemcacheTest1'), 'BackendMemcacheTest1');
+               $this->assertFalse($backend->has('BackendMemcacheTest2'), 'BackendMemcacheTest2');
+               $this->assertFalse($backend->has('BackendMemcacheTest3'), 'BackendMemcacheTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $backendOptions = array('servers' => array('localhost:11211'));
+               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
+               $thisBackend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
+               $thisBackend->setCache($thisCache);
+               $thisBackend->initializeObject();
+               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE);
+               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
+               $thatBackend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
+               $thatBackend->setCache($thatCache);
+               $thatBackend->initializeObject();
+               $thisBackend->set('thisEntry', 'Hello');
+               $thatBackend->set('thatEntry', 'World!');
+               $thatBackend->flush();
+               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
+               $this->assertFalse($thatBackend->has('thatEntry'));
+       }
+
+       /**
+        * Check if we can store ~5 MB of data, this gives some headroom for the
+        * reflection data.
+        *
+        * @test
+        */
+       public function largeDataIsStored() {
+               $backend = $this->setUpBackend();
+               $data = str_repeat('abcde', 1024 * 1024);
+               $backend->set('tooLargeData', $data);
+               $this->assertTrue($backend->has('tooLargeData'));
+               $this->assertEquals($backend->get('tooLargeData'), $data);
+       }
+
+       /**
+        * Sets up the memcached backend used for testing
+        *
+        * @param array $backendOptions Options for the memcache backend
+        * @return \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend
+        */
+       protected function setUpBackend(array $backendOptions = array()) {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               if ($backendOptions == array()) {
+                       $backendOptions = array('servers' => array('localhost:11211'));
+               }
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\MemcachedBackend('Testing', $backendOptions);
+               $backend->setCache($cache);
+               $backend->initializeObject();
+               return $backend;
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/MockBackend.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/MockBackend.php
new file mode 100644 (file)
index 0000000..5e21da9
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * A caching backend which forgets everything immediately
+ * Used in FactoryTest
+ *
+ * This file is a backport from FLOW3
+ *
+ * @author Robert Lemke <robert@typo3.org>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class MockBackend extends \TYPO3\CMS\Core\Cache\Backend\NullBackend {
+
+       /**
+        * @var mixed
+        */
+       protected $someOption;
+
+       /**
+        * Sets some option
+        *
+        * @param mixed $value
+        * @return void
+        */
+       public function setSomeOption($value) {
+               $this->someOption = $value;
+       }
+
+       /**
+        * Returns the option value
+        *
+        * @return mixed
+        */
+       public function getSomeOption() {
+               return $this->someOption;
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php
new file mode 100644 (file)
index 0000000..c0f2341
--- /dev/null
@@ -0,0 +1,268 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the PDO cache backend
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class PdoBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * Sets up this testcase
+        */
+       public function setUp() {
+               if (!extension_loaded('pdo_sqlite')) {
+                       $this->markTestSkipped('pdo_sqlite extension was not available');
+               }
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\PdoBackend('Testing');
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $this->assertTrue($backend->has($identifier));
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $this->assertFalse($backend->has($identifier));
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $otherData = 'some other data';
+               $backend->set($identifier, $otherData);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($otherData, $fetchedData);
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsSetEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $entryIdentifier = 'MyIdentifier';
+               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
+               $this->assertEquals($entryIdentifier, $retrieved[0]);
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
+               $this->assertEquals($entryIdentifier, $retrieved[0]);
+       }
+
+       /**
+        * @test
+        */
+       public function setRemovesTagsFromPreviousSet() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $entryIdentifier = 'MyIdentifier';
+               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag3'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
+               $this->assertEquals(array(), $retrieved);
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier';
+               $this->assertFalse($backend->has($identifier));
+       }
+
+       /**
+        * @test
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier';
+               $this->assertFalse($backend->remove($identifier));
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('PdoBackendTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('PdoBackendTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('PdoBackendTest3', $data, array('UnitTestTag%test'));
+               $backend->flushByTag('UnitTestTag%special');
+               $this->assertTrue($backend->has('PdoBackendTest1'), 'PdoBackendTest1');
+               $this->assertFalse($backend->has('PdoBackendTest2'), 'PdoBackendTest2');
+               $this->assertTrue($backend->has('PdoBackendTest3'), 'PdoBackendTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('PdoBackendTest1', $data);
+               $backend->set('PdoBackendTest2', $data);
+               $backend->set('PdoBackendTest3', $data);
+               $backend->flush();
+               $this->assertFalse($backend->has('PdoBackendTest1'), 'PdoBackendTest1');
+               $this->assertFalse($backend->has('PdoBackendTest2'), 'PdoBackendTest2');
+               $this->assertFalse($backend->has('PdoBackendTest3'), 'PdoBackendTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
+               $thisBackend = $this->setUpBackend();
+               $thisBackend->setCache($thisCache);
+               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
+               $thatBackend = $this->setUpBackend();
+               $thatBackend->setCache($thatCache);
+               $thisBackend->set('thisEntry', 'Hello');
+               $thatBackend->set('thatEntry', 'World!');
+               $thatBackend->flush();
+               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
+               $this->assertFalse($thatBackend->has('thatEntry'));
+       }
+
+       /**
+        * @test
+        */
+       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendPDORemovalTest';
+               $backend->set($entryIdentifier, $data, array(), 1);
+               $this->assertTrue($backend->has($entryIdentifier));
+               $GLOBALS['EXEC_TIME'] += 2;
+               $backend->collectGarbage();
+               $this->assertFalse($backend->has($entryIdentifier));
+       }
+
+       /**
+        * @test
+        */
+       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendPDORemovalTest';
+               $backend->set($entryIdentifier . 'A', $data, array(), NULL);
+               $backend->set($entryIdentifier . 'B', $data, array(), 10);
+               $backend->set($entryIdentifier . 'C', $data, array(), 1);
+               $backend->set($entryIdentifier . 'D', $data, array(), 1);
+               $this->assertTrue($backend->has($entryIdentifier . 'A'));
+               $this->assertTrue($backend->has($entryIdentifier . 'B'));
+               $this->assertTrue($backend->has($entryIdentifier . 'C'));
+               $this->assertTrue($backend->has($entryIdentifier . 'D'));
+               $GLOBALS['EXEC_TIME'] += 2;
+               $backend->collectGarbage();
+               $this->assertTrue($backend->has($entryIdentifier . 'A'));
+               $this->assertTrue($backend->has($entryIdentifier . 'B'));
+               $this->assertFalse($backend->has($entryIdentifier . 'C'));
+               $this->assertFalse($backend->has($entryIdentifier . 'D'));
+       }
+
+       /**
+        * Sets up the PDO backend used for testing
+        *
+        * @return \TYPO3\CMS\Core\Cache\Backend\PdoBackend
+        */
+       protected function setUpBackend() {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
+               $backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\Backend\\PdoBackend', 'Testing');
+               $backend->setCache($mockCache);
+               $backend->setDataSourceName('sqlite::memory:');
+               $backend->initializeObject();
+               return $backend;
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php
new file mode 100644 (file)
index 0000000..f291fc9
--- /dev/null
@@ -0,0 +1,838 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the cache to redis backend
+ *
+ * This class has functional tests as well as implementation tests:
+ * - The functional tests make API calls to the backend and check expected behaviour
+ * - The implementation tests make additional calls with an own redis instance to
+ * check stored data structures in the redis server, which can not be checked
+ * by functional tests alone. Those tests will fail if any changes
+ * to the internal data structure are done.
+ *
+ * Warning:
+ * The unit tests use and flush redis database numbers 0 and 1!
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class RedisBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
+        * If set, the tearDown() method will flush the cache used by this unit test.
+        *
+        * @var \TYPO3\CMS\Core\Cache\Backend\RedisBackend
+        */
+       protected $backend = NULL;
+
+       /**
+        * Own redis instance used in implementation tests
+        *
+        * @var Redis
+        */
+       protected $redis = NULL;
+
+       /**
+        * Set up this testcase
+        */
+       public function setUp() {
+               if (!extension_loaded('redis')) {
+                       $this->markTestSkipped('redis extension was not available');
+               }
+               try {
+                       if (!@fsockopen('127.0.0.1', 6379)) {
+                               $this->markTestSkipped('redis server not reachable');
+                       }
+               } catch (\Exception $e) {
+                       $this->markTestSkipped('redis server not reachable');
+               }
+       }
+
+       /**
+        * Sets up the redis backend used for testing
+        *
+        * @param array $backendOptions Options for the redis backend
+        */
+       protected function setUpBackend(array $backendOptions = array()) {
+               $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
+               $this->backend = new \TYPO3\CMS\Core\Cache\Backend\RedisBackend('Testing', $backendOptions);
+               $this->backend->setCache($mockCache);
+               $this->backend->initializeObject();
+       }
+
+       /**
+        * Sets up an own redis instance for implementation tests
+        */
+       protected function setUpRedis() {
+               $this->redis = new \Redis();
+               $this->redis->connect('127.0.0.1', 6379);
+       }
+
+       /**
+        * Tear down this testcase
+        */
+       public function tearDown() {
+               if ($this->backend instanceof \TYPO3\CMS\Core\Cache\Backend\RedisBackend) {
+                       $this->backend->flush();
+               }
+       }
+
+       /**
+        * @test Functional
+        */
+       public function initializeObjectThrowsNoExceptionIfGivenDatabaseWasSuccessfullySelected() {
+               try {
+                       $this->setUpBackend(array('database' => 1));
+               } catch (Exception $e) {
+                       $this->assertTrue();
+               }
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNotAnInteger() {
+               $this->setUpBackend(array('database' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNegative() {
+               $this->setUpBackend(array('database' => -1));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setCompressionThrowsExceptionIfCompressionParameterIsNotOfTypeBoolean() {
+               $this->setUpBackend(array('compression' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotInteger() {
+               $this->setUpBackend(array('compressionLevel' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotBetweenMinusOneAndNine() {
+               $this->setUpBackend(array('compressionLevel' => 11));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->set(array(), 'data');
+       }
+
+       /**
+        * @test Functional
+        * @expectedException t3lib_cache_Exception_InvalidData
+        */
+       public function setThrowsExceptionIfDataIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->set('identifier' . uniqid(), array());
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setThrowsExceptionIfLifetimeIsNegative() {
+               $this->setUpBackend();
+               $this->backend->set('identifier' . uniqid(), 'data', array(), -42);
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function setThrowsExceptionIfLifetimeIsNotNullOrAnInteger() {
+               $this->setUpBackend();
+               $this->backend->set('identifier' . uniqid(), 'data', array(), array());
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setStoresEntriesInSelectedDatabase() {
+               $this->setUpRedis();
+               $this->redis->select(1);
+               $this->setUpBackend(array('database' => 1));
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->assertTrue($this->redis->exists('identData:' . $identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesStringDataTypeForIdentifierToDataEntry() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->assertSame(\Redis::REDIS_STRING, $this->redis->type('identData:' . $identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesEntryWithDefaultLifeTime() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $defaultLifetime = 42;
+               $this->backend->setDefaultLifetime($defaultLifetime);
+               $this->backend->set($identifier, 'data');
+               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
+               $this->assertSame($defaultLifetime, $lifetimeRegisteredInBackend);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesEntryWithSpecifiedLifeTime() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $lifetime = 43;
+               $this->backend->set($identifier, 'data', array(), $lifetime);
+               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
+               $this->assertSame($lifetime, $lifetimeRegisteredInBackend);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesEntryWithUnlimitedLifeTime() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data', array(), 0);
+               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
+               $this->assertSame(31536000, $lifetimeRegisteredInBackend);
+       }
+
+       /**
+        * @test Functional
+        */
+       public function setOverwritesExistingEntryWithNewData() {
+               $this->setUpBackend();
+               $data = 'data 1';
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, $data);
+               $otherData = 'data 2';
+               $this->backend->set($identifier, $otherData);
+               $fetchedData = $this->backend->get($identifier);
+               $this->assertSame($otherData, $fetchedData);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setOverwritesExistingEntryWithSpecifiedLifetime() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $data = 'data';
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, $data);
+               $lifetime = 42;
+               $this->backend->set($identifier, $data, array(), $lifetime);
+               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
+               $this->assertSame($lifetime, $lifetimeRegisteredInBackend);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setOverwritesExistingEntryWithNewDefaultLifetime() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $data = 'data';
+               $identifier = 'identifier' . uniqid();
+               $lifetime = 42;
+               $this->backend->set($identifier, $data, array(), $lifetime);
+               $newDefaultLifetime = 43;
+               $this->backend->setDefaultLifetime($newDefaultLifetime);
+               $this->backend->set($identifier, $data, array(), $newDefaultLifetime);
+               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
+               $this->assertSame($newDefaultLifetime, $lifetimeRegisteredInBackend);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setOverwritesExistingEntryWithNewUnlimitedLifetime() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $data = 'data';
+               $identifier = 'identifier' . uniqid();
+               $lifetime = 42;
+               $this->backend->set($identifier, $data, array(), $lifetime);
+               $this->backend->set($identifier, $data, array(), 0);
+               $lifetimeRegisteredInBackend = $this->redis->ttl('identData:' . $identifier);
+               $this->assertSame(31536000, $lifetimeRegisteredInBackend);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesSetDataTypeForIdentifierToTagsSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data', array('tag'));
+               $this->assertSame(\Redis::REDIS_SET, $this->redis->type('identTags:' . $identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesSpecifiedTagsInIdentifierToTagsSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tags = array('thatTag', 'thisTag');
+               $this->backend->set($identifier, 'data', $tags);
+               $savedTags = $this->redis->sMembers('identTags:' . $identifier);
+               sort($savedTags);
+               $this->assertSame($tags, $savedTags);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setRemovesAllPreviouslySetTagsFromIdentifierToTagsSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tags = array('fooTag', 'barTag');
+               $this->backend->set($identifier, 'data', $tags);
+               $this->backend->set($identifier, 'data', array());
+               $this->assertSame(array(), $this->redis->sMembers('identTags:' . $identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setRemovesMultiplePreviouslySetTagsFromIdentifierToTagsSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $firstTagSet = array('tag1', 'tag2', 'tag3', 'tag4');
+               $this->backend->set($identifier, 'data', $firstTagSet);
+               $secondTagSet = array('tag1', 'tag3');
+               $this->backend->set($identifier, 'data', $secondTagSet);
+               $actualTagSet = $this->redis->sMembers('identTags:' . $identifier);
+               sort($actualTagSet);
+               $this->assertSame($secondTagSet, $actualTagSet);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesSetDataTypeForTagToIdentifiersSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'tag';
+               $this->backend->set($identifier, 'data', array($tag));
+               $this->assertSame(\Redis::REDIS_SET, $this->redis->type('tagIdents:' . $tag));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesIdentifierInTagToIdentifiersSetOfSpecifiedTag() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'thisTag';
+               $this->backend->set($identifier, 'data', array($tag));
+               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
+               $this->assertSame(array($identifier), $savedTagToIdentifiersMemberArray);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setAppendsSecondIdentifierInTagToIdentifiersEntry() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $firstIdentifier = 'identifier' . uniqid();
+               $tag = 'thisTag';
+               $this->backend->set($firstIdentifier, 'data', array($tag));
+               $secondIdentifier = 'identifier' . uniqid();
+               $this->backend->set($secondIdentifier, 'data', array($tag));
+               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
+               sort($savedTagToIdentifiersMemberArray);
+               $identifierArray = array($firstIdentifier, $secondIdentifier);
+               sort($identifierArray);
+               $this->assertSame(array($firstIdentifier, $secondIdentifier), $savedTagToIdentifiersMemberArray);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setRemovesIdentifierFromTagToIdentifiersEntryIfTagIsOmittedOnConsecutiveSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'thisTag';
+               $this->backend->set($identifier, 'data', array($tag));
+               $this->backend->set($identifier, 'data', array());
+               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
+               $this->assertSame(array(), $savedTagToIdentifiersMemberArray);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setAddsIdentifierInTagToIdentifiersEntryIfTagIsAddedOnConsecutiveSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $tag = 'thisTag';
+               $this->backend->set($identifier, 'data', array($tag));
+               $savedTagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
+               $this->assertSame(array($identifier), $savedTagToIdentifiersMemberArray);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesCompressedDataWithEnabledCompression() {
+               $this->setUpBackend(array(
+                       'compression' => TRUE
+               ));
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $data = 'some data ' . microtime();
+               $this->backend->set($identifier, $data);
+               $uncompresedStoredData = '';
+               try {
+                       $uncompresedStoredData = @gzuncompress($this->redis->get(('identData:' . $identifier)));
+               } catch (\Exception $e) {
+
+               }
+               $this->assertEquals($data, $uncompresedStoredData, 'Original and compressed data don\'t match');
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function setSavesPlaintextDataWithEnabledCompressionAndCompressionLevel0() {
+               $this->setUpBackend(array(
+                       'compression' => TRUE,
+                       'compressionLevel' => 0
+               ));
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $data = 'some data ' . microtime();
+               $this->backend->set($identifier, $data);
+               $this->assertGreaterThan(0, substr_count($this->redis->get('identData:' . $identifier), $data), 'Plaintext data not found');
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function hasThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->has(array());
+       }
+
+       /**
+        * @test Functional
+        */
+       public function hasReturnsFalseForNotExistingEntry() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->assertFalse($this->backend->has($identifier));
+       }
+
+       /**
+        * @test Functional
+        */
+       public function hasReturnsTrueForPreviouslySetEntry() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->assertTrue($this->backend->has($identifier));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function getThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->get(array());
+       }
+
+       /**
+        * @test Functional
+        */
+       public function getReturnsPreviouslyCompressedSetEntry() {
+               $this->setUpBackend(array(
+                       'compression' => TRUE
+               ));
+               $data = 'data';
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, $data);
+               $fetchedData = $this->backend->get($identifier);
+               $this->assertSame($data, $fetchedData);
+       }
+
+       /**
+        * @test Functional
+        */
+       public function getReturnsPreviouslySetEntry() {
+               $this->setUpBackend();
+               $data = 'data';
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, $data);
+               $fetchedData = $this->backend->get($identifier);
+               $this->assertSame($data, $fetchedData);
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function removeThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->remove(array());
+       }
+
+       /**
+        * @test Functional
+        */
+       public function removeReturnsFalseIfNoEntryWasDeleted() {
+               $this->setUpBackend();
+               $this->assertFalse($this->backend->remove('identifier' . uniqid()));
+       }
+
+       /**
+        * @test Functional
+        */
+       public function removeReturnsTrueIfAnEntryWasDeleted() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->assertTrue($this->backend->remove($identifier));
+       }
+
+       /**
+        * @test Functional
+        */
+       public function removeDeletesEntryFromCache() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->backend->remove($identifier);
+               $this->assertFalse($this->backend->has($identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function removeDeletesIdentifierToTagEntry() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'thisTag';
+               $this->backend->set($identifier, 'data', array($tag));
+               $this->backend->remove($identifier);
+               $this->assertFalse($this->redis->exists('identTags:' . $identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function removeDeletesIdentifierFromTagToIdentifiersSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'thisTag';
+               $this->backend->set($identifier, 'data', array($tag));
+               $this->backend->remove($identifier);
+               $tagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
+               $this->assertSame(array(), $tagToIdentifiersMemberArray);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function removeDeletesIdentifierFromTagToIdentifiersSetWithMultipleEntries() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $firstIdentifier = 'identifier' . uniqid();
+               $secondIdentifier = 'identifier' . uniqid();
+               $tag = 'thisTag';
+               $this->backend->set($firstIdentifier, 'data', array($tag));
+               $this->backend->set($secondIdentifier, 'data', array($tag));
+               $this->backend->remove($firstIdentifier);
+               $tagToIdentifiersMemberArray = $this->redis->sMembers('tagIdents:' . $tag);
+               $this->assertSame(array($secondIdentifier), $tagToIdentifiersMemberArray);
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function findIdentifiersByTagThrowsExceptionIfTagIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->findIdentifiersByTag(array());
+       }
+
+       /**
+        * @test Functional
+        */
+       public function findIdentifiersByTagReturnsEmptyArrayForNotExistingTag() {
+               $this->setUpBackend();
+               $this->assertSame(array(), $this->backend->findIdentifiersByTag('thisTag'));
+       }
+
+       /**
+        * @test Functional
+        */
+       public function findIdentifiersByTagReturnsAllIdentifiersTagedWithSpecifiedTag() {
+               $this->setUpBackend();
+               $firstIdentifier = 'identifier' . uniqid();
+               $secondIdentifier = 'identifier' . uniqid();
+               $thirdIdentifier = 'identifier' . uniqid();
+               $tagsForFirstIdentifier = array('thisTag');
+               $tagsForSecondIdentifier = array('thatTag');
+               $tagsForThirdIdentifier = array('thisTag', 'thatTag');
+               $this->backend->set($firstIdentifier, 'data', $tagsForFirstIdentifier);
+               $this->backend->set($secondIdentifier, 'data', $tagsForSecondIdentifier);
+               $this->backend->set($thirdIdentifier, 'data', $tagsForThirdIdentifier);
+               $expectedResult = array($firstIdentifier, $thirdIdentifier);
+               $actualResult = $this->backend->findIdentifiersByTag('thisTag');
+               sort($actualResult);
+               $this->assertSame($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function flushRemovesAllEntriesFromCache() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->backend->flush();
+               $this->assertSame(array(), $this->redis->getKeys('*'));
+       }
+
+       /**
+        * @test Functional
+        * @expectedException \InvalidArgumentException
+        */
+       public function flushByTagThrowsExceptionIfTagIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->flushByTag(array());
+       }
+
+       /**
+        * @test Functional
+        */
+       public function flushByTagRemovesEntriesTaggedWithSpecifiedTag() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag1'));
+               $this->backend->set($identifier . 'B', 'data', array('tag2'));
+               $this->backend->set($identifier . 'C', 'data', array('tag1', 'tag2'));
+               $this->backend->flushByTag('tag1');
+               $expectedResult = array(FALSE, TRUE, FALSE);
+               $actualResult = array(
+                       $this->backend->has($identifier . 'A'),
+                       $this->backend->has($identifier . 'B'),
+                       $this->backend->has($identifier . 'C')
+               );
+               $this->assertSame($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function flushByTagRemovesTemporarySet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag1'));
+               $this->backend->set($identifier . 'C', 'data', array('tag1', 'tag2'));
+               $this->backend->flushByTag('tag1');
+               $this->assertSame(array(), $this->redis->getKeys('temp*'));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function flushByTagRemovesIdentifierToTagsSetOfEntryTaggedWithGivenTag() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'tag1';
+               $this->backend->set($identifier, 'data', array($tag));
+               $this->backend->flushByTag($tag);
+               $this->assertFalse($this->redis->exists('identTags:' . $identifier));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function flushByTagDoesNotRemoveIdentifierToTagsSetOfUnrelatedEntry() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifierToBeRemoved = 'identifier' . uniqid();
+               $tagToRemove = 'tag1';
+               $this->backend->set($identifierToBeRemoved, 'data', array($tagToRemove));
+               $identifierNotToBeRemoved = 'identifier' . uniqid();
+               $tagNotToRemove = 'tag2';
+               $this->backend->set($identifierNotToBeRemoved, 'data', array($tagNotToRemove));
+               $this->backend->flushByTag($tagToRemove);
+               $this->assertSame(array($tagNotToRemove), $this->redis->sMembers('identTags:' . $identifierNotToBeRemoved));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function flushByTagRemovesTagToIdentifiersSetOfGivenTag() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $tag = 'tag1';
+               $this->backend->set($identifier, 'data', array($tag));
+               $this->backend->flushByTag($tag);
+               $this->assertFalse($this->redis->exists('tagIdents:' . $tag));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function flushByTagRemovesIdentifiersTaggedWithGivenTagFromTagToIdentifiersSets() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2'));
+               $this->backend->set($identifier . 'B', 'data', array('tag1', 'tag2'));
+               $this->backend->set($identifier . 'C', 'data', array('tag2'));
+               $this->backend->flushByTag('tag1');
+               $this->assertSame(array($identifier . 'C'), $this->redis->sMembers('tagIdents:tag2'));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function collectGarbageDoesNotRemoveNotExpiredIdentifierToDataEntry() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag'));
+               $this->backend->set($identifier . 'B', 'data', array('tag'));
+               $this->redis->delete(('identData:' . $identifier) . 'A');
+               $this->backend->collectGarbage();
+               $this->assertTrue($this->redis->exists(('identData:' . $identifier) . 'B'));
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function collectGarbageRemovesLeftOverIdentifierToTagsSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag'));
+               $this->backend->set($identifier . 'B', 'data', array('tag'));
+               $this->redis->delete(('identData:' . $identifier) . 'A');
+               $this->backend->collectGarbage();
+               $expectedResult = array(FALSE, TRUE);
+               $actualResult = array(
+                       $this->redis->exists(('identTags:' . $identifier) . 'A'),
+                       $this->redis->exists(('identTags:' . $identifier) . 'B')
+               );
+               $this->assertSame($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        */
+       public function collectGarbageRemovesExpiredIdentifierFromTagsToIdentifierSet() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2'));
+               $this->backend->set($identifier . 'B', 'data', array('tag2'));
+               $this->redis->delete(('identData:' . $identifier) . 'A');
+               $this->backend->collectGarbage();
+               $expectedResult = array(
+                       array(),
+                       array($identifier . 'B')
+               );
+               $actualResult = array(
+                       $this->redis->sMembers('tagIdents:tag1'),
+                       $this->redis->sMembers('tagIdents:tag2')
+               );
+               $this->assertSame($expectedResult, $actualResult);
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/TransientMemoryBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/TransientMemoryBackendTest.php
new file mode 100644 (file)
index 0000000..88ffc4f
--- /dev/null
@@ -0,0 +1,184 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the TransientMemory cache backend
+ *
+ * This file is a backport from FLOW3
+ *
+ * @author Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class TransientMemoryBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        * @test
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $otherData = 'some other data';
+               $backend->set($identifier, $otherData);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($otherData, $fetchedData);
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'Some data';
+               $entryIdentifier = 'MyIdentifier';
+               $backend->set($entryIdentifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
+               $this->assertEquals($entryIdentifier, $retrieved[0]);
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
+               $this->assertEquals($entryIdentifier, $retrieved[0]);
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $identifier = 'NonExistingIdentifier';
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache);
+       }
+
+       /**
+        * @test
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $identifier = 'NonExistingIdentifier';
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache);
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'some data' . microtime();
+               $backend->set('TransientMemoryBackendTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('TransientMemoryBackendTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('TransientMemoryBackendTest3', $data, array('UnitTestTag%test'));
+               $backend->flushByTag('UnitTestTag%special');
+               $this->assertTrue($backend->has('TransientMemoryBackendTest1'), 'TransientMemoryBackendTest1');
+               $this->assertFalse($backend->has('TransientMemoryBackendTest2'), 'TransientMemoryBackendTest2');
+               $this->assertTrue($backend->has('TransientMemoryBackendTest3'), 'TransientMemoryBackendTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend('Testing');
+               $backend->setCache($cache);
+               $data = 'some data' . microtime();
+               $backend->set('TransientMemoryBackendTest1', $data);
+               $backend->set('TransientMemoryBackendTest2', $data);
+               $backend->set('TransientMemoryBackendTest3', $data);
+               $backend->flush();
+               $this->assertFalse($backend->has('TransientMemoryBackendTest1'), 'TransientMemoryBackendTest1');
+               $this->assertFalse($backend->has('TransientMemoryBackendTest2'), 'TransientMemoryBackendTest2');
+               $this->assertFalse($backend->has('TransientMemoryBackendTest3'), 'TransientMemoryBackendTest3');
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/WincacheBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/WincacheBackendTest.php
new file mode 100644 (file)
index 0000000..0abeded
--- /dev/null
@@ -0,0 +1,233 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2012 Tobias Burger <tobias_burger@hotmail.com>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the WinCache cache backend
+ *
+ * @author Tobias Burger <tobias_burger@hotmail.com>
+ * @package TYPO3
+ * @subpackage tests
+ */
+class WincacheBackendTest extends \tx_phpunit_testcase {
+
+       /**
+        * Sets up this testcase
+        *
+        * @return void
+        */
+       public function setUp() {
+               if (!extension_loaded('wincache')) {
+                       $this->markTestSkipped('WinCache extension was not available');
+               }
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Cache\Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache, 'WinCache backend failed to set and check entry');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData, 'Winache backend failed to set and retrieve data');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, 'Failed to set and remove data from WinCache backend');
+       }
+
+       /**
+        * @test
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $otherData = 'some other data';
+               $backend->set($identifier, $otherData);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($otherData, $fetchedData, 'WinCache backend failed to overwrite and retrieve data');
+       }
+
+       /**
+        * @test
+        */
+       public function findIdentifiersByTagFindsSetEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag1');
+               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tag2');
+               $this->assertEquals($identifier, $retrieved[0], 'Could not retrieve expected entry by tag.');
+       }
+
+       /**
+        * @test
+        */
+       public function setRemovesTagsFromPreviousSet() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data, array('UnitTestTag%tag1', 'UnitTestTag%tagX'));
+               $backend->set($identifier, $data, array('UnitTestTag%tag3'));
+               $retrieved = $backend->findIdentifiersByTag('UnitTestTag%tagX');
+               $this->assertEquals(array(), $retrieved, 'Found entry which should no longer exist.');
+       }
+
+       /**
+        * @test
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, '"has" did not return FALSE when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier' . md5(uniqid(mt_rand(), TRUE));
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache, '"remove" did not return FALSE when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('BackendWincacheTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('BackendWincacheTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $backend->set('BackendWincacheTest3', $data, array('UnitTestTag%test'));
+               $backend->flushByTag('UnitTestTag%special');
+               $this->assertTrue($backend->has('BackendWincacheTest1'), 'BackendWincacheTest1');
+               $this->assertFalse($backend->has('BackendWincacheTest2'), 'BackendWincacheTest2');
+               $this->assertTrue($backend->has('BackendWincacheTest3'), 'BackendWincacheTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesAllCacheEntries() {
+               $backend = $this->setUpBackend();
+               $data = 'some data' . microtime();
+               $backend->set('BackendWincacheTest1', $data);
+               $backend->set('BackendWincacheTest2', $data);
+               $backend->set('BackendWincacheTest3', $data);
+               $backend->flush();
+               $this->assertFalse($backend->has('BackendWincacheTest1'), 'BackendWincacheTest1');
+               $this->assertFalse($backend->has('BackendWincacheTest2'), 'BackendWincacheTest2');
+               $this->assertFalse($backend->has('BackendWincacheTest3'), 'BackendWincacheTest3');
+       }
+
+       /**
+        * @test
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $thisCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
+               $thisBackend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
+               $thisBackend->setCache($thisCache);
+               $thatCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
+               $thatBackend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
+               $thatBackend->setCache($thatCache);
+               $thisBackend->set('thisEntry', 'Hello');
+               $thatBackend->set('thatEntry', 'World!');
+               $thatBackend->flush();
+               $this->assertEquals('Hello', $thisBackend->get('thisEntry'));
+               $this->assertFalse($thatBackend->has('thatEntry'));
+       }
+
+       /**
+        * Check if we can store ~5 MB of data
+        *
+        * @test
+        */
+       public function largeDataIsStored() {
+               $backend = $this->setUpBackend();
+               $data = str_repeat('abcde', 1024 * 1024);
+               $identifier = 'tooLargeData' . md5(uniqid(mt_rand(), TRUE));
+               $backend->set($identifier, $data);
+               $this->assertTrue($backend->has($identifier));
+               $this->assertEquals($backend->get($identifier), $data);
+       }
+
+       /**
+        * Sets up the WinCache backend used for testing
+        *
+        * @return \TYPO3\CMS\Core\Cache\Backend\WincacheBackend
+        */
+       protected function setUpBackend() {
+               $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(), '', FALSE);
+               $backend = new \TYPO3\CMS\Core\Cache\Backend\WincacheBackend();
+               $backend->setCache($cache);
+               return $backend;
+       }
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Cache/CacheManagerTest.php b/typo3/sysext/core/Tests/Unit/Cache/CacheManagerTest.php
new file mode 100644 (file)
index 0000000..8227ea1
--- /dev/null
@@ -0,0 +1,209 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Cache;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public