Database: Set MySQL connection collation.

Fixes #36649.


git-svn-id: https://develop.svn.wordpress.org/trunk@37320 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Eric Andrew Lewis
2016-04-28 01:38:31 +00:00
parent 8692cdbecd
commit 878343d4d1
2 changed files with 24 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ class Tests_DB_Charset extends WP_UnitTestCase {
public static function setUpBeforeClass() {
require_once( dirname( dirname( __FILE__ ) ) . '/db.php' );
self::$_wpdb = new wpdb_exposed_methods_for_testing();
}
@@ -891,4 +891,19 @@ class Tests_DB_Charset extends WP_UnitTestCase {
$this->assertEquals( $safe_query, $stripped_query );
}
/**
* @ticket 36649
*/
function test_set_charset_changes_the_connection_collation() {
self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' );
$results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" );
$this->assertEquals( 'utf8_general_ci', $results[0]->Value );
self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8mb4', 'utf8mb4_unicode_ci' );
$results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" );
$this->assertEquals( 'utf8mb4_unicode_ci', $results[0]->Value );
self::$_wpdb->set_charset( self::$_wpdb->dbh );
}
}