[TASK] Add prefix "class." to all unit test files which contain classes.
authorStefano Kowalke <blueduck@gmx.net>
Sun, 17 Apr 2011 13:05:39 +0000 (15:05 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 17 Apr 2011 18:37:49 +0000 (20:37 +0200)
According to the CGL the files which contains a class must have a prefix "class." in filename.

Change-Id: I5ac0214236dc248a7d2b37d5981278fd65bc6c91
Resolves: #25868
Releases: 4.6
Reviewed-on: http://review.typo3.org/1646
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
92 files changed:
tests/contrib/class.removexssTest.php [new file with mode: 0644]
tests/contrib/removexssTest.php [deleted file]
tests/t3lib/cache/backend/class.t3lib_cache_backend_abstractbackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_apcbackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_filebackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_pdobackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_redisbackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackendTest.php [new file with mode: 0644]
tests/t3lib/cache/backend/t3lib_cache_backend_abstractbackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_apcbackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_dbbackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_filebackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_memcachedbackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_pdobackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_redisbackendTest.php [deleted file]
tests/t3lib/cache/backend/t3lib_cache_backend_transientmemorybackendTest.php [deleted file]
tests/t3lib/cache/class.t3lib_cache_factoryTest.php [new file with mode: 0644]
tests/t3lib/cache/class.t3lib_cache_managerTest.php [new file with mode: 0644]
tests/t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontendTest.php [new file with mode: 0644]
tests/t3lib/cache/frontend/class.t3lib_cache_frontend_phpfrontendTest.php [new file with mode: 0644]
tests/t3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontendTest.php [new file with mode: 0644]
tests/t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontendTest.php [new file with mode: 0644]
tests/t3lib/cache/frontend/t3lib_cache_frontend_abstractfrontendTest.php [deleted file]
tests/t3lib/cache/frontend/t3lib_cache_frontend_phpfrontendTest.php [deleted file]
tests/t3lib/cache/frontend/t3lib_cache_frontend_stringfrontendTest.php [deleted file]
tests/t3lib/cache/frontend/t3lib_cache_frontend_variablefrontendTest.php [deleted file]
tests/t3lib/cache/t3lib_cache_factoryTest.php [deleted file]
tests/t3lib/cache/t3lib_cache_managerTest.php [deleted file]
tests/t3lib/class.config_defaultTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_arraybrowserTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_befuncTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_beuserauthTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_csTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_dbTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_divTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_extmgmTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_htmlmailTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_iconWorksTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_lockTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_pagerendererTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_pageselectTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_registryTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_spritemanagerTest.php [new file with mode: 0644]
tests/t3lib/class.t3lib_tcemainTest.php [new file with mode: 0644]
tests/t3lib/config_defaultTest.php [deleted file]
tests/t3lib/db/class.t3lib_db_preparedstatementTest.php [new file with mode: 0644]
tests/t3lib/db/t3lib_db_preparedstatementTest.php [deleted file]
tests/t3lib/formprotection/class.t3lib_formprotection_AbstractTest.php [new file with mode: 0644]
tests/t3lib/formprotection/class.t3lib_formprotection_BackendFormProtectionTest.php [new file with mode: 0644]
tests/t3lib/formprotection/class.t3lib_formprotection_FactoryTest.php [new file with mode: 0644]
tests/t3lib/formprotection/class.t3lib_formprotection_InstallToolFormProtectionTest.php [new file with mode: 0644]
tests/t3lib/formprotection/t3lib_formprotection_AbstractTest.php [deleted file]
tests/t3lib/formprotection/t3lib_formprotection_BackendFormProtectionTest.php [deleted file]
tests/t3lib/formprotection/t3lib_formprotection_FactoryTest.php [deleted file]
tests/t3lib/formprotection/t3lib_formprotection_InstallToolFormProtectionTest.php [deleted file]
tests/t3lib/mail/class.t3lib_mail_swiftmaileradapterTest.php [new file with mode: 0644]
tests/t3lib/mail/t3lib_mail_swiftmaileradapterTest.php [deleted file]
tests/t3lib/matchcondition/class.t3lib_matchcondition_backendTest.php [new file with mode: 0644]
tests/t3lib/matchcondition/class.t3lib_matchcondition_frontendTest.php [new file with mode: 0644]
tests/t3lib/matchcondition/t3lib_matchcondition_backendTest.php [deleted file]
tests/t3lib/matchcondition/t3lib_matchcondition_frontendTest.php [deleted file]
tests/t3lib/t3lib_arraybrowserTest.php [deleted file]
tests/t3lib/t3lib_befuncTest.php [deleted file]
tests/t3lib/t3lib_beuserauthTest.php [deleted file]
tests/t3lib/t3lib_csTest.php [deleted file]
tests/t3lib/t3lib_dbTest.php [deleted file]
tests/t3lib/t3lib_divTest.php [deleted file]
tests/t3lib/t3lib_extmgmTest.php [deleted file]
tests/t3lib/t3lib_htmlmailTest.php [deleted file]
tests/t3lib/t3lib_iconWorksTest.php [deleted file]
tests/t3lib/t3lib_lockTest.php [deleted file]
tests/t3lib/t3lib_pagerendererTest.php [deleted file]
tests/t3lib/t3lib_pageselectTest.php [deleted file]
tests/t3lib/t3lib_registryTest.php [deleted file]
tests/t3lib/t3lib_spritemanagerTest.php [deleted file]
tests/t3lib/t3lib_tcemainTest.php [deleted file]
tests/t3lib/tree/class.t3lib_tree_nodeTest.php [new file with mode: 0644]
tests/t3lib/tree/class.t3lib_tree_nodecollectionTest.php [new file with mode: 0644]
tests/t3lib/tree/class.t3lib_tree_sortednodecollectionTest.php [new file with mode: 0644]
tests/t3lib/tree/t3lib_tree_nodeTest.php [deleted file]
tests/t3lib/tree/t3lib_tree_nodecollectionTest.php [deleted file]
tests/t3lib/tree/t3lib_tree_sortednodecollectionTest.php [deleted file]
tests/t3lib/utility/class.t3lib_utility_clientTest.php [new file with mode: 0644]
tests/t3lib/utility/class.t3lib_utility_mailTest.php [new file with mode: 0644]
tests/t3lib/utility/t3lib_utility_clientTest.php [deleted file]
tests/t3lib/utility/t3lib_utility_mailTest.php [deleted file]
tests/typo3/sysext/cms/tslib/class.tslib_contentTest.php [new file with mode: 0644]
tests/typo3/sysext/cms/tslib/class.tslib_feTest.php [new file with mode: 0644]
tests/typo3/sysext/cms/tslib/tslib_contentTest.php [deleted file]
tests/typo3/sysext/cms/tslib/tslib_feTest.php [deleted file]

diff --git a/tests/contrib/class.removexssTest.php b/tests/contrib/class.removexssTest.php
new file mode 100644 (file)
index 0000000..7932607
--- /dev/null
@@ -0,0 +1,410 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009-2011 Steffen Kamper <info@sk-typo3.de>
+*  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(PATH_typo3 . 'contrib/RemoveXSS/RemoveXSS.php');
+
+/**
+ * Testcase for class RemoveXSS
+ *
+ * @author     Steffen Kamper <info@sk-typo3.de>
+ * @package TYPO3
+ * @subpackage contrib
+ * @ see http://ha.ckers.org/xss.html
+ * @ examples from http://ha.ckers.org/xssAttacks.xml
+ */
+class RemoveXSSTest extends tx_phpunit_testcase {
+
+       /**
+        * @test
+        */
+       public function checkAttackScriptAlert() {
+               $testString = "<SCRIPT>alert('XSS')</SCRIPT>";
+               $expectedString = "<sc<x>ript>alert('XSS')</SCRIPT>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackScriptSrcJs() {
+               $testString = '<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>';
+               $expectedString = "<sc<x>ript SRC=http://ha.ckers.org/xss.js></SCRIPT>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackScriptAlertFromCharCode() {
+               $testString = '<SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>';
+               $expectedString = '<sc<x>ript>alert(String.fromCharCode(88,83,83))</SCRIPT>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBaseHref() {
+               $testString = "<BASE HREF=\"javascript:alert('XSS');//\">";
+               $expectedString = "<ba<x>se HREF=\"ja<x>vascript:alert('XSS');//\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBgsound() {
+               $testString = "<BGSOUND SRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<bg<x>sound SRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBodyBackground() {
+               $testString = "<BODY BACKGROUND=\"javascript:alert('XSS');\">";
+               $expectedString = "<BODY BACKGROUND=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackBodyOnLoad() {
+               $testString = "<BODY ONLOAD=alert('XSS')>";
+               $expectedString = "<BODY on<x>load=alert('XSS')>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleUrl() {
+               $testString = "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">";
+               $expectedString = "<DIV st<x>yle=\"background-image: url(ja<x>vascript:alert('XSS'))\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleWidth() {
+               $testString = "<DIV STYLE=\"width: expression(alert('XSS'));\">";
+               $expectedString = "<DIV st<x>yle=\"width: expression(alert('XSS'));\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackFrameset() {
+               $testString = "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>";
+               $expectedString = "<fr<x>ameset><fr<x>ame SRC=\"ja<x>vascript:alert('XSS');\"></FRAMESET>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackIframe() {
+               $testString = "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>";
+               $expectedString = "<if<x>rame SRC=\"ja<x>vascript:alert('XSS');\"></IFRAME>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackInputImage() {
+               $testString = "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<INPUT TYPE=\"IMAGE\" SRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageSrc() {
+               $testString = "<IMG SRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<IMG SRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageSrcNoQuotesNoSemicolon() {
+               $testString = "<IMG SRC=javascript:alert('XSS')>";
+               $expectedString = "<IMG SRC=ja<x>vascript:alert('XSS')>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageDynsrc() {
+               $testString = "<IMG DYNSRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<IMG DYNSRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageLowsrc() {
+               $testString = "<IMG LOWSRC=\"javascript:alert('XSS');\">";
+               $expectedString = "<IMG LOWSRC=\"ja<x>vascript:alert('XSS');\">";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyle() {
+               $testString = "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE>";
+               $expectedString = "<st<x>yle>li {list-style-image: url(\"ja<x>vascript:alert('XSS')\");}</STYLE>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageVbscript() {
+               $testString = "<IMG SRC='vbscript:msgbox(\"XSS\")'>";
+               $expectedString = "<IMG SRC='vb<x>script:msgbox(\"XSS\")'>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackLayer() {
+               $testString = "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
+               $expectedString = "<la<x>yer SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackMeta() {
+               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">';
+               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=ja<x>vascript:alert(\'XSS\');">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackMetaWithUrl() {
+               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
+               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackMetaWithUrlExtended() {
+               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">';
+               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=ja<x>vascript:alert(\'XSS\');">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackObject() {
+               $testString = '<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
+               $expectedString = '<ob<x>ject TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackObjectEmbeddedXss() {
+               $testString = '<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert(\'XSS\')></OBJECT>';
+               $expectedString = '<ob<x>ject classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=ja<x>vascript:alert(\'XSS\')></OBJECT>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackEmbedFlash() {
+               $testString = '<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
+               $expectedString = '<em<x>bed SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackActionScriptEval() {
+               $testString = 'a="get";b="URL("";c="javascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
+               $expectedString = 'a="get";b="URL("";c="ja<x>vascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImageStyleWithComment() {
+               $testString = '<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
+               $expectedString = '<IMG st<x>yle="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleInAnonymousHtml() {
+               $testString = '<XSS STYLE="xss:expression(alert(\'XSS\'))">';
+               $expectedString = '<XSS st<x>yle="xss:expression(alert(\'XSS\'))">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleWithBackgroundImage() {
+               $testString = '<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
+               $expectedString = '<st<x>yle>.XSS{background-image:url("ja<x>vascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStyleWithBackground() {
+               $testString = '<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>';
+               $expectedString = '<st<x>yle type="text/css">BODY{background:url("ja<x>vascript:alert(\'XSS\')")}</STYLE>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackStylesheet() {
+               $testString = '<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">';
+               $expectedString = '<li<x>nk REL="stylesheet" HREF="ja<x>vascript:alert(\'XSS\');">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackRemoteStylesheet() {
+               $testString = '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
+               $expectedString = '<li<x>nk REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+       /**
+        * @test
+        */
+       public function checkAttackImportRemoteStylesheet() {
+               $testString = '<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
+               $expectedString = '<st<x>yle>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
+               $actualString = RemoveXSS::process($testString);
+
+               $this->assertEquals($expectedString, $actualString);
+       }
+
+       /**
+        * @return array<array> input strings and expected output strings to test
+        *
+        * @see processWithDataProvider
+        */
+       public function processDataProvider() {
+               return array(
+                       'attackWithHexEncodedCharacter' => array(
+                               '<a href="j&#x61;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attackWithNestedHexEncodedCharacter' => array(
+                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attackWithUnicodeNumericalEncodedCharacter' => array(
+                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+                       'attackWithNestedUnicodeNumericalEncodedCharacter' => array(
+                               '<a href="j&#6&#53;;vascript:alert(123);">click</a>',
+                               '<a href="ja<x>vascript:alert(123);">click</a>',
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        *
+        * @param string $input input value to test
+        * @param string $expected expected output value
+        *
+        * @dataProvider processDataProvider
+        */
+       public function processWithDataProvider($input, $expected) {
+               $this->assertEquals(
+                       $expected,
+                       RemoveXSS::process($input)
+               );
+       }
+}
+?>
\ No newline at end of file
diff --git a/tests/contrib/removexssTest.php b/tests/contrib/removexssTest.php
deleted file mode 100644 (file)
index 7932607..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009-2011 Steffen Kamper <info@sk-typo3.de>
-*  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(PATH_typo3 . 'contrib/RemoveXSS/RemoveXSS.php');
-
-/**
- * Testcase for class RemoveXSS
- *
- * @author     Steffen Kamper <info@sk-typo3.de>
- * @package TYPO3
- * @subpackage contrib
- * @ see http://ha.ckers.org/xss.html
- * @ examples from http://ha.ckers.org/xssAttacks.xml
- */
-class RemoveXSSTest extends tx_phpunit_testcase {
-
-       /**
-        * @test
-        */
-       public function checkAttackScriptAlert() {
-               $testString = "<SCRIPT>alert('XSS')</SCRIPT>";
-               $expectedString = "<sc<x>ript>alert('XSS')</SCRIPT>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackScriptSrcJs() {
-               $testString = '<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>';
-               $expectedString = "<sc<x>ript SRC=http://ha.ckers.org/xss.js></SCRIPT>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackScriptAlertFromCharCode() {
-               $testString = '<SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>';
-               $expectedString = '<sc<x>ript>alert(String.fromCharCode(88,83,83))</SCRIPT>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBaseHref() {
-               $testString = "<BASE HREF=\"javascript:alert('XSS');//\">";
-               $expectedString = "<ba<x>se HREF=\"ja<x>vascript:alert('XSS');//\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBgsound() {
-               $testString = "<BGSOUND SRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<bg<x>sound SRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBodyBackground() {
-               $testString = "<BODY BACKGROUND=\"javascript:alert('XSS');\">";
-               $expectedString = "<BODY BACKGROUND=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackBodyOnLoad() {
-               $testString = "<BODY ONLOAD=alert('XSS')>";
-               $expectedString = "<BODY on<x>load=alert('XSS')>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleUrl() {
-               $testString = "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">";
-               $expectedString = "<DIV st<x>yle=\"background-image: url(ja<x>vascript:alert('XSS'))\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleWidth() {
-               $testString = "<DIV STYLE=\"width: expression(alert('XSS'));\">";
-               $expectedString = "<DIV st<x>yle=\"width: expression(alert('XSS'));\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackFrameset() {
-               $testString = "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>";
-               $expectedString = "<fr<x>ameset><fr<x>ame SRC=\"ja<x>vascript:alert('XSS');\"></FRAMESET>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackIframe() {
-               $testString = "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>";
-               $expectedString = "<if<x>rame SRC=\"ja<x>vascript:alert('XSS');\"></IFRAME>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackInputImage() {
-               $testString = "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<INPUT TYPE=\"IMAGE\" SRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageSrc() {
-               $testString = "<IMG SRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<IMG SRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageSrcNoQuotesNoSemicolon() {
-               $testString = "<IMG SRC=javascript:alert('XSS')>";
-               $expectedString = "<IMG SRC=ja<x>vascript:alert('XSS')>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageDynsrc() {
-               $testString = "<IMG DYNSRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<IMG DYNSRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageLowsrc() {
-               $testString = "<IMG LOWSRC=\"javascript:alert('XSS');\">";
-               $expectedString = "<IMG LOWSRC=\"ja<x>vascript:alert('XSS');\">";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyle() {
-               $testString = "<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE>";
-               $expectedString = "<st<x>yle>li {list-style-image: url(\"ja<x>vascript:alert('XSS')\");}</STYLE>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageVbscript() {
-               $testString = "<IMG SRC='vbscript:msgbox(\"XSS\")'>";
-               $expectedString = "<IMG SRC='vb<x>script:msgbox(\"XSS\")'>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackLayer() {
-               $testString = "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
-               $expectedString = "<la<x>yer SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>";
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackMeta() {
-               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">';
-               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=ja<x>vascript:alert(\'XSS\');">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackMetaWithUrl() {
-               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
-               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackMetaWithUrlExtended() {
-               $testString = '<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">';
-               $expectedString = '<me<x>ta HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=ja<x>vascript:alert(\'XSS\');">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackObject() {
-               $testString = '<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
-               $expectedString = '<ob<x>ject TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackObjectEmbeddedXss() {
-               $testString = '<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert(\'XSS\')></OBJECT>';
-               $expectedString = '<ob<x>ject classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=ja<x>vascript:alert(\'XSS\')></OBJECT>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackEmbedFlash() {
-               $testString = '<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
-               $expectedString = '<em<x>bed SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackActionScriptEval() {
-               $testString = 'a="get";b="URL("";c="javascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
-               $expectedString = 'a="get";b="URL("";c="ja<x>vascript:";d="alert(\'XSS\');")";eval(a+b+c+d);";';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImageStyleWithComment() {
-               $testString = '<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
-               $expectedString = '<IMG st<x>yle="xss:expr/*XSS*/ession(alert(\'XSS\'))">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleInAnonymousHtml() {
-               $testString = '<XSS STYLE="xss:expression(alert(\'XSS\'))">';
-               $expectedString = '<XSS st<x>yle="xss:expression(alert(\'XSS\'))">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleWithBackgroundImage() {
-               $testString = '<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
-               $expectedString = '<st<x>yle>.XSS{background-image:url("ja<x>vascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStyleWithBackground() {
-               $testString = '<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>';
-               $expectedString = '<st<x>yle type="text/css">BODY{background:url("ja<x>vascript:alert(\'XSS\')")}</STYLE>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackStylesheet() {
-               $testString = '<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">';
-               $expectedString = '<li<x>nk REL="stylesheet" HREF="ja<x>vascript:alert(\'XSS\');">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackRemoteStylesheet() {
-               $testString = '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
-               $expectedString = '<li<x>nk REL="stylesheet" HREF="http://ha.ckers.org/xss.css">';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-       /**
-        * @test
-        */
-       public function checkAttackImportRemoteStylesheet() {
-               $testString = '<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
-               $expectedString = '<st<x>yle>@import\'http://ha.ckers.org/xss.css\';</STYLE>';
-               $actualString = RemoveXSS::process($testString);
-
-               $this->assertEquals($expectedString, $actualString);
-       }
-
-       /**
-        * @return array<array> input strings and expected output strings to test
-        *
-        * @see processWithDataProvider
-        */
-       public function processDataProvider() {
-               return array(
-                       'attackWithHexEncodedCharacter' => array(
-                               '<a href="j&#x61;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attackWithNestedHexEncodedCharacter' => array(
-                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attackWithUnicodeNumericalEncodedCharacter' => array(
-                               '<a href="j&#x6&#x31;;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-                       'attackWithNestedUnicodeNumericalEncodedCharacter' => array(
-                               '<a href="j&#6&#53;;vascript:alert(123);">click</a>',
-                               '<a href="ja<x>vascript:alert(123);">click</a>',
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        *
-        * @param string $input input value to test
-        * @param string $expected expected output value
-        *
-        * @dataProvider processDataProvider
-        */
-       public function processWithDataProvider($input, $expected) {
-               $this->assertEquals(
-                       $expected,
-                       RemoveXSS::process($input)
-               );
-       }
-}
-?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_abstractbackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_abstractbackendTest.php
new file mode 100644 (file)
index 0000000..a3286ab
--- /dev/null
@@ -0,0 +1,83 @@
+<?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 t3lib_cache_backend_AbstractBackend
+        */
+       protected $backend;
+
+       /**
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setUp() {
+               $className = uniqid('ConcreteBackend_');
+               eval('
+                       class ' . $className. ' extends t3lib_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 flushByTags(array $tags) {}
+                               public function findIdentifiersByTag($tag) {}
+                               public function findIdentifiersByTags(array $tags) {}
+                               public function collectGarbage() {}
+                               public function setSomeOption($value) {
+                                       $this->someOption = $value;
+                               }
+                               public function getSomeOption() {
+                                       return $this->someOption;
+                               }
+                       }
+               ');
+               $this->backend = new $className();
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function theConstructorCallsSetterMethodsForAllSpecifiedOptions() {
+               $className = get_class($this->backend);
+               $backend = new $className(array('someOption' => 'someValue'));
+               $this->assertSame('someValue', $backend->getSomeOption());
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_apcbackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_apcbackendTest.php
new file mode 100644 (file)
index 0000000..fde7de6
--- /dev/null
@@ -0,0 +1,274 @@
+<?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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @expectedException t3lib_cache_Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = new t3lib_cache_backend_ApcBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache, 'APC backend failed to set and check entry');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData, 'APC backend failed to set and retrieve data');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, 'Failed to set and remove data from APC backend');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function findIdentifiersByTagFindsSetEntries() {
+               $backend = $this->setUpBackend();
+
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function setRemovesTagsFromPreviousSet() {
+               $backend = $this->setUpBackend();
+
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = uniqid('NonExistingIdentifier');
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache,'"has" did not return false when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = uniqid('NonExistingIdentifier');
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache,'"remove" did not return false when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $thisCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
+               $thisBackend = new t3lib_cache_backend_ApcBackend();
+               $thisBackend->setCache($thisCache);
+
+               $thatCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
+               $thatBackend = new t3lib_cache_backend_ApcBackend();
+               $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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function largeDataIsStored() {
+               $backend = $this->setUpBackend();
+
+               $data = str_repeat('abcde', 1024 * 1024);
+               $identifier = uniqid('tooLargeData');
+               $backend->set($identifier, $data);
+
+               $this->assertTrue($backend->has($identifier));
+               $this->assertEquals($backend->get($identifier), $data);
+       }
+
+       /**
+        * Sets up the APC backend used for testing
+        *
+        * @param array $backendOptions Options for the APC backend
+        * @return t3lib_cache_backend_ApcBackend
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       protected function setUpBackend() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_ApcBackend();
+               $backend->setCache($cache);
+
+               return $backend;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_dbbackendTest.php
new file mode 100644 (file)
index 0000000..3551082
--- /dev/null
@@ -0,0 +1,695 @@
+<?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 {
+
+       /**
+        * If set, the tearDown() method will clean up the cache table used by this unit test.
+        *
+        * @var t3lib_cache_backend_DbBackend
+        */
+       protected $backend;
+
+       protected $testingCacheTable;
+       protected $testingTagsTable;
+
+       /**
+        * Sets up the backend used for testing
+        *
+        * @return void
+        * @author Ingo Renner <ingo@typo3.org>
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function setUpBackend(array $backendOptions = array()) {
+               $defaultTestingCacheTable = 'test_cache_dbbackend';
+               $defaultTestingTagsTable = 'test_cache_dbbackend_tags';
+
+               $backendOptions = array_merge(
+                       array(
+                               'cacheTable' => $defaultTestingCacheTable,
+                               'tagsTable' => $defaultTestingTagsTable,
+                       ),
+                       $backendOptions
+               );
+
+               $this->testingCacheTable = $backendOptions['cacheTable'];
+               $this->testingTagsTable = $backendOptions['tagsTable'];
+
+               $GLOBALS['TYPO3_DB']->sql_query('CREATE TABLE ' . $this->testingCacheTable . ' (
+                       id int(11) unsigned NOT NULL auto_increment,
+                       identifier varchar(128) DEFAULT \'\' NOT NULL,
+                       crdate int(11) unsigned DEFAULT \'0\' NOT NULL,
+                       content mediumblob,
+                       lifetime int(11) unsigned DEFAULT \'0\' NOT NULL,
+                       PRIMARY KEY (id),
+                       KEY cache_id (identifier)
+               ) ENGINE=InnoDB;
+               ');
+
+               $GLOBALS['TYPO3_DB']->sql_query('CREATE TABLE ' . $this->testingTagsTable . ' (
+                       id int(11) unsigned NOT NULL auto_increment,
+                       identifier varchar(128) DEFAULT \'\' NOT NULL,
+                       tag varchar(128) DEFAULT \'\' NOT NULL,
+                       PRIMARY KEY (id),
+                       KEY cache_id (identifier),
+                       KEY cache_tag (tag)
+               ) ENGINE=InnoDB;
+               ');
+
+               $this->backend = t3lib_div::makeInstance(
+                       't3lib_cache_backend_DbBackend',
+                       $backendOptions
+               );
+       }
+
+       /**
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function tearDown() {
+               $GLOBALS['TYPO3_DB']->sql_query(
+                       'DROP TABLE ' . $this->testingCacheTable . ';'
+               );
+
+               $GLOBALS['TYPO3_DB']->sql_query(
+                       'DROP TABLE ' . $this->testingTagsTable . ';'
+               );
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function getCacheTableReturnsThePreviouslySetTable() {
+               $this->setUpBackend();
+               $this->backend->setCacheTable($this->testingCacheTable);
+               $this->assertEquals($this->testingCacheTable, $this->backend->getCacheTable(), 'getCacheTable() did not return the expected value.');
+       }
+
+       /**
+        * @test
+        * @expectedException t3lib_cache_exception_InvalidData
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setThrowsExceptionIfDataIsNotAString() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = array('Some data');
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+
+               $this->backend->set($entryIdentifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setReallySavesToTheSpecifiedTable() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data            = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data);
+
+               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       '*',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertEquals(
+                       $data,
+                       $entryFound['content'],
+                       'The original and the retrieved data don\'t match.'
+               );
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setRemovesAnAlreadyExistingCacheEntryForTheSameIdentifier() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data1 = 'some data' . microtime();
+               $data2 = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemoveBeforeSetTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data1, array(), 500);
+                       // setting a second entry with the same identifier, but different
+                       // data, this should _replace_ the existing one we set before
+               $this->backend->set($entryIdentifier, $data2, array(), 200);
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertEquals(1, count($entriesFound), 'There was not exactly one cache entry.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setReallySavesSpecifiedTags() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+               $this->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, 'The tags do not exist.');
+               $this->assertTrue(in_array('UnitTestTag%tag1', $tags), 'Tag UnitTestTag%tag1 does not exist.');
+               $this->assertTrue(in_array('UnitTestTag%tag2', $tags), 'Tag UnitTestTag%tag2 does not exist.');
+       }
+
+       /**
+        * @test
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function setSavesCompressedDataWithEnabledCompression() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+               $this->setUpBackend(
+                       array(
+                               'compression' => TRUE,
+                       )
+               );
+               $this->backend->setCache($mockCache);
+
+               $data = 'some data ' . microtime();
+
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->set($entryIdentifier, $data);
+
+               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       'content',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertEquals($data, @gzuncompress($entry['content']), 'Original and compressed data don\'t match');
+       }
+
+       /**
+        * @test
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function setSavesPlaintextDataWithEnabledCompressionAndCompressionLevel0() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+               $this->setUpBackend(
+                       array(
+                               'compression' => TRUE,
+                               'compressionLevel' => 0,
+                       )
+               );
+               $this->backend->setCache($mockCache);
+
+               $data = 'some data ' . microtime();
+
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->set($entryIdentifier, $data);
+
+               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       'content',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertGreaterThan(0, substr_count($entry['content'], $data), 'Plaintext data not found');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function getReturnsContentOfTheCorrectCacheEntry() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data, array(), 500);
+
+               $data = 'some other data' . microtime();
+               $this->backend->set($entryIdentifier, $data, array(), 100);
+
+               $loadedData = $this->backend->get($entryIdentifier);
+
+               $this->assertEquals($data, $loadedData, 'The original and the retrieved data don\'t match.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function hasReturnsTheCorrectResult() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data);
+
+               $this->assertTrue($this->backend->has($entryIdentifier), 'has() did not return TRUE.');
+               $this->assertFalse($this->backend->has($entryIdentifier . 'Not'), 'has() did not return FALSE.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function removeReallyRemovesACacheEntry() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemovalTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data);
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertTrue(is_array($entriesFound) && count($entriesFound) > 0, 'The cache entry does not exist.');
+
+               $this->backend->remove($entryIdentifier);
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertTrue(count($entriesFound) == 0, 'The cache entry still exists.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemovalTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data, array(), 1);
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertTrue(is_array($entriesFound) && count($entriesFound) > 0, 'The cache entry does not exist.');
+
+               sleep(2);
+               $GLOBALS['EXEC_TIME'] += 2;
+               $this->backend->collectGarbage();
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       'identifier = \'' . $entryIdentifier . '\''
+               );
+
+               $this->assertTrue(count($entriesFound) == 0, 'The cache entry still exists.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbRemovalTest';
+
+               $this->backend->setCache($cache);
+
+               $this->backend->set($entryIdentifier . 'A', $data, array(), 1);
+               $this->backend->set($entryIdentifier . 'B', $data, array(), 1);
+               $this->backend->set($entryIdentifier . 'C', $data, array(), 1);
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       ''
+               );
+
+               $this->assertTrue(is_array($entriesFound) && count($entriesFound) > 0, 'The cache entries do not exist.');
+
+               sleep(2);
+               $GLOBALS['EXEC_TIME'] += 2;
+               $this->backend->collectGarbage();
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       ''
+               );
+
+               $this->assertTrue(count($entriesFound) == 0, 'The cache entries still exist.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $this->backend->setCache($cache);
+
+               $data = 'some data' . microtime();
+               $this->backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $this->backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $this->backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
+
+               $expectedEntry = 'BackendDbTest2';
+
+               $actualEntries = $this->backend->findIdentifiersByTag('UnitTestTag%special');
+               $this->assertTrue(is_array($actualEntries), 'actualEntries is not an array.');
+
+               $this->assertEquals($expectedEntry, array_pop($actualEntries));
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushRemovesAllCacheEntries() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $this->backend->setCache($cache);
+
+               $data = 'some data' . microtime();
+               $this->backend->set('BackendDbTest1', $data, array('UnitTestTag%test'));
+               $this->backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $this->backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
+
+               $this->backend->flush();
+
+               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $this->testingCacheTable,
+                       ''
+               );
+
+               $this->assertTrue(count($entriesFound) == 0, 'Still entries in the cache table');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $this->backend->setCache($cache);
+
+               $data = 'some data' . microtime();
+               $this->backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $this->backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $this->backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
+
+               $this->backend->flushByTag('UnitTestTag%special');
+
+               $this->assertTrue($this->backend->has('BackendDbTest1'), 'BackendDbTest1 does not exist anymore.');
+               $this->assertFalse($this->backend->has('BackendDbTest2'), 'BackendDbTest2 still exists.');
+               $this->assertTrue($this->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), 'UnitTestTag%special still exists in tags table');
+       }
+
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function hasReturnsTheCorrectResultForEntryWithExceededLifetime() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data);
+
+               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
+               $expiredData = 'some old data' . microtime();
+               $this->backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
+
+               sleep(2);
+               $GLOBALS['EXEC_TIME'] += 2;
+
+               $this->assertFalse($this->backend->has($expiredEntryIdentifier), 'has() did not return FALSE.');
+       }
+
+       /**
+        * @test
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function hasReturnsTrueForEntryWithUnlimitedLifetime() {
+               $this->setUpBackend();
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($mockCache);
+               $this->backend->set($entryIdentifier, 'data', array(), 0);
+
+               $GLOBALS['EXEC_TIME'] += 1;
+               $this->assertTrue($this->backend->has($entryIdentifier));
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function getReturnsFalseForEntryWithExceededLifetime() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendDbTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data);
+
+               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
+               $expiredData = 'some old data' . microtime();
+               $this->backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
+
+               sleep(2);
+               $GLOBALS['EXEC_TIME'] += 2;
+
+               $this->assertEquals($data, $this->backend->get($entryIdentifier), 'The original and the retrieved data don\'t match.');
+               $this->assertFalse($this->backend->get($expiredEntryIdentifier), 'The expired entry could be loaded.');
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function findIdentifiersByTagReturnsEmptyArrayForEntryWithExceededLifetime() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $this->backend->setCache($cache);
+               $this->backend->set('BackendDbTest', 'some data', array('UnitTestTag%special'), 1);
+
+               sleep(2);
+               $GLOBALS['EXEC_TIME'] += 2;
+                       // Not required, but used to update the pre-calculated queries:
+               $this->backend->setTagsTable($this->testingTagsTable);
+
+               $this->assertEquals(array(), $this->backend->findIdentifiersByTag('UnitTestTag%special'));
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setWithUnlimitedLifetimeWritesCorrectEntry() {
+               $this->setUpBackend();
+               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
+                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $data = 'some data' . microtime();
+               $entryIdentifier = 'BackendFileTest';
+
+               $this->backend->setCache($cache);
+               $this->backend->set($entryIdentifier, $data, array(), 0);
+
+               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       '*',
+                       $this->testingCacheTable,
+                       ''
+               );
+
+               $this->assertTrue(is_array($entryFound), 'entriesFound is not an array.');
+
+               $retrievedData = $entryFound['content'];
+               $this->assertEquals($data, $retrievedData, 'The original and the retrieved data don\'t match.');
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_filebackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_filebackendTest.php
new file mode 100644 (file)
index 0000000..a9047c3
--- /dev/null
@@ -0,0 +1,563 @@
+<?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 {
+       /**
+        * Backup of global variable EXEC_TIME
+        *
+        * @var array
+        */
+       protected $backupGlobalVariables;
+
+       /**
+        * If set, the tearDown() method will clean up the cache subdirectory used by this unit test.
+        *
+        * @var t3lib_cache_backend_FileBackend
+        */
+       protected $backend;
+
+       /**
+        * @var string Directory for testing data, relative to PATH_site
+        */
+       protected $testingCacheDirectory;
+
+       /**
+        * Sets up this testcase
+        *
+        * @return void
+        */
+       public function setUp() {
+               $this->backupGlobalVariables = array(
+                       'EXEC_TIME' => $GLOBALS['EXEC_TIME'],
+               );
+
+               $this->testingCacheDirectory = 'typo3temp/cache/testing/';
+
+               $this->backend = t3lib_div::makeInstance(
+                       't3lib_cache_backend_FileBackend',
+                       array('cacheDirectory' => $this->testingCacheDirectory)
+               );
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function defaultCacheDirectoryIsWritable() {
+               $cacheDirectory = $this->backend->getCacheDirectory();
+
+               $this->assertTrue(is_writable($cacheDirectory), 'The default cache directory "' . $cacheDirectory . '" is not writable.');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function setCacheDirectoryThrowsExceptionOnNonWritableDirectory() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('test not reliable in Windows environment');
+               }
+
+                       // Create test directory and remove write permissions
+               $directoryName = PATH_site . 'typo3temp/' . uniqid('test_');
+               t3lib_div::mkdir($directoryName);
+               chmod($directoryName, 1551);
+
+               try {
+                       $this->backend->setCacheDirectory($directoryName);
+                       $this->fail('setCacheDirectory did not throw an exception on a non writable directory');
+               } catch (t3lib_cache_Exception $e) {
+                               // Remove created test directory
+                       t3lib_div::rmdir($directoryName);
+               }
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function getCacheDirectoryReturnsTheCurrentCacheDirectory() {
+               $directory = $this->testingCacheDirectory;
+               $fullPathToDirectory = PATH_site . $directory;
+
+               $this->backend->setCacheDirectory($directory);
+               $this->assertEquals($fullPathToDirectory, $this->backend->getCacheDirectory(), 'getCacheDirectory() did not return the expected value.');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        * @expectedException t3lib_cache_exception_InvalidData
+        */
+       public function setThrowsExceptionIfDataIsNotAString() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $this->backend->setCache($mockCache);
+               $data = array('Some data');
+               $entryIdentifier = 'BackendFileTest';
+
+               $this->backend->set($entryIdentifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       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';
+               $this->backend->setCache($mockCache);
+               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
+
+               $this->backend->set($entryIdentifier, $data, array(), 10);
+
+               $this->assertFileExists($pathAndFilename);
+               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data));
+               $this->assertEquals($data, $retrievedData);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       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';
+
+               $this->backend->setCache($mockCache);
+               $this->backend->set($entryIdentifier, $data1, array(), 500);
+                       // Setting a second entry with the same identifier, but different
+                       // data, this should _replace_ the existing one we set before
+               $this->backend->set($entryIdentifier, $data2, array(), 200);
+
+               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
+
+               $this->assertFileExists($pathAndFilename);
+               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data2));
+               $this->assertEquals($data2, $retrievedData);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       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 = 'BackendFileTest';
+
+               $this->backend->setCache($mockCache);
+               $this->backend->set($entryIdentifier, $data, array('Tag1', 'Tag2'));
+
+               $pathAndFilename = $this->backend->getCacheDirectory() . $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
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function setWithUnlimitedLifetimeWritesCorrectEntry() {
+               $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';
+
+               $this->backend->setCache($mockCache);
+               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
+
+               $this->backend->set($entryIdentifier, $data, array(), 0);
+
+               $this->assertFileExists($pathAndFilename);
+
+               $dataSize = (integer)file_get_contents($pathAndFilename, NULL, NULL, filesize($pathAndFilename) - t3lib_cache_backend_FileBackend::DATASIZE_DIGITS, t3lib_cache_backend_FileBackend::DATASIZE_DIGITS);
+               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, $dataSize);
+
+               $this->assertEquals($data, $retrievedData, 'The original and the retrieved data don\'t match.');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       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);
+               $fullPathToCacheFile = PATH_site . 'typo3temp/cache/UnitTestCache/ExpiredEntry';
+               $backend->expects($this->once())->method('isCacheFileExpired')->with($fullPathToCacheFile)->will($this->returnValue(TRUE));
+               $backend->setCache($mockCache);
+
+               $this->assertFalse($backend->get('ExpiredEntry'));
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function hasReturnsTrueIfAnEntryExists() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $this->backend->setCache($mockCache);
+
+               $entryIdentifier = 'BackendFileTest';
+               $data = 'some data' . microtime();
+               $this->backend->set($entryIdentifier, $data);
+
+               $this->assertTrue($this->backend->has($entryIdentifier), 'has() did not return TRUE.');
+               $this->assertFalse($this->backend->has($entryIdentifier . 'Not'), 'has() did not return FALSE.');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       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
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       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';
+
+               $this->backend->setCache($mockCache);
+               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
+               $this->backend->set($entryIdentifier, $data);
+
+               $this->assertFileExists($pathAndFilename);
+               $this->backend->remove($entryIdentifier);
+               $this->assertFileNotExists($pathAndFilename);
+       }
+
+       /**
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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(), '', TRUE);
+               $backend->setCache($mockCache);
+
+               $backend->set($identifier, 'cache data', array());
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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->setCache($mockCache);
+
+               $backend->get($identifier);
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function hasThrowsExceptionForInvalidIdentifier($identifier) {
+               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
+
+               $backend->has($identifier);
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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->setCache($mockCache);
+
+               $backend->remove($identifier);
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidEntryIdentifiers
+        * @expectedException InvalidArgumentException
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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->setCache($mockCache);
+
+               $backend->requireOnce($identifier);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
+               $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 = 'BackendFileRemovalTest';
+
+               $this->backend->setCache($mockCache);
+               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
+               $this->backend->set($entryIdentifier, $data, array(), 1);
+
+               $this->assertFileExists($pathAndFilename);
+
+               $GLOBALS['EXEC_TIME'] += 2;
+               $this->backend->collectGarbage();
+
+               $this->assertFileNotExists($pathAndFilename);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
+               $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 = 'BackendFileRemovalTest';
+
+               $this->backend->setCache($mockCache);
+               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
+
+               $this->backend->set($entryIdentifier . 'A', $data, array(), NULL);
+               $this->backend->set($entryIdentifier . 'B', $data, array(), 10);
+               $this->backend->set($entryIdentifier . 'C', $data, array(), 1);
+               $this->backend->set($entryIdentifier . 'D', $data, array(), 1);
+
+               $this->assertFileExists($pathAndFilename . 'A');
+               $this->assertFileExists($pathAndFilename . 'B');
+               $this->assertFileExists($pathAndFilename . 'C');
+               $this->assertFileExists($pathAndFilename . 'D');
+
+               $GLOBALS['EXEC_TIME'] += 2;
+               $this->backend->collectGarbage();
+
+               $this->assertFileExists($pathAndFilename . 'A');
+               $this->assertFileExists($pathAndFilename . 'B');
+               $this->assertFileNotExists($pathAndFilename . 'C');
+               $this->assertFileNotExists($pathAndFilename . 'D');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $this->backend->setCache($mockCache);
+
+               $data = 'some data' . microtime();
+               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
+
+               $expectedEntry = 'BackendFileTest2';
+
+               $actualEntries = $this->backend->findIdentifiersByTag('UnitTestTag%special');
+
+               $this->assertTrue(is_array($actualEntries), 'actualEntries is not an array.');
+               $this->assertEquals($expectedEntry, array_pop($actualEntries));
+       }
+
+       /**
+        * @test
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function findIdentifiersByTagDoesNotReturnExpiredEntries() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $this->backend->setCache($mockCache);
+
+               $data = 'some data';
+               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'), -100);
+               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
+
+               $this->assertSame(array(), $this->backend->findIdentifiersByTag('UnitTestTag%special'));
+               $foundIdentifiers = $this->backend->findIdentifiersByTag('UnitTestTag%test');
+               sort($foundIdentifiers);
+               $this->assertSame(array('BackendFileTest1', 'BackendFileTest3'), $foundIdentifiers);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushRemovesAllCacheEntries() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $this->backend->setCache($mockCache);
+
+               $data = 'some data' . microtime();
+               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test'));
+               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
+
+               $this->backend->flush();
+
+               $pattern = $this->backend->getCacheDirectory() . '*';
+               $filesFound = is_array(glob($pattern)) ? glob($pattern) : array();
+               $this->assertTrue(count($filesFound) === 0, 'Still files in the cache directory');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
+
+               $this->backend->setCache($mockCache);
+
+               $data = 'some data' . microtime();
+               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
+               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
+
+               $this->backend->flushByTag('UnitTestTag%special');
+
+               $this->assertTrue($this->backend->has('BackendFileTest1'), 'BackendFileTest1');
+               $this->assertFalse($this->backend->has('BackendFileTest2'), 'BackendFileTest2');
+               $this->assertTrue($this->backend->has('BackendFileTest3'), 'BackendFileTest3');
+       }
+
+       /**
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function tearDown() {
+               if (is_object($this->backend)) {
+                       $directory = $this->backend->getCacheDirectory();
+                       if (is_dir($directory)) {
+                               t3lib_div::rmdir($directory, TRUE);
+                       }
+               }
+               foreach ($this->backupGlobalVariables as $key => $data) {
+                       $GLOBALS[$key] = $data;
+               }
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackendTest.php
new file mode 100644 (file)
index 0000000..af42101
--- /dev/null
@@ -0,0 +1,326 @@
+<?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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        * @expectedException t3lib_cache_Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backendOptions = array('servers' => array('localhost:11211'));
+               $backend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
+
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        * @expectedException t3lib_cache_Exception
+        */
+       public function constructorThrowsExceptionIfNoMemcacheServerIsConfigured() {
+               $backend = new t3lib_cache_backend_MemcachedBackend();
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        * @expectedException t3lib_cache_Exception
+        */
+       public function setThrowsExceptionIfConfiguredServersAreUnreachable() {
+               $backend = $this->setUpBackend(array('servers' => array('julle.did.this:1234')));
+               $data = 'Somedata';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache, 'Memcache failed to set and check entry');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData, 'Memcache failed to set and retrieve data');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache, 'Failed to set and remove data from Memcache');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $backend = $this->setUpBackend();
+
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function setRemovesTagsFromPreviousSet() {
+               $backend = $this->setUpBackend();
+
+               $data = 'Some data';
+               $identifier = uniqid('MyIdentifier');
+               $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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = uniqid('NonExistingIdentifier');
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache,'"has" did not return false when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = uniqid('NonExistingIdentifier');
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache,'"remove" did not return false when checking on non existing identifier');
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $backendOptions = array('servers' => array('localhost:11211'));
+
+               $thisCache = $this->getMock(
+                       't3lib_cache_frontend_AbstractFrontend',
+                       array(),
+                       array(),
+                       '',
+                       FALSE
+               );
+               $thisCache->expects($this->any())
+                       ->method('getIdentifier')
+                       ->will($this->returnValue('thisCache'));
+               $thisBackend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
+               $thisBackend->setCache($thisCache);
+
+               $thatCache = $this->getMock(
+                       't3lib_cache_frontend_AbstractFrontend',
+                       array(),
+                       array(),
+                       '',
+                       FALSE
+               );
+               $thatCache->expects($this->any())
+                       ->method('getIdentifier')
+                       ->will($this->returnValue('thatCache'));
+               $thatBackend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
+               $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, this gives some headroom for the
+        * reflection data.
+        *
+        * @test
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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 t3lib_cache_backend_MemcachedBackend
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       protected function setUpBackend(array $backendOptions = array()) {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               if (empty($backendOptions)) {
+                       $backendOptions = array('servers' => array('localhost:11211'));
+               }
+
+               $backend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
+               $backend->setCache($cache);
+
+               return $backend;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_pdobackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_pdobackendTest.php
new file mode 100644 (file)
index 0000000..aeb7b1b
--- /dev/null
@@ -0,0 +1,364 @@
+<?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 {
+
+       /**
+        * Backup of global variable EXEC_TIME
+        *
+        * @var array
+        */
+       protected $backupGlobalVariables;
+
+       /**
+        * Sets up this testcase
+        *
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function setUp() {
+               if (!extension_loaded('pdo_sqlite')) {
+                       $this->markTestSkipped('pdo_sqlite extension was not available');
+               }
+
+               $this->backupGlobalVariables = array(
+                       'EXEC_TIME' => $GLOBALS['EXEC_TIME'],
+               );
+       }
+
+       /**
+        * @test
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @expectedException t3lib_cache_Exception
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = t3lib_div::makeInstance('t3lib_cache_backend_PdoBackend');
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $this->assertTrue($backend->has($identifier));
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData);
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $backend = $this->setUpBackend();
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $this->assertFalse($backend->has($identifier));
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function findIdentifiersByTagsFindsSetEntries() {
+               $backend = $this->setUpBackend();
+
+               $data = 'Some data';
+               $entryIdentifier = 'MyIdentifier';
+               $backend->set($entryIdentifier . 'A', $data, array('UnitTestTag%tag1'));
+               $backend->set($entryIdentifier . 'B', $data, array('UnitTestTag%tag2'));
+               $backend->set($entryIdentifier . 'C', $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+               $backend->set($entryIdentifier . 'D', $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2', 'UnitTestTag%tag3'));
+
+               $retrieved = $backend->findIdentifiersByTags(array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
+
+               $this->assertFalse(in_array($entryIdentifier . 'A', $retrieved));
+               $this->assertFalse(in_array($entryIdentifier . 'B', $retrieved));
+               $this->assertTrue(in_array($entryIdentifier . 'C', $retrieved));
+               $this->assertTrue(in_array($entryIdentifier . 'D', $retrieved));
+       }
+
+       /**
+        * @test
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier';
+               $this->assertFalse($backend->has($identifier));
+       }
+
+       /**
+        * @test
+        * @author Christian Jul Jensen <julle@typo3.org>
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $backend = $this->setUpBackend();
+               $identifier = 'NonExistingIdentifier';
+               $this->assertFalse($backend->remove($identifier));
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function flushByTagsRemovesCacheEntriesWithSpecifiedTags() {
+               $backend = $this->setUpBackend();
+
+               $data = 'some data' . microtime();
+               $backend->set('PdoBackendTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
+               $backend->set('PdoBackendTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special1'));
+               $backend->set('PdoBackendTest3', $data, array('UnitTestTag%test', 'UnitTestTag%special2'));
+               $backend->set('PdoBackendTest4', $data, array('UnitTestTag%test', 'UnitTestTag%special2'));
+
+               $backend->flushByTags(array('UnitTestTag%special1','UnitTestTag%special2'));
+
+               $this->assertTrue($backend->has('PdoBackendTest1'));
+               $this->assertFalse($backend->has('PdoBackendTest2'));
+               $this->assertFalse($backend->has('PdoBackendTest3'));
+               $this->assertFalse($backend->has('PdoBackendTest4'));
+       }
+
+       /**
+        * @test
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function flushRemovesOnlyOwnEntries() {
+               $thisCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
+               $thisBackend = $this->setUpBackend();
+               $thisBackend->setCache($thisCache);
+
+               $thatCache = $this->getMock('t3lib_cache_frontend_Frontend', 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
+        * @author Ingo Renner <ingo@typo3.org>
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Ingo Renner <ingo@typo3.org>
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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 t3lib_cache_backend_PdoBackend
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       protected function setUpBackend() {
+               $mockCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
+
+               $backendOptions = array(
+                       'dataSourceName' => 'sqlite::memory:',
+                       'username' => '',
+                       'password' => '',
+               );
+               $backend = t3lib_div::makeInstance('t3lib_cache_backend_PdoBackend', $backendOptions);
+               $backend->setCache($mockCache);
+
+               return $backend;
+       }
+
+       /**
+        * Clean up after the tests
+        *
+        * @return void
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function tearDown() {
+               foreach ($this->backupGlobalVariables as $key => $data) {
+                       $GLOBALS[$key] = $data;
+               }
+       }
+}
+
+?>
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_redisbackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_redisbackendTest.php
new file mode 100644 (file)
index 0000000..963ec2f
--- /dev/null
@@ -0,0 +1,1123 @@
+<?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 {
+       /**
+        * If set, the tearDown() method will flush the cache used by this unit test.
+        *
+        * @var t3lib_cache_backend_RedisBackend
+        */
+       protected $backend = NULL;
+
+       /**
+        * Own redis instance used in implementation tests
+        *
+        * @var Redis
+        */
+       protected $redis = NULL;
+
+       /**
+        * Set up this testcase
+        *
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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 Options for the redis backend
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       protected function setUpBackend(array $backendOptions = array()) {
+               $mockCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
+
+               $this->backend = new t3lib_cache_backend_RedisBackend($backendOptions);
+               $this->backend->setCache($mockCache);
+       }
+
+       /**
+        * Sets up an own redis instance for implementation tests
+        *
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       protected function setUpRedis() {
+               $this->redis = new Redis();
+               $this->redis->connect('127.0.0.1', 6379);
+       }
+
+       /**
+        * Tear down this testcase
+        *
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function tearDown() {
+               if ($this->backend instanceof t3lib_cache_backend_RedisBackend) {
+                       $this->backend->flush();
+               }
+
+               unset($this->redis, $this->backend);
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function constructorThrowsNoExceptionIfPasswordOptionIsSet() {
+               $this->setUpBackend(array('password' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function constructorThrowsNoExceptionIfGivenDatabaseWasSuccessfullySelected() {
+               $this->setUpBackend(array('database' => 1));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNotAnInteger() {
+               $this->setUpBackend(array('database' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNegative() {
+               $this->setUpBackend(array('database' => -1));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setCompressionThrowsExceptionIfCompressionParameterIsNotOfTypeBoolean() {
+               $this->setUpBackend(array('compression' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotInteger() {
+               $this->setUpBackend(array('compressionLevel' => 'foo'));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotBetweenMinusOneAndNine() {
+               $this->setUpBackend(array('compressionLevel' => 11));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->set(array(), 'data');
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException t3lib_cache_Exception_InvalidData
+        */
+       public function setThrowsExceptionIfDataIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->set('identifier' . uniqid(), array());
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setThrowsExceptionIfLifetimeIsNegative() {
+               $this->setUpBackend();
+               $this->backend->set('identifier' . uniqid(), 'data', array(), -42);
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function setThrowsExceptionIfLifetimeIsNotNullOrAnInteger() {
+               $this->setUpBackend();
+               $this->backend->set('identifier' . uniqid(), 'data', array(), array());
+       }
+
+       /**
+        * @test Implementation
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function hasThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->has(array());
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function hasReturnsFalseForNotExistingEntry() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->assertFalse($this->backend->has($identifier));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function hasReturnsTrueForPreviouslySetEntry() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->assertTrue($this->backend->has($identifier));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function getThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->get(array());
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function removeThrowsExceptionIfIdentifierIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->remove(array());
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function removeReturnsFalseIfNoEntryWasDeleted() {
+               $this->setUpBackend();
+               $this->assertFalse($this->backend->remove('identifier' . uniqid()));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function removeReturnsTrueIfAnEntryWasDeleted() {
+               $this->setUpBackend();
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier, 'data');
+               $this->assertTrue($this->backend->remove($identifier));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Jul Jensen <julle@typo3.org>
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function findIdentifiersByTagThrowsExceptionIfTagIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->findIdentifiersByTag(array());
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function findIdentifiersByTagReturnsEmptyArrayForNotExistingTag() {
+               $this->setUpBackend();
+               $this->assertSame(array(), $this->backend->findIdentifiersByTag('thisTag'));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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 Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function findIdentifiersByTagsReturnEmptyArrayForNotExistingTag() {
+               $this->setUpBackend();
+               $this->assertEquals(array(), $this->backend->findIdentifiersByTags(array('thisTags')));
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function findIdentifiersByTagsReturnsIdentifiersTaggedWithAllSpecifiedTags() {
+               $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->set($identifier . 'D', 'data', array('tag1', 'tag2', 'tag3'));
+
+               $expectedResult = array($identifier . 'C', $identifier . 'D');
+               $actualResult = $this->backend->findIdentifiersByTags(array('tag1', 'tag2'));
+               sort($actualResult);
+
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+
+
+       /**
+        * @test Implementation
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        * @expectedException InvalidArgumentException
+        */
+       public function flushByTagThrowsExceptionIfTagIsNotAString() {
+               $this->setUpBackend();
+               $this->backend->flushByTag(array());
+       }
+
+       /**
+        * @test Functional
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function flushByTagsRemovesEntriesTaggedWithSpecifiedTags() {
+               $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('tag3'));
+               $this->backend->set($identifier . 'D', 'data', array('tag1', 'tag2'));
+               $this->backend->set($identifier . 'E', 'data', array('tag1', 'tag3'));
+               $this->backend->flushByTags(array('tag1', 'tag2'));
+
+               $expectedResult = array(FALSE, FALSE, TRUE, FALSE, FALSE);
+               $actualResult = array(
+                       $this->backend->has($identifier . 'A'),
+                       $this->backend->has($identifier . 'B'),
+                       $this->backend->has($identifier . 'C'),
+                       $this->backend->has($identifier . 'D'),
+                       $this->backend->has($identifier . 'E'),
+               );
+
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function flushByTagsRemovesIdentifierToTagsSetOfEntriesTaggedWithGivenTags() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2'));
+               $this->backend->set($identifier . 'B', 'data', array('tag1', 'tag3'));
+               $this->backend->set($identifier . 'C', 'data', array('tag2', 'tag4'));
+               $this->backend->set($identifier . 'D', 'data', array('tag3', 'tag4'));
+
+               $this->backend->flushByTags(array('tag1', 'tag2'));
+
+               $expectedResult = array(FALSE, FALSE, FALSE, TRUE);
+               $actualResult = array(
+                       $this->redis->exists('identTags:' . $identifier . 'A'),
+                       $this->redis->exists('identTags:' . $identifier . 'B'),
+                       $this->redis->exists('identTags:' . $identifier . 'C'),
+                       $this->redis->exists('identTags:' . $identifier . 'D'),
+               );
+
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function flushByTagsRemovesTagToIdentifiersSetsOfGivenTags() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2'));
+               $this->backend->set($identifier . 'B', 'data', array('tag1', 'tag3'));
+               $this->backend->set($identifier . 'C', 'data', array('tag2', 'tag4'));
+               $this->backend->set($identifier . 'D', 'data', array('tag3', 'tag4'));
+
+               $this->backend->flushByTags(array('tag1', 'tag2'));
+
+               $expectedResult = array(FALSE, FALSE, TRUE, TRUE);
+               $actualResult = array(
+                       $this->redis->exists('tagIdents:tag1'),
+                       $this->redis->exists('tagIdents:tag2'),
+                       $this->redis->exists('tagIdents:tag3'),
+                       $this->redis->exists('tagIdents:tag4'),
+               );
+
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       public function flushByTagsRemovesIdentifiersTaggedWithGivenTagsFromTagToIdentifiersSets() {
+               $this->setUpBackend();
+               $this->setUpRedis();
+
+               $identifier = 'identifier' . uniqid();
+               $this->backend->set('A' . $identifier, 'data', array('tag1', 'tag2'));
+               $this->backend->set('B' . $identifier, 'data', array('tag1', 'tag3'));
+               $this->backend->set('C' . $identifier, 'data', array('tag3', 'tag4'));
+               $this->backend->set('D' . $identifier, 'data', array('tag3', 'tag4', 'tag5'));
+
+               $this->backend->flushByTags(array('tag1', 'tag2'));
+
+               $expectedResult = array(
+                       array('C' . $identifier, 'D' . $identifier),
+                       array('C' . $identifier, 'D' . $identifier),
+                       array('D' . $identifier),
+               );
+
+               $tag3Identifiers = $this->redis->sMembers('tagIdents:tag3');
+               $tag4Identifiers = $this->redis->sMembers('tagIdents:tag4');
+               $tag5Identifiers = $this->redis->sMembers('tagIdents:tag5');
+               sort($tag3Identifiers);
+               sort($tag4Identifiers);
+
+               $actualResult = array(
+                       $tag3Identifiers,
+                       $tag4Identifiers,
+                       $tag5Identifiers,
+               );
+
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test Implementation
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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
+        * @author Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       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);
+       }
+}
+?>
diff --git a/tests/t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackendTest.php b/tests/t3lib/cache/backend/class.t3lib_cache_backend_transientmemorybackendTest.php
new file mode 100644 (file)
index 0000000..4c78a67
--- /dev/null
@@ -0,0 +1,217 @@
+<?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 t3lib_cache_Exception
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function itIsPossibleToSetAndCheckExistenceInCache() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $backend->setCache($cache);
+
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $inCache = $backend->has($identifier);
+               $this->assertTrue($inCache);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function itIsPossibleToSetAndGetEntry() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $backend->setCache($cache);
+
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $fetchedData = $backend->get($identifier);
+               $this->assertEquals($data, $fetchedData);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function itIsPossibleToRemoveEntryFromCache() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $backend->setCache($cache);
+
+               $data = 'Some data';
+               $identifier = 'MyIdentifier';
+               $backend->set($identifier, $data);
+               $backend->remove($identifier);
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function itIsPossibleToOverwriteAnEntryInTheCache() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $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
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $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
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function hasReturnsFalseIfTheEntryDoesntExist() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $backend->setCache($cache);
+
+               $identifier = 'NonExistingIdentifier';
+               $inCache = $backend->has($identifier);
+               $this->assertFalse($inCache);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function removeReturnsFalseIfTheEntryDoesntExist() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $backend->setCache($cache);
+
+               $identifier = 'NonExistingIdentifier';
+               $inCache = $backend->remove($identifier);
+               $this->assertFalse($inCache);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $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
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Ingo Renner <ingo@typo3.org>
+        */
+       public function flushRemovesAllCacheEntries() {
+               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
+               $backend = new t3lib_cache_backend_TransientMemoryBackend();
+               $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/t3lib/cache/backend/t3lib_cache_backend_abstractbackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_abstractbackendTest.php
deleted file mode 100644 (file)
index a3286ab..0000000
+++ /dev/null
@@ -1,83 +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 t3lib_cache_backend_AbstractBackend
-        */
-       protected $backend;
-
-       /**
-        * @return void
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setUp() {
-               $className = uniqid('ConcreteBackend_');
-               eval('
-                       class ' . $className. ' extends t3lib_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 flushByTags(array $tags) {}
-                               public function findIdentifiersByTag($tag) {}
-                               public function findIdentifiersByTags(array $tags) {}
-                               public function collectGarbage() {}
-                               public function setSomeOption($value) {
-                                       $this->someOption = $value;
-                               }
-                               public function getSomeOption() {
-                                       return $this->someOption;
-                               }
-                       }
-               ');
-               $this->backend = new $className();
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function theConstructorCallsSetterMethodsForAllSpecifiedOptions() {
-               $className = get_class($this->backend);
-               $backend = new $className(array('someOption' => 'someValue'));
-               $this->assertSame('someValue', $backend->getSomeOption());
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/t3lib_cache_backend_apcbackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_apcbackendTest.php
deleted file mode 100644 (file)
index fde7de6..0000000
+++ /dev/null
@@ -1,274 +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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @expectedException t3lib_cache_Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backend = new t3lib_cache_backend_ApcBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-               $inCache = $backend->has($identifier);
-               $this->assertTrue($inCache, 'APC backend failed to set and check entry');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData, 'APC backend failed to set and retrieve data');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, 'Failed to set and remove data from APC backend');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function findIdentifiersByTagFindsSetEntries() {
-               $backend = $this->setUpBackend();
-
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function setRemovesTagsFromPreviousSet() {
-               $backend = $this->setUpBackend();
-
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = uniqid('NonExistingIdentifier');
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache,'"has" did not return false when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = uniqid('NonExistingIdentifier');
-               $inCache = $backend->remove($identifier);
-               $this->assertFalse($inCache,'"remove" did not return false when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $thisCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
-               $thisBackend = new t3lib_cache_backend_ApcBackend();
-               $thisBackend->setCache($thisCache);
-
-               $thatCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
-               $thatBackend = new t3lib_cache_backend_ApcBackend();
-               $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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function largeDataIsStored() {
-               $backend = $this->setUpBackend();
-
-               $data = str_repeat('abcde', 1024 * 1024);
-               $identifier = uniqid('tooLargeData');
-               $backend->set($identifier, $data);
-
-               $this->assertTrue($backend->has($identifier));
-               $this->assertEquals($backend->get($identifier), $data);
-       }
-
-       /**
-        * Sets up the APC backend used for testing
-        *
-        * @param array $backendOptions Options for the APC backend
-        * @return t3lib_cache_backend_ApcBackend
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       protected function setUpBackend() {
-               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               $backend = new t3lib_cache_backend_ApcBackend();
-               $backend->setCache($cache);
-
-               return $backend;
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/t3lib_cache_backend_dbbackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_dbbackendTest.php
deleted file mode 100644 (file)
index 3551082..0000000
+++ /dev/null
@@ -1,695 +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 {
-
-       /**
-        * If set, the tearDown() method will clean up the cache table used by this unit test.
-        *
-        * @var t3lib_cache_backend_DbBackend
-        */
-       protected $backend;
-
-       protected $testingCacheTable;
-       protected $testingTagsTable;
-
-       /**
-        * Sets up the backend used for testing
-        *
-        * @return void
-        * @author Ingo Renner <ingo@typo3.org>
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function setUpBackend(array $backendOptions = array()) {
-               $defaultTestingCacheTable = 'test_cache_dbbackend';
-               $defaultTestingTagsTable = 'test_cache_dbbackend_tags';
-
-               $backendOptions = array_merge(
-                       array(
-                               'cacheTable' => $defaultTestingCacheTable,
-                               'tagsTable' => $defaultTestingTagsTable,
-                       ),
-                       $backendOptions
-               );
-
-               $this->testingCacheTable = $backendOptions['cacheTable'];
-               $this->testingTagsTable = $backendOptions['tagsTable'];
-
-               $GLOBALS['TYPO3_DB']->sql_query('CREATE TABLE ' . $this->testingCacheTable . ' (
-                       id int(11) unsigned NOT NULL auto_increment,
-                       identifier varchar(128) DEFAULT \'\' NOT NULL,
-                       crdate int(11) unsigned DEFAULT \'0\' NOT NULL,
-                       content mediumblob,
-                       lifetime int(11) unsigned DEFAULT \'0\' NOT NULL,
-                       PRIMARY KEY (id),
-                       KEY cache_id (identifier)
-               ) ENGINE=InnoDB;
-               ');
-
-               $GLOBALS['TYPO3_DB']->sql_query('CREATE TABLE ' . $this->testingTagsTable . ' (
-                       id int(11) unsigned NOT NULL auto_increment,
-                       identifier varchar(128) DEFAULT \'\' NOT NULL,
-                       tag varchar(128) DEFAULT \'\' NOT NULL,
-                       PRIMARY KEY (id),
-                       KEY cache_id (identifier),
-                       KEY cache_tag (tag)
-               ) ENGINE=InnoDB;
-               ');
-
-               $this->backend = t3lib_div::makeInstance(
-                       't3lib_cache_backend_DbBackend',
-                       $backendOptions
-               );
-       }
-
-       /**
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB']->sql_query(
-                       'DROP TABLE ' . $this->testingCacheTable . ';'
-               );
-
-               $GLOBALS['TYPO3_DB']->sql_query(
-                       'DROP TABLE ' . $this->testingTagsTable . ';'
-               );
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function getCacheTableReturnsThePreviouslySetTable() {
-               $this->setUpBackend();
-               $this->backend->setCacheTable($this->testingCacheTable);
-               $this->assertEquals($this->testingCacheTable, $this->backend->getCacheTable(), 'getCacheTable() did not return the expected value.');
-       }
-
-       /**
-        * @test
-        * @expectedException t3lib_cache_exception_InvalidData
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setThrowsExceptionIfDataIsNotAString() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = array('Some data');
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-
-               $this->backend->set($entryIdentifier, $data);
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setReallySavesToTheSpecifiedTable() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data            = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data);
-
-               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
-                       '*',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertEquals(
-                       $data,
-                       $entryFound['content'],
-                       'The original and the retrieved data don\'t match.'
-               );
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setRemovesAnAlreadyExistingCacheEntryForTheSameIdentifier() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data1 = 'some data' . microtime();
-               $data2 = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemoveBeforeSetTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data1, array(), 500);
-                       // setting a second entry with the same identifier, but different
-                       // data, this should _replace_ the existing one we set before
-               $this->backend->set($entryIdentifier, $data2, array(), 200);
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertEquals(1, count($entriesFound), 'There was not exactly one cache entry.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setReallySavesSpecifiedTags() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-               $this->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, 'The tags do not exist.');
-               $this->assertTrue(in_array('UnitTestTag%tag1', $tags), 'Tag UnitTestTag%tag1 does not exist.');
-               $this->assertTrue(in_array('UnitTestTag%tag2', $tags), 'Tag UnitTestTag%tag2 does not exist.');
-       }
-
-       /**
-        * @test
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function setSavesCompressedDataWithEnabledCompression() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-               $this->setUpBackend(
-                       array(
-                               'compression' => TRUE,
-                       )
-               );
-               $this->backend->setCache($mockCache);
-
-               $data = 'some data ' . microtime();
-
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->set($entryIdentifier, $data);
-
-               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
-                       'content',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertEquals($data, @gzuncompress($entry['content']), 'Original and compressed data don\'t match');
-       }
-
-       /**
-        * @test
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function setSavesPlaintextDataWithEnabledCompressionAndCompressionLevel0() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-               $this->setUpBackend(
-                       array(
-                               'compression' => TRUE,
-                               'compressionLevel' => 0,
-                       )
-               );
-               $this->backend->setCache($mockCache);
-
-               $data = 'some data ' . microtime();
-
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->set($entryIdentifier, $data);
-
-               $entry = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
-                       'content',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertGreaterThan(0, substr_count($entry['content'], $data), 'Plaintext data not found');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function getReturnsContentOfTheCorrectCacheEntry() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data, array(), 500);
-
-               $data = 'some other data' . microtime();
-               $this->backend->set($entryIdentifier, $data, array(), 100);
-
-               $loadedData = $this->backend->get($entryIdentifier);
-
-               $this->assertEquals($data, $loadedData, 'The original and the retrieved data don\'t match.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function hasReturnsTheCorrectResult() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data);
-
-               $this->assertTrue($this->backend->has($entryIdentifier), 'has() did not return TRUE.');
-               $this->assertFalse($this->backend->has($entryIdentifier . 'Not'), 'has() did not return FALSE.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function removeReallyRemovesACacheEntry() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemovalTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data);
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertTrue(is_array($entriesFound) && count($entriesFound) > 0, 'The cache entry does not exist.');
-
-               $this->backend->remove($entryIdentifier);
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertTrue(count($entriesFound) == 0, 'The cache entry still exists.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemovalTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data, array(), 1);
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertTrue(is_array($entriesFound) && count($entriesFound) > 0, 'The cache entry does not exist.');
-
-               sleep(2);
-               $GLOBALS['EXEC_TIME'] += 2;
-               $this->backend->collectGarbage();
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       'identifier = \'' . $entryIdentifier . '\''
-               );
-
-               $this->assertTrue(count($entriesFound) == 0, 'The cache entry still exists.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbRemovalTest';
-
-               $this->backend->setCache($cache);
-
-               $this->backend->set($entryIdentifier . 'A', $data, array(), 1);
-               $this->backend->set($entryIdentifier . 'B', $data, array(), 1);
-               $this->backend->set($entryIdentifier . 'C', $data, array(), 1);
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       ''
-               );
-
-               $this->assertTrue(is_array($entriesFound) && count($entriesFound) > 0, 'The cache entries do not exist.');
-
-               sleep(2);
-               $GLOBALS['EXEC_TIME'] += 2;
-               $this->backend->collectGarbage();
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       ''
-               );
-
-               $this->assertTrue(count($entriesFound) == 0, 'The cache entries still exist.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $this->backend->setCache($cache);
-
-               $data = 'some data' . microtime();
-               $this->backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $this->backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $this->backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
-
-               $expectedEntry = 'BackendDbTest2';
-
-               $actualEntries = $this->backend->findIdentifiersByTag('UnitTestTag%special');
-               $this->assertTrue(is_array($actualEntries), 'actualEntries is not an array.');
-
-               $this->assertEquals($expectedEntry, array_pop($actualEntries));
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function flushRemovesAllCacheEntries() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $this->backend->setCache($cache);
-
-               $data = 'some data' . microtime();
-               $this->backend->set('BackendDbTest1', $data, array('UnitTestTag%test'));
-               $this->backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $this->backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
-
-               $this->backend->flush();
-
-               $entriesFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       '*',
-                       $this->testingCacheTable,
-                       ''
-               );
-
-               $this->assertTrue(count($entriesFound) == 0, 'Still entries in the cache table');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $this->backend->setCache($cache);
-
-               $data = 'some data' . microtime();
-               $this->backend->set('BackendDbTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $this->backend->set('BackendDbTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $this->backend->set('BackendDbTest3', $data, array('UnitTestTag%test'));
-
-               $this->backend->flushByTag('UnitTestTag%special');
-
-               $this->assertTrue($this->backend->has('BackendDbTest1'), 'BackendDbTest1 does not exist anymore.');
-               $this->assertFalse($this->backend->has('BackendDbTest2'), 'BackendDbTest2 still exists.');
-               $this->assertTrue($this->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), 'UnitTestTag%special still exists in tags table');
-       }
-
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function hasReturnsTheCorrectResultForEntryWithExceededLifetime() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data);
-
-               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
-               $expiredData = 'some old data' . microtime();
-               $this->backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
-
-               sleep(2);
-               $GLOBALS['EXEC_TIME'] += 2;
-
-               $this->assertFalse($this->backend->has($expiredEntryIdentifier), 'has() did not return FALSE.');
-       }
-
-       /**
-        * @test
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function hasReturnsTrueForEntryWithUnlimitedLifetime() {
-               $this->setUpBackend();
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($mockCache);
-               $this->backend->set($entryIdentifier, 'data', array(), 0);
-
-               $GLOBALS['EXEC_TIME'] += 1;
-               $this->assertTrue($this->backend->has($entryIdentifier));
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function getReturnsFalseForEntryWithExceededLifetime() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendDbTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data);
-
-               $expiredEntryIdentifier = 'ExpiredBackendDbTest';
-               $expiredData = 'some old data' . microtime();
-               $this->backend->set($expiredEntryIdentifier, $expiredData, array(), 1);
-
-               sleep(2);
-               $GLOBALS['EXEC_TIME'] += 2;
-
-               $this->assertEquals($data, $this->backend->get($entryIdentifier), 'The original and the retrieved data don\'t match.');
-               $this->assertFalse($this->backend->get($expiredEntryIdentifier), 'The expired entry could be loaded.');
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function findIdentifiersByTagReturnsEmptyArrayForEntryWithExceededLifetime() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $this->backend->setCache($cache);
-               $this->backend->set('BackendDbTest', 'some data', array('UnitTestTag%special'), 1);
-
-               sleep(2);
-               $GLOBALS['EXEC_TIME'] += 2;
-                       // Not required, but used to update the pre-calculated queries:
-               $this->backend->setTagsTable($this->testingTagsTable);
-
-               $this->assertEquals(array(), $this->backend->findIdentifiersByTag('UnitTestTag%special'));
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setWithUnlimitedLifetimeWritesCorrectEntry() {
-               $this->setUpBackend();
-               $cache = $this->getMock('t3lib_cache_frontend_AbstractFrontend',
-                       array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove'),
-                       array(),
-                       '',
-                       FALSE
-               );
-
-               $data = 'some data' . microtime();
-               $entryIdentifier = 'BackendFileTest';
-
-               $this->backend->setCache($cache);
-               $this->backend->set($entryIdentifier, $data, array(), 0);
-
-               $entryFound = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
-                       '*',
-                       $this->testingCacheTable,
-                       ''
-               );
-
-               $this->assertTrue(is_array($entryFound), 'entriesFound is not an array.');
-
-               $retrievedData = $entryFound['content'];
-               $this->assertEquals($data, $retrievedData, 'The original and the retrieved data don\'t match.');
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/t3lib_cache_backend_filebackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_filebackendTest.php
deleted file mode 100644 (file)
index a9047c3..0000000
+++ /dev/null
@@ -1,563 +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 {
-       /**
-        * Backup of global variable EXEC_TIME
-        *
-        * @var array
-        */
-       protected $backupGlobalVariables;
-
-       /**
-        * If set, the tearDown() method will clean up the cache subdirectory used by this unit test.
-        *
-        * @var t3lib_cache_backend_FileBackend
-        */
-       protected $backend;
-
-       /**
-        * @var string Directory for testing data, relative to PATH_site
-        */
-       protected $testingCacheDirectory;
-
-       /**
-        * Sets up this testcase
-        *
-        * @return void
-        */
-       public function setUp() {
-               $this->backupGlobalVariables = array(
-                       'EXEC_TIME' => $GLOBALS['EXEC_TIME'],
-               );
-
-               $this->testingCacheDirectory = 'typo3temp/cache/testing/';
-
-               $this->backend = t3lib_div::makeInstance(
-                       't3lib_cache_backend_FileBackend',
-                       array('cacheDirectory' => $this->testingCacheDirectory)
-               );
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function defaultCacheDirectoryIsWritable() {
-               $cacheDirectory = $this->backend->getCacheDirectory();
-
-               $this->assertTrue(is_writable($cacheDirectory), 'The default cache directory "' . $cacheDirectory . '" is not writable.');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function setCacheDirectoryThrowsExceptionOnNonWritableDirectory() {
-               if (TYPO3_OS == 'WIN') {
-                       $this->markTestSkipped('test not reliable in Windows environment');
-               }
-
-                       // Create test directory and remove write permissions
-               $directoryName = PATH_site . 'typo3temp/' . uniqid('test_');
-               t3lib_div::mkdir($directoryName);
-               chmod($directoryName, 1551);
-
-               try {
-                       $this->backend->setCacheDirectory($directoryName);
-                       $this->fail('setCacheDirectory did not throw an exception on a non writable directory');
-               } catch (t3lib_cache_Exception $e) {
-                               // Remove created test directory
-                       t3lib_div::rmdir($directoryName);
-               }
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function getCacheDirectoryReturnsTheCurrentCacheDirectory() {
-               $directory = $this->testingCacheDirectory;
-               $fullPathToDirectory = PATH_site . $directory;
-
-               $this->backend->setCacheDirectory($directory);
-               $this->assertEquals($fullPathToDirectory, $this->backend->getCacheDirectory(), 'getCacheDirectory() did not return the expected value.');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        * @expectedException t3lib_cache_exception_InvalidData
-        */
-       public function setThrowsExceptionIfDataIsNotAString() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $this->backend->setCache($mockCache);
-               $data = array('Some data');
-               $entryIdentifier = 'BackendFileTest';
-
-               $this->backend->set($entryIdentifier, $data);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       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';
-               $this->backend->setCache($mockCache);
-               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
-
-               $this->backend->set($entryIdentifier, $data, array(), 10);
-
-               $this->assertFileExists($pathAndFilename);
-               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data));
-               $this->assertEquals($data, $retrievedData);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       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';
-
-               $this->backend->setCache($mockCache);
-               $this->backend->set($entryIdentifier, $data1, array(), 500);
-                       // Setting a second entry with the same identifier, but different
-                       // data, this should _replace_ the existing one we set before
-               $this->backend->set($entryIdentifier, $data2, array(), 200);
-
-               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
-
-               $this->assertFileExists($pathAndFilename);
-               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, strlen($data2));
-               $this->assertEquals($data2, $retrievedData);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       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 = 'BackendFileTest';
-
-               $this->backend->setCache($mockCache);
-               $this->backend->set($entryIdentifier, $data, array('Tag1', 'Tag2'));
-
-               $pathAndFilename = $this->backend->getCacheDirectory() . $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
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function setWithUnlimitedLifetimeWritesCorrectEntry() {
-               $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';
-
-               $this->backend->setCache($mockCache);
-               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
-
-               $this->backend->set($entryIdentifier, $data, array(), 0);
-
-               $this->assertFileExists($pathAndFilename);
-
-               $dataSize = (integer)file_get_contents($pathAndFilename, NULL, NULL, filesize($pathAndFilename) - t3lib_cache_backend_FileBackend::DATASIZE_DIGITS, t3lib_cache_backend_FileBackend::DATASIZE_DIGITS);
-               $retrievedData = file_get_contents($pathAndFilename, NULL, NULL, 0, $dataSize);
-
-               $this->assertEquals($data, $retrievedData, 'The original and the retrieved data don\'t match.');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       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);
-               $fullPathToCacheFile = PATH_site . 'typo3temp/cache/UnitTestCache/ExpiredEntry';
-               $backend->expects($this->once())->method('isCacheFileExpired')->with($fullPathToCacheFile)->will($this->returnValue(TRUE));
-               $backend->setCache($mockCache);
-
-               $this->assertFalse($backend->get('ExpiredEntry'));
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function hasReturnsTrueIfAnEntryExists() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $this->backend->setCache($mockCache);
-
-               $entryIdentifier = 'BackendFileTest';
-               $data = 'some data' . microtime();
-               $this->backend->set($entryIdentifier, $data);
-
-               $this->assertTrue($this->backend->has($entryIdentifier), 'has() did not return TRUE.');
-               $this->assertFalse($this->backend->has($entryIdentifier . 'Not'), 'has() did not return FALSE.');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       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
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       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';
-
-               $this->backend->setCache($mockCache);
-               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
-               $this->backend->set($entryIdentifier, $data);
-
-               $this->assertFileExists($pathAndFilename);
-               $this->backend->remove($entryIdentifier);
-               $this->assertFileNotExists($pathAndFilename);
-       }
-
-       /**
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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(), '', TRUE);
-               $backend->setCache($mockCache);
-
-               $backend->set($identifier, 'cache data', array());
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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->setCache($mockCache);
-
-               $backend->get($identifier);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function hasThrowsExceptionForInvalidIdentifier($identifier) {
-               $backend = $this->getMock('t3lib_cache_backend_FileBackend', array('dummy'), array(), '', FALSE);
-
-               $backend->has($identifier);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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->setCache($mockCache);
-
-               $backend->remove($identifier);
-       }
-
-       /**
-        * @test
-        * @dataProvider invalidEntryIdentifiers
-        * @expectedException InvalidArgumentException
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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->setCache($mockCache);
-
-               $backend->requireOnce($identifier);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function collectGarbageReallyRemovesAnExpiredCacheEntry() {
-               $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 = 'BackendFileRemovalTest';
-
-               $this->backend->setCache($mockCache);
-               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
-               $this->backend->set($entryIdentifier, $data, array(), 1);
-
-               $this->assertFileExists($pathAndFilename);
-
-               $GLOBALS['EXEC_TIME'] += 2;
-               $this->backend->collectGarbage();
-
-               $this->assertFileNotExists($pathAndFilename);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function collectGarbageReallyRemovesAllExpiredCacheEntries() {
-               $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 = 'BackendFileRemovalTest';
-
-               $this->backend->setCache($mockCache);
-               $pathAndFilename = $this->backend->getCacheDirectory() . $entryIdentifier;
-
-               $this->backend->set($entryIdentifier . 'A', $data, array(), NULL);
-               $this->backend->set($entryIdentifier . 'B', $data, array(), 10);
-               $this->backend->set($entryIdentifier . 'C', $data, array(), 1);
-               $this->backend->set($entryIdentifier . 'D', $data, array(), 1);
-
-               $this->assertFileExists($pathAndFilename . 'A');
-               $this->assertFileExists($pathAndFilename . 'B');
-               $this->assertFileExists($pathAndFilename . 'C');
-               $this->assertFileExists($pathAndFilename . 'D');
-
-               $GLOBALS['EXEC_TIME'] += 2;
-               $this->backend->collectGarbage();
-
-               $this->assertFileExists($pathAndFilename . 'A');
-               $this->assertFileExists($pathAndFilename . 'B');
-               $this->assertFileNotExists($pathAndFilename . 'C');
-               $this->assertFileNotExists($pathAndFilename . 'D');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $this->backend->setCache($mockCache);
-
-               $data = 'some data' . microtime();
-               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
-
-               $expectedEntry = 'BackendFileTest2';
-
-               $actualEntries = $this->backend->findIdentifiersByTag('UnitTestTag%special');
-
-               $this->assertTrue(is_array($actualEntries), 'actualEntries is not an array.');
-               $this->assertEquals($expectedEntry, array_pop($actualEntries));
-       }
-
-       /**
-        * @test
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function findIdentifiersByTagDoesNotReturnExpiredEntries() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $this->backend->setCache($mockCache);
-
-               $data = 'some data';
-               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'), -100);
-               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
-
-               $this->assertSame(array(), $this->backend->findIdentifiersByTag('UnitTestTag%special'));
-               $foundIdentifiers = $this->backend->findIdentifiersByTag('UnitTestTag%test');
-               sort($foundIdentifiers);
-               $this->assertSame(array('BackendFileTest1', 'BackendFileTest3'), $foundIdentifiers);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function flushRemovesAllCacheEntries() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $this->backend->setCache($mockCache);
-
-               $data = 'some data' . microtime();
-               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test'));
-               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
-
-               $this->backend->flush();
-
-               $pattern = $this->backend->getCacheDirectory() . '*';
-               $filesFound = is_array(glob($pattern)) ? glob($pattern) : array();
-               $this->assertTrue(count($filesFound) === 0, 'Still files in the cache directory');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function flushByTagRemovesCacheEntriesWithSpecifiedTag() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_AbstractFrontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
-
-               $this->backend->setCache($mockCache);
-
-               $data = 'some data' . microtime();
-               $this->backend->set('BackendFileTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $this->backend->set('BackendFileTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special'));
-               $this->backend->set('BackendFileTest3', $data, array('UnitTestTag%test'));
-
-               $this->backend->flushByTag('UnitTestTag%special');
-
-               $this->assertTrue($this->backend->has('BackendFileTest1'), 'BackendFileTest1');
-               $this->assertFalse($this->backend->has('BackendFileTest2'), 'BackendFileTest2');
-               $this->assertTrue($this->backend->has('BackendFileTest3'), 'BackendFileTest3');
-       }
-
-       /**
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function tearDown() {
-               if (is_object($this->backend)) {
-                       $directory = $this->backend->getCacheDirectory();
-                       if (is_dir($directory)) {
-                               t3lib_div::rmdir($directory, TRUE);
-                       }
-               }
-               foreach ($this->backupGlobalVariables as $key => $data) {
-                       $GLOBALS[$key] = $data;
-               }
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/t3lib_cache_backend_memcachedbackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_memcachedbackendTest.php
deleted file mode 100644 (file)
index af42101..0000000
+++ /dev/null
@@ -1,326 +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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        * @expectedException t3lib_cache_Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backendOptions = array('servers' => array('localhost:11211'));
-               $backend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
-
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        * @expectedException t3lib_cache_Exception
-        */
-       public function constructorThrowsExceptionIfNoMemcacheServerIsConfigured() {
-               $backend = new t3lib_cache_backend_MemcachedBackend();
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        * @expectedException t3lib_cache_Exception
-        */
-       public function setThrowsExceptionIfConfiguredServersAreUnreachable() {
-               $backend = $this->setUpBackend(array('servers' => array('julle.did.this:1234')));
-               $data = 'Somedata';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-               $inCache = $backend->has($identifier);
-               $this->assertTrue($inCache, 'Memcache failed to set and check entry');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData, 'Memcache failed to set and retrieve data');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache, 'Failed to set and remove data from Memcache');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToOverwriteAnEntryInTheCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag() {
-               $backend = $this->setUpBackend();
-
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function setRemovesTagsFromPreviousSet() {
-               $backend = $this->setUpBackend();
-
-               $data = 'Some data';
-               $identifier = uniqid('MyIdentifier');
-               $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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = uniqid('NonExistingIdentifier');
-               $inCache = $backend->has($identifier);
-               $this->assertFalse($inCache,'"has" did not return false when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = uniqid('NonExistingIdentifier');
-               $inCache = $backend->remove($identifier);
-               $this->assertFalse($inCache,'"remove" did not return false when checking on non existing identifier');
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $backendOptions = array('servers' => array('localhost:11211'));
-
-               $thisCache = $this->getMock(
-                       't3lib_cache_frontend_AbstractFrontend',
-                       array(),
-                       array(),
-                       '',
-                       FALSE
-               );
-               $thisCache->expects($this->any())
-                       ->method('getIdentifier')
-                       ->will($this->returnValue('thisCache'));
-               $thisBackend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
-               $thisBackend->setCache($thisCache);
-
-               $thatCache = $this->getMock(
-                       't3lib_cache_frontend_AbstractFrontend',
-                       array(),
-                       array(),
-                       '',
-                       FALSE
-               );
-               $thatCache->expects($this->any())
-                       ->method('getIdentifier')
-                       ->will($this->returnValue('thatCache'));
-               $thatBackend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
-               $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, this gives some headroom for the
-        * reflection data.
-        *
-        * @test
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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 t3lib_cache_backend_MemcachedBackend
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @author Ingo Renner <ingo@typo3.org>
-        */
-       protected function setUpBackend(array $backendOptions = array()) {
-               $cache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               if (empty($backendOptions)) {
-                       $backendOptions = array('servers' => array('localhost:11211'));
-               }
-
-               $backend = new t3lib_cache_backend_MemcachedBackend($backendOptions);
-               $backend->setCache($cache);
-
-               return $backend;
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/tests/t3lib/cache/backend/t3lib_cache_backend_pdobackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_pdobackendTest.php
deleted file mode 100644 (file)
index aeb7b1b..0000000
+++ /dev/null
@@ -1,364 +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 {
-
-       /**
-        * Backup of global variable EXEC_TIME
-        *
-        * @var array
-        */
-       protected $backupGlobalVariables;
-
-       /**
-        * Sets up this testcase
-        *
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function setUp() {
-               if (!extension_loaded('pdo_sqlite')) {
-                       $this->markTestSkipped('pdo_sqlite extension was not available');
-               }
-
-               $this->backupGlobalVariables = array(
-                       'EXEC_TIME' => $GLOBALS['EXEC_TIME'],
-               );
-       }
-
-       /**
-        * @test
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        * @expectedException t3lib_cache_Exception
-        */
-       public function setThrowsExceptionIfNoFrontEndHasBeenSet() {
-               $backend = t3lib_div::makeInstance('t3lib_cache_backend_PdoBackend');
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToSetAndCheckExistenceInCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $this->assertTrue($backend->has($identifier));
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToSetAndGetEntry() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $fetchedData = $backend->get($identifier);
-               $this->assertEquals($data, $fetchedData);
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function itIsPossibleToRemoveEntryFromCache() {
-               $backend = $this->setUpBackend();
-               $data = 'Some data';
-               $identifier = 'MyIdentifier';
-               $backend->set($identifier, $data);
-               $backend->remove($identifier);
-               $this->assertFalse($backend->has($identifier));
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function findIdentifiersByTagsFindsSetEntries() {
-               $backend = $this->setUpBackend();
-
-               $data = 'Some data';
-               $entryIdentifier = 'MyIdentifier';
-               $backend->set($entryIdentifier . 'A', $data, array('UnitTestTag%tag1'));
-               $backend->set($entryIdentifier . 'B', $data, array('UnitTestTag%tag2'));
-               $backend->set($entryIdentifier . 'C', $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-               $backend->set($entryIdentifier . 'D', $data, array('UnitTestTag%tag1', 'UnitTestTag%tag2', 'UnitTestTag%tag3'));
-
-               $retrieved = $backend->findIdentifiersByTags(array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
-
-               $this->assertFalse(in_array($entryIdentifier . 'A', $retrieved));
-               $this->assertFalse(in_array($entryIdentifier . 'B', $retrieved));
-               $this->assertTrue(in_array($entryIdentifier . 'C', $retrieved));
-               $this->assertTrue(in_array($entryIdentifier . 'D', $retrieved));
-       }
-
-       /**
-        * @test
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function hasReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier';
-               $this->assertFalse($backend->has($identifier));
-       }
-
-       /**
-        * @test
-        * @author Christian Jul Jensen <julle@typo3.org>
-        */
-       public function removeReturnsFalseIfTheEntryDoesntExist() {
-               $backend = $this->setUpBackend();
-               $identifier = 'NonExistingIdentifier';
-               $this->assertFalse($backend->remove($identifier));
-       }
-
-       /**
-        * @test
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function flushByTagsRemovesCacheEntriesWithSpecifiedTags() {
-               $backend = $this->setUpBackend();
-
-               $data = 'some data' . microtime();
-               $backend->set('PdoBackendTest1', $data, array('UnitTestTag%test', 'UnitTestTag%boring'));
-               $backend->set('PdoBackendTest2', $data, array('UnitTestTag%test', 'UnitTestTag%special1'));
-               $backend->set('PdoBackendTest3', $data, array('UnitTestTag%test', 'UnitTestTag%special2'));
-               $backend->set('PdoBackendTest4', $data, array('UnitTestTag%test', 'UnitTestTag%special2'));
-
-               $backend->flushByTags(array('UnitTestTag%special1','UnitTestTag%special2'));
-
-               $this->assertTrue($backend->has('PdoBackendTest1'));
-               $this->assertFalse($backend->has('PdoBackendTest2'));
-               $this->assertFalse($backend->has('PdoBackendTest3'));
-               $this->assertFalse($backend->has('PdoBackendTest4'));
-       }
-
-       /**
-        * @test
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       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
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function flushRemovesOnlyOwnEntries() {
-               $thisCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
-               $thisBackend = $this->setUpBackend();
-               $thisBackend->setCache($thisCache);
-
-               $thatCache = $this->getMock('t3lib_cache_frontend_Frontend', 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
-        * @author Ingo Renner <ingo@typo3.org>
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Ingo Renner <ingo@typo3.org>
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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 t3lib_cache_backend_PdoBackend
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       protected function setUpBackend() {
-               $mockCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
-
-               $backendOptions = array(
-                       'dataSourceName' => 'sqlite::memory:',
-                       'username' => '',
-                       'password' => '',
-               );
-               $backend = t3lib_div::makeInstance('t3lib_cache_backend_PdoBackend', $backendOptions);
-               $backend->setCache($mockCache);
-
-               return $backend;
-       }
-
-       /**
-        * Clean up after the tests
-        *
-        * @return void
-        * @author Karsten Dambekalns <karsten@typo3.org>
-        */
-       public function tearDown() {
-               foreach ($this->backupGlobalVariables as $key => $data) {
-                       $GLOBALS[$key] = $data;
-               }
-       }
-}
-
-?>
diff --git a/tests/t3lib/cache/backend/t3lib_cache_backend_redisbackendTest.php b/tests/t3lib/cache/backend/t3lib_cache_backend_redisbackendTest.php
deleted file mode 100644 (file)
index 963ec2f..0000000
+++ /dev/null
@@ -1,1123 +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 {
-       /**
-        * If set, the tearDown() method will flush the cache used by this unit test.
-        *
-        * @var t3lib_cache_backend_RedisBackend
-        */
-       protected $backend = NULL;
-
-       /**
-        * Own redis instance used in implementation tests
-        *
-        * @var Redis
-        */
-       protected $redis = NULL;
-
-       /**
-        * Set up this testcase
-        *
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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 Options for the redis backend
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       protected function setUpBackend(array $backendOptions = array()) {
-               $mockCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
-               $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
-
-               $this->backend = new t3lib_cache_backend_RedisBackend($backendOptions);
-               $this->backend->setCache($mockCache);
-       }
-
-       /**
-        * Sets up an own redis instance for implementation tests
-        *
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       protected function setUpRedis() {
-               $this->redis = new Redis();
-               $this->redis->connect('127.0.0.1', 6379);
-       }
-
-       /**
-        * Tear down this testcase
-        *
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function tearDown() {
-               if ($this->backend instanceof t3lib_cache_backend_RedisBackend) {
-                       $this->backend->flush();
-               }
-
-               unset($this->redis, $this->backend);
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function constructorThrowsNoExceptionIfPasswordOptionIsSet() {
-               $this->setUpBackend(array('password' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function constructorThrowsNoExceptionIfGivenDatabaseWasSuccessfullySelected() {
-               $this->setUpBackend(array('database' => 1));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNotAnInteger() {
-               $this->setUpBackend(array('database' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setDatabaseThrowsExceptionIfGivenDatabaseNumberIsNegative() {
-               $this->setUpBackend(array('database' => -1));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setCompressionThrowsExceptionIfCompressionParameterIsNotOfTypeBoolean() {
-               $this->setUpBackend(array('compression' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotInteger() {
-               $this->setUpBackend(array('compressionLevel' => 'foo'));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setCompressionLevelThrowsExceptionIfCompressionLevelIsNotBetweenMinusOneAndNine() {
-               $this->setUpBackend(array('compressionLevel' => 11));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->set(array(), 'data');
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException t3lib_cache_Exception_InvalidData
-        */
-       public function setThrowsExceptionIfDataIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->set('identifier' . uniqid(), array());
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setThrowsExceptionIfLifetimeIsNegative() {
-               $this->setUpBackend();
-               $this->backend->set('identifier' . uniqid(), 'data', array(), -42);
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function setThrowsExceptionIfLifetimeIsNotNullOrAnInteger() {
-               $this->setUpBackend();
-               $this->backend->set('identifier' . uniqid(), 'data', array(), array());
-       }
-
-       /**
-        * @test Implementation
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function hasThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->has(array());
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function hasReturnsFalseForNotExistingEntry() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->assertFalse($this->backend->has($identifier));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function hasReturnsTrueForPreviouslySetEntry() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->assertTrue($this->backend->has($identifier));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function getThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->get(array());
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        * @expectedException InvalidArgumentException
-        */
-       public function removeThrowsExceptionIfIdentifierIsNotAString() {
-               $this->setUpBackend();
-               $this->backend->remove(array());
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function removeReturnsFalseIfNoEntryWasDeleted() {
-               $this->setUpBackend();
-               $this->assertFalse($this->backend->remove('identifier' . uniqid()));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       public function removeReturnsTrueIfAnEntryWasDeleted() {
-               $this->setUpBackend();
-               $identifier = 'identifier' . uniqid();
-               $this->backend->set($identifier, 'data');
-               $this->assertTrue($this->backend->remove($identifier));
-       }
-
-       /**
-        * @test Functional
-        * @author Christian Jul Jensen <julle@typo3.org>
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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
-        * @author Christian Kuhn <lolli@schwarzbu.ch>
-        */
-       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));
-       }
-
-       /**