Merge pull request #6345 from owncloud/mysql-set-names-utf8-tests

DB tests: Test whether we can insert and read UTF8 data.
This commit is contained in:
Thomas Müller 2013-12-17 01:54:30 -08:00
commit 5a1194520e
1 changed files with 27 additions and 0 deletions

View File

@ -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);
}
}