Make WordPress Core

Changeset 30533


Ignore:
Timestamp:
11/23/2014 11:51:13 PM (12 years ago)
Author:
pento
Message:

Split the tests for wp_json_encode() into smaller chunks (let's all them "units"). Skip a couple of these tests when running on older versions of PHP that don't support the tested functionality.

See #28786.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r30520 r30533  
    531531        function test_wp_json_encode() {
    532532                $this->assertEquals( wp_json_encode( 'a' ), '"a"' );
     533        }
     534
     535        /**
     536         * @ticket 28786
     537         */
     538        function test_wp_json_encode_utf8() {
    533539                $this->assertEquals( wp_json_encode( '这' ), '"\u8fd9"' );
     540        }
     541
     542        /**
     543         * @ticket 28786
     544         */
     545        function test_wp_json_encode_non_utf8() {
     546                if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
     547                        $this->markTestSkipped( 'EUC-JP character set added in PHP 5.4' );
     548                };
    534549
    535550                $old_charsets = $charsets = mb_detect_order();
     
    546561                $this->assertEquals( wp_json_encode( $eucjp ), '"a\u3042b"' );
    547562
     563                mb_detect_order( $old_charsets );
     564        }
     565
     566        /**
     567         * @ticket 28786
     568         */
     569        function test_wp_json_encode_array() {
    548570                $this->assertEquals( wp_json_encode( array( 'a' ) ), '["a"]' );
    549 
     571        }
     572
     573        /**
     574         * @ticket 28786
     575         */
     576        function test_wp_json_encode_object() {
    550577                $object = new stdClass;
    551578                $object->a = 'b';
    552579                $this->assertEquals( wp_json_encode( $object ), '{"a":"b"}' );
    553 
    554                 mb_detect_order( $old_charsets );
    555580        }
    556581
     
    559584         */
    560585        function test_wp_json_encode_depth() {
     586                if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
     587                        $this->markTestSkipped( 'json_encode() supports the $depth parameter in PHP 5.5+' );
     588                };
     589
    561590                $data = array( array( array( 1, 2, 3 ) ) );
    562591                $json = wp_json_encode( $data, 0, 1 );
Note: See TracChangeset for help on using the changeset viewer.