Make WordPress Core

Ticket #18007: 18007.unit-test.2.patch

File 18007.unit-test.2.patch, 2.0 KB (added by SergeyBiryukov, 12 years ago)

More accurate check for mbstring.func_overload

  • mbstring.xml

     
     1<phpunit
     2        bootstrap="bootstrap.php"
     3        backupGlobals="false"
     4        colors="true"
     5        >
     6    <testsuites>
     7        <testsuite>
     8            <directory suffix=".php">tests/mbstring</directory>
     9        </testsuite>
     10    </testsuites>
     11</phpunit>
  • phpunit.xml

     
    1414    <groups>
    1515        <exclude>
    1616            <group>ajax</group>
     17            <group>mbstring</group>
    1718        </exclude>
    1819    </groups>
    1920    <logging>
  • tests/mbstring/serialize.php

     
     1<?php
     2
     3/**
     4 * @group mbstring
     5 */
     6class 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}