Make WordPress Core


Ignore:
Timestamp:
04/28/2016 01:38:31 AM (6 years ago)
Author:
ericlewis
Message:

Database: Set MySQL connection collation.

Fixes #36649.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db/charset.php

    r36116 r37320  
    1717    public static function setUpBeforeClass() {
    1818        require_once( dirname( dirname( __FILE__ ) ) . '/db.php' );
    19        
     19
    2020        self::$_wpdb = new wpdb_exposed_methods_for_testing();
    2121    }
     
    892892        $this->assertEquals( $safe_query, $stripped_query );
    893893    }
     894
     895    /**
     896     * @ticket 36649
     897     */
     898    function test_set_charset_changes_the_connection_collation() {
     899        self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' );
     900        $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" );
     901        $this->assertEquals( 'utf8_general_ci', $results[0]->Value );
     902
     903        self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8mb4', 'utf8mb4_unicode_ci' );
     904        $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" );
     905        $this->assertEquals( 'utf8mb4_unicode_ci', $results[0]->Value );
     906
     907        self::$_wpdb->set_charset( self::$_wpdb->dbh );
     908    }
    894909}
Note: See TracChangeset for help on using the changeset viewer.