summaryrefslogtreecommitdiffstats
path: root/tests/lib/DB/LegacyDBTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/DB/LegacyDBTest.php')
-rw-r--r--tests/lib/DB/LegacyDBTest.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/DB/LegacyDBTest.php b/tests/lib/DB/LegacyDBTest.php
index 7aeeb3dd1f9..f3de570c52d 100644
--- a/tests/lib/DB/LegacyDBTest.php
+++ b/tests/lib/DB/LegacyDBTest.php
@@ -46,6 +46,11 @@ class LegacyDBTest extends \Test\TestCase {
*/
private $table5;
+ /**
+ * @var string
+ */
+ private $text_table;
+
protected function setUp() {
parent::setUp();
@@ -63,6 +68,7 @@ class LegacyDBTest extends \Test\TestCase {
$this->table3 = $this->test_prefix.'vcategory';
$this->table4 = $this->test_prefix.'decimal';
$this->table5 = $this->test_prefix.'uniconst';
+ $this->text_table = $this->test_prefix.'text_table';
}
protected function tearDown() {
@@ -390,4 +396,33 @@ class LegacyDBTest extends \Test\TestCase {
$result = $query->execute(array('%ba%'));
$this->assertCount(1, $result->fetchAll());
}
+
+ /**
+ * @dataProvider insertAndSelectDataProvider
+ */
+ public function testInsertAndSelectData($expected, $throwsOnMysqlWithoutUTF8MB4) {
+ $table = "*PREFIX*{$this->text_table}";
+ $config = \OC::$server->getConfig();
+
+ $query = OC_DB::prepare("INSERT INTO `$table` (`textfield`) VALUES (?)");
+ if ($throwsOnMysqlWithoutUTF8MB4 && $config->getSystemValue('dbtype', 'sqlite') === 'mysql' && $config->getSystemValue('mysql.utf8mb4', false) === false) {
+ $this->markTestSkipped('MySQL requires UTF8mb4 to store value: ' . $expected);
+ }
+ $result = $query->execute(array($expected));
+ $this->assertEquals(1, $result);
+
+ $actual = OC_DB::prepare("SELECT `textfield` FROM `$table`")->execute()->fetchOne();
+ $this->assertSame($expected, $actual);
+ }
+
+ public function insertAndSelectDataProvider() {
+ return [
+ ['abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXYZ', false],
+ ['0123456789', false],
+ ['äöüÄÖÜß!"§$%&/()=?#\'+*~°^`´', false],
+ ['²³¼½¬{[]}\\', false],
+ ['♡⚗', false],
+ ['💩', true], # :hankey: on github
+ ];
+ }
}