diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-12-17 01:54:30 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-12-17 01:54:30 -0800 |
commit | 5a1194520ec71e9f471289a6f85e4c2aa93a9e59 (patch) | |
tree | 43b0731554cf081025a303c815bd9f4351c78db9 | |
parent | 275d666d2630b94229d88c10b7978e66fd0b8079 (diff) | |
parent | ab4136f4329bf702e72e6eaa3fd1e32b1c1f1cd4 (diff) | |
download | nextcloud-server-5a1194520ec71e9f471289a6f85e4c2aa93a9e59.tar.gz nextcloud-server-5a1194520ec71e9f471289a6f85e4c2aa93a9e59.zip |
Merge pull request #6345 from owncloud/mysql-set-names-utf8-tests
DB tests: Test whether we can insert and read UTF8 data.
-rw-r--r-- | tests/lib/db.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php index 1977025cf12..3fcdf8a7dc6 100644 --- a/tests/lib/db.php +++ b/tests/lib/db.php @@ -12,6 +12,21 @@ class Test_DB extends PHPUnit_Framework_TestCase { protected static $schema_file = 'static://test_db_scheme'; protected $test_prefix; + /** + * @var string + */ + private $table1; + + /** + * @var string + */ + private $table2; + + /** + * @var string + */ + private $table3; + public function setUp() { $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; @@ -145,4 +160,16 @@ class Test_DB extends PHPUnit_Framework_TestCase { $this->assertEquals(1, $result->numRows()); } + + public function testUtf8Data() { + $table = "*PREFIX*{$this->table2}"; + $expected = "Ћö雙喜\xE2\x80\xA2"; + + $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); + $result = $query->execute(array($expected, 'uri_1', 'This is a vCard')); + $this->assertEquals(1, $result); + + $actual = OC_DB::prepare("SELECT `fullname` FROM `$table`")->execute()->fetchOne(); + $this->assertSame($expected, $actual); + } } |