summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-07-30 10:57:16 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-10-19 00:15:01 +0200
commit972e560e7274cf25021b1a5095206640b063789a (patch)
treedfdce374cd21574529e6e5486d42356046897f56
parente115bf96e742909b78150d04305b67196b94115c (diff)
downloadnextcloud-server-972e560e7274cf25021b1a5095206640b063789a.tar.gz
nextcloud-server-972e560e7274cf25021b1a5095206640b063789a.zip
Adding tests for 4 byte unicode characters
* success on SQLite and Postgres * failure on MySQL due to the limited charset that only supports up to 3 bytes
-rw-r--r--tests/data/db_structure.xml15
-rw-r--r--tests/lib/DB/LegacyDBTest.php31
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/data/db_structure.xml b/tests/data/db_structure.xml
index 371da944832..b155114f2ed 100644
--- a/tests/data/db_structure.xml
+++ b/tests/data/db_structure.xml
@@ -293,4 +293,19 @@
</table>
+ <table>
+
+ <name>*dbprefix*text_table</name>
+ <declaration>
+
+ <field>
+ <name>textfield</name>
+ <type>text</type>
+ <notnull>false</notnull>
+ <length>255</length>
+ </field>
+
+ </declaration>
+ </table>
+
</database>
diff --git a/tests/lib/DB/LegacyDBTest.php b/tests/lib/DB/LegacyDBTest.php
index 7aeeb3dd1f9..2c91121c024 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,29 @@ class LegacyDBTest extends \Test\TestCase {
$result = $query->execute(array('%ba%'));
$this->assertCount(1, $result->fetchAll());
}
+
+ /**
+ * @dataProvider insertAndSelectDataProvider
+ */
+ public function testInsertAndSelectData($expected) {
+ $table = "*PREFIX*{$this->text_table}";
+
+ $query = OC_DB::prepare("INSERT INTO `$table` (`textfield`) VALUES (?)");
+ $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'],
+ ['0123456789'],
+ ['äöüÄÖÜß!"§$%&/()=?#\'+*~°^`´'],
+ ['²³¼½¬{[]}\\'],
+ ['♡⚗'],
+ ['💩'], # :hankey: on github
+ ];
+ }
}