[TASK] Functional test for VariableFrontend cache type 94/51394/3
authorManuel Selbach <manuel_selbach@yahoo.de>
Sun, 22 Jan 2017 06:13:44 +0000 (22:13 -0800)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 26 Jan 2017 16:05:03 +0000 (17:05 +0100)
Add a functional test to verify that serialized PHP objects
can be successfully stored in the database without having
encoding/escaping problems.

Resolves: #79452
Releases: master
Change-Id: I97d586cb8a50e571d99ff8b7fc463c0a83e15f36
Reviewed-on: https://review.typo3.org/51394
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Manuel Selbach <manuel_selbach@yahoo.de>
Tested-by: Manuel Selbach <manuel_selbach@yahoo.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/core/Tests/Functional/Cache/Frontend/VariableFrontendTest.php [new file with mode: 0644]

diff --git a/typo3/sysext/core/Tests/Functional/Cache/Frontend/VariableFrontendTest.php b/typo3/sysext/core/Tests/Functional/Cache/Frontend/VariableFrontendTest.php
new file mode 100644 (file)
index 0000000..f8a37d6
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Functional\Cache\Frontend;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
+use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
+
+/**
+ * Test case
+ */
+class VariableFrontendTest extends \TYPO3\CMS\Components\TestingFramework\Core\FunctionalTestCase
+{
+    public function insertSerializedArrayIntoLobAndRetrieveItDataProvider()
+    {
+        $arrayToSerialize = [
+            'string' => 'Serialize a string',
+            'integer' => 0,
+            'anotherIntegerValue' => 123456,
+            'float' => 12.34,
+            'bool' => true,
+            'array' => [
+                0 => 'test',
+                1 => 'another test',
+            ],
+        ];
+
+        return [
+            [
+                $arrayToSerialize,
+                'cache_pages',
+                $arrayToSerialize,
+            ]
+        ];
+    }
+
+    /**
+     * @dataProvider insertSerializedArrayIntoLobAndRetrieveItDataProvider
+     *
+     * @test
+     *
+     * @param array $expected
+     * @param string $identifier
+     * @param array $arrayToSerialize
+     */
+    public function insertSerializedArrayIntoLobAndRetrieveIt(
+        array $expected,
+        string $identifier,
+        array $arrayToSerialize
+    ) {
+        $typo3DatabaseBackend = new Typo3DatabaseBackend('Testing');
+        $subject = new VariableFrontend($identifier, $typo3DatabaseBackend);
+
+        $subject->set('myIdentifier', $arrayToSerialize);
+        $this->assertSame($expected, $subject->get('myIdentifier'));
+    }
+}