Last active
August 29, 2015 14:19
-
-
Save miya0001/91c837a1d3a0b75cd233 to your computer and use it in GitHub Desktop.
MySQL UTF-8 4 Bytes character problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SampleTest extends WP_UnitTestCase { | |
/** | |
* @test | |
*/ | |
function utf8_test() | |
{ | |
global $wp_version; | |
global $wpdb; | |
$this->assertSame( '4.2', $wp_version ); | |
// post_title is sushi | |
$post_id = $this->factory->post->create( array( 'post_title' => '🍣' ) ); | |
// search by beer | |
$result = $wpdb->get_var( $wpdb->prepare( | |
"SELECT ID FROM $wpdb->posts where post_title=%s", '🍺' | |
) ); | |
// It should be null but 3 | |
$this->assertSame( NULL, $result ); // fail | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment