Browse Source

MySQL driver+test => utf8mb3 -> utf8mb4 (#11329)

Use utf8mb4 by default as it gives the greatest compatibility with unicode in the wild.
inoas 8 years ago
parent
commit
5349d9086d
2 changed files with 8 additions and 8 deletions
  1. 1 1
      src/Database/Driver/Mysql.php
  2. 7 7
      tests/TestCase/Database/Driver/MysqlTest.php

+ 1 - 1
src/Database/Driver/Mysql.php

@@ -39,7 +39,7 @@ class Mysql extends Driver
         'database' => 'cake',
         'port' => '3306',
         'flags' => [],
-        'encoding' => 'utf8',
+        'encoding' => 'utf8mb4',
         'timezone' => null,
         'init' => [],
     ];

+ 7 - 7
tests/TestCase/Database/Driver/MysqlTest.php

@@ -46,7 +46,7 @@ class MysqlTest extends TestCase
         $driver = $this->getMockBuilder('Cake\Database\Driver\Mysql')
             ->setMethods(['_connect', 'connection'])
             ->getMock();
-        $dsn = 'mysql:host=localhost;port=3306;dbname=cake;charset=utf8';
+        $dsn = 'mysql:host=localhost;port=3306;dbname=cake;charset=utf8mb4';
         $expected = [
             'persistent' => true,
             'host' => 'localhost',
@@ -55,9 +55,9 @@ class MysqlTest extends TestCase
             'database' => 'cake',
             'port' => '3306',
             'flags' => [],
-            'encoding' => 'utf8',
+            'encoding' => 'utf8mb4',
             'timezone' => null,
-            'init' => ['SET NAMES utf8'],
+            'init' => ['SET NAMES utf8mb4'],
         ];
 
         $expected['flags'] += [
@@ -93,7 +93,7 @@ class MysqlTest extends TestCase
             'password' => 'pass',
             'port' => 3440,
             'flags' => [1 => true, 2 => false],
-            'encoding' => 'a-language',
+            'encoding' => 'some-encoding',
             'timezone' => 'Antarctica',
             'init' => [
                 'Execute this',
@@ -104,10 +104,10 @@ class MysqlTest extends TestCase
             ->setMethods(['_connect', 'connection'])
             ->setConstructorArgs([$config])
             ->getMock();
-        $dsn = 'mysql:host=foo;port=3440;dbname=bar;charset=a-language';
+        $dsn = 'mysql:host=foo;port=3440;dbname=bar;charset=some-encoding';
         $expected = $config;
         $expected['init'][] = "SET time_zone = 'Antarctica'";
-        $expected['init'][] = 'SET NAMES a-language';
+        $expected['init'][] = 'SET NAMES some-encoding';
         $expected['flags'] += [
             PDO::ATTR_PERSISTENT => false,
             PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
@@ -120,7 +120,7 @@ class MysqlTest extends TestCase
         $connection->expects($this->at(0))->method('exec')->with('Execute this');
         $connection->expects($this->at(1))->method('exec')->with('this too');
         $connection->expects($this->at(2))->method('exec')->with("SET time_zone = 'Antarctica'");
-        $connection->expects($this->at(3))->method('exec')->with('SET NAMES a-language');
+        $connection->expects($this->at(3))->method('exec')->with('SET NAMES some-encoding');
         $connection->expects($this->exactly(4))->method('exec');
 
         $driver->expects($this->once())->method('_connect')