| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * @group mbstring |
| | 5 | */ |
| | 6 | class Tests_Mbstring_Serialize extends WP_UnitTestCase { |
| | 7 | |
| | 8 | /** |
| | 9 | * @ticket 18007 |
| | 10 | */ |
| | 11 | public function test_is_serialized() { |
| | 12 | /** |
| | 13 | * Context |
| | 14 | * |
| | 15 | * utf-8 encoded database fields |
| | 16 | * auto overloading singlebyte functions from conf (see http://www.php.net/manual/en/mbstring.overload.php) |
| | 17 | */ |
| | 18 | |
| | 19 | if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) == 0 ) { |
| | 20 | $this->markTestIncomplete( 'Please run as php -d mbstring.func_overload=2 /usr/bin/phpunit -c mbstring.xml'); |
| | 21 | } |
| | 22 | |
| | 23 | /** |
| | 24 | * Bug scenario |
| | 25 | * |
| | 26 | * the strlen call is actually a mb_strlen one |
| | 27 | * the $length var is the number of characters (not bytes) |
| | 28 | * using $data[$length-1] doesn't retrieve the last char but one before, its actual position is undefined, depending on the other content of the string |
| | 29 | * thus $lastc is not ; or } |
| | 30 | * the string is understood as not serialized |
| | 31 | */ |
| | 32 | |
| | 33 | $data = serialize( 'aéùp' ); |
| | 34 | |
| | 35 | $this->assertTrue( is_serialized( $data ) ); |
| | 36 | } |
| | 37 | } |