WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using assertSame() should generally be preferred to assertEquals() where appropriate, to make the tests more reliable.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php

    r48402 r48937  
    268268        $response = rest_get_server()->dispatch( $request );
    269269
    270         $this->assertEquals( 200, $response->get_status() );
     270        $this->assertSame( 200, $response->get_status() );
    271271
    272272        $data = $response->get_data();
     
    275275        $meta = (array) $data['meta'];
    276276        $this->assertArrayHasKey( 'test_single', $meta );
    277         $this->assertEquals( 'testvalue', $meta['test_single'] );
     277        $this->assertSame( 'testvalue', $meta['test_single'] );
    278278    }
    279279
     
    286286
    287287        $response = rest_get_server()->dispatch( $request );
    288         $this->assertEquals( 200, $response->get_status() );
     288        $this->assertSame( 200, $response->get_status() );
    289289
    290290        $data = $response->get_data();
     
    298298
    299299        $response = rest_get_server()->dispatch( $request );
    300         $this->assertEquals( 200, $response->get_status() );
     300        $this->assertSame( 200, $response->get_status() );
    301301        $data = $response->get_data();
    302302        $meta = (array) $data['meta'];
     
    313313
    314314        $response = rest_get_server()->dispatch( $request );
    315         $this->assertEquals( 200, $response->get_status() );
     315        $this->assertSame( 200, $response->get_status() );
    316316
    317317        $data = $response->get_data();
     
    328328
    329329        $response = rest_get_server()->dispatch( $request );
    330         $this->assertEquals( 200, $response->get_status() );
     330        $this->assertSame( 200, $response->get_status() );
    331331
    332332        $data = $response->get_data();
     
    343343
    344344        $response = rest_get_server()->dispatch( $request );
    345         $this->assertEquals( 200, $response->get_status() );
     345        $this->assertSame( 200, $response->get_status() );
    346346
    347347        $data = $response->get_data();
     
    390390        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
    391391        $response = rest_get_server()->dispatch( $request );
    392         $this->assertEquals( 200, $response->get_status() );
     392        $this->assertSame( 200, $response->get_status() );
    393393
    394394        $data = $response->get_data();
     
    405405        $this->assertArrayHasKey( 'test_bool', $meta );
    406406        $this->assertInternalType( 'boolean', $meta['test_bool'] );
    407         $this->assertSame( true, $meta['test_bool'] );
     407        $this->assertTrue( $meta['test_bool'] );
    408408    }
    409409
     
    414414        $response = rest_get_server()->dispatch( $request );
    415415
    416         $this->assertEquals( 200, $response->get_status() );
     416        $this->assertSame( 200, $response->get_status() );
    417417
    418418        $data = $response->get_data();
     
    421421        $meta = (array) $data['meta'];
    422422        $this->assertArrayHasKey( 'new_name', $meta );
    423         $this->assertEquals( 'janet', $meta['new_name'] );
     423        $this->assertSame( 'janet', $meta['new_name'] );
    424424    }
    425425
     
    443443
    444444        $response = rest_get_server()->dispatch( $request );
    445         $this->assertEquals( 200, $response->get_status() );
     445        $this->assertSame( 200, $response->get_status() );
    446446
    447447        $meta = get_post_meta( self::$post_id, 'test_single', false );
    448448        $this->assertNotEmpty( $meta );
    449449        $this->assertCount( 1, $meta );
    450         $this->assertEquals( 'test_value', $meta[0] );
     450        $this->assertSame( 'test_value', $meta[0] );
    451451
    452452        $data = $response->get_data();
    453453        $meta = (array) $data['meta'];
    454454        $this->assertArrayHasKey( 'test_single', $meta );
    455         $this->assertEquals( 'test_value', $meta['test_single'] );
     455        $this->assertSame( 'test_value', $meta['test_single'] );
    456456    }
    457457
     
    462462        // Start with an existing metakey and value.
    463463        $values = update_post_meta( self::$post_id, 'test_single', 'test_value' );
    464         $this->assertEquals( 'test_value', get_post_meta( self::$post_id, 'test_single', true ) );
     464        $this->assertSame( 'test_value', get_post_meta( self::$post_id, 'test_single', true ) );
    465465
    466466        $this->grant_write_permission();
     
    475475
    476476        $response = rest_get_server()->dispatch( $request );
    477         $this->assertEquals( 200, $response->get_status() );
     477        $this->assertSame( 200, $response->get_status() );
    478478
    479479        $meta = get_post_meta( self::$post_id, 'test_single', true );
    480480        $this->assertNotEmpty( $meta );
    481         $this->assertEquals( 'test_value', $meta );
     481        $this->assertSame( 'test_value', $meta );
    482482
    483483        $data = $response->get_data();
    484484        $meta = (array) $data['meta'];
    485485        $this->assertArrayHasKey( 'test_single', $meta );
    486         $this->assertEquals( 'test_value', $meta['test_single'] );
     486        $this->assertSame( 'test_value', $meta['test_single'] );
    487487    }
    488488
     
    593593
    594594        $response = rest_get_server()->dispatch( $request );
    595         $this->assertEquals( 200, $response->get_status() );
     595        $this->assertSame( 200, $response->get_status() );
    596596
    597597        $meta = get_post_meta( self::$post_id, 'test_multi', false );
    598598        $this->assertNotEmpty( $meta );
    599599        $this->assertCount( 1, $meta );
    600         $this->assertEquals( 'val1', $meta[0] );
     600        $this->assertSame( 'val1', $meta[0] );
    601601
    602602        // Add another value.
     
    609609
    610610        $response = rest_get_server()->dispatch( $request );
    611         $this->assertEquals( 200, $response->get_status() );
     611        $this->assertSame( 200, $response->get_status() );
    612612
    613613        $meta = get_post_meta( self::$post_id, 'test_multi', false );
     
    637637
    638638        $response = rest_get_server()->dispatch( $request );
    639         $this->assertEquals( 200, $response->get_status() );
     639        $this->assertSame( 200, $response->get_status() );
    640640
    641641        $meta = get_post_meta( self::$post_id, 'test_multi', false );
     
    744744        $response = rest_get_server()->dispatch( $request );
    745745        $data     = $response->get_data();
    746         $this->assertEquals( 1, $data['meta']['my_meta_key'] );
     746        $this->assertSame( 1, $data['meta']['my_meta_key'] );
    747747    }
    748748
     
    770770        $response = rest_get_server()->dispatch( $request );
    771771        $data     = $response->get_data();
    772         $this->assertEquals( array( 1, 2, 3 ), $data['meta']['my_meta_key'] );
     772        $this->assertSame( array( 1, 2, 3 ), $data['meta']['my_meta_key'] );
    773773    }
    774774
     
    842842
    843843        $response = rest_get_server()->dispatch( $request );
    844         $this->assertEquals( 200, $response->get_status() );
     844        $this->assertSame( 200, $response->get_status() );
    845845
    846846        $meta = get_post_meta( self::$post_id, 'test_custom_schema', false );
     
    871871
    872872        $response = rest_get_server()->dispatch( $request );
    873         $this->assertEquals( 200, $response->get_status() );
     873        $this->assertSame( 200, $response->get_status() );
    874874
    875875        $meta = get_post_meta( self::$post_id, 'test_custom_schema_multi', false );
     
    887887
    888888        $response = rest_get_server()->dispatch( $request );
    889         $this->assertEquals( 200, $response->get_status() );
     889        $this->assertSame( 200, $response->get_status() );
    890890
    891891        $meta = get_post_meta( self::$post_id, 'test_custom_schema_multi', false );
     
    915915
    916916        $response = rest_get_server()->dispatch( $request );
    917         $this->assertEquals( 200, $response->get_status() );
     917        $this->assertSame( 200, $response->get_status() );
    918918
    919919        $meta = get_post_meta( self::$post_id, 'test_custom_name', false );
    920920        $this->assertNotEmpty( $meta );
    921921        $this->assertCount( 1, $meta );
    922         $this->assertEquals( 'janet', $meta[0] );
     922        $this->assertSame( 'janet', $meta[0] );
    923923
    924924        $data = $response->get_data();
    925925        $meta = (array) $data['meta'];
    926926        $this->assertArrayHasKey( 'new_name', $meta );
    927         $this->assertEquals( 'janet', $meta['new_name'] );
     927        $this->assertSame( 'janet', $meta['new_name'] );
    928928    }
    929929
     
    944944
    945945        $response = rest_get_server()->dispatch( $request );
    946         $this->assertEquals( 200, $response->get_status() );
     946        $this->assertSame( 200, $response->get_status() );
    947947
    948948        $meta = get_post_meta( self::$post_id, 'test_custom_name_multi', false );
    949949        $this->assertNotEmpty( $meta );
    950950        $this->assertCount( 1, $meta );
    951         $this->assertEquals( 'janet', $meta[0] );
     951        $this->assertSame( 'janet', $meta[0] );
    952952
    953953        // Add another value.
     
    960960
    961961        $response = rest_get_server()->dispatch( $request );
    962         $this->assertEquals( 200, $response->get_status() );
     962        $this->assertSame( 200, $response->get_status() );
    963963
    964964        $meta = get_post_meta( self::$post_id, 'test_custom_name_multi', false );
     
    992992        // The meta value should not have changed.
    993993        $current_value = get_post_meta( self::$post_id, 'test_single', true );
    994         $this->assertEquals( 'So I tied an onion to my belt, which was the style at the time.', $current_value );
     994        $this->assertSame( 'So I tied an onion to my belt, which was the style at the time.', $current_value );
    995995
    996996        // Ensure the post title update was not processed.
    997997        $post_updated = get_post( self::$post_id );
    998         $this->assertEquals( $post_original->post_title, $post_updated->post_title );
     998        $this->assertSame( $post_original->post_title, $post_updated->post_title );
    999999    }
    10001000
     
    10211021        // The meta value should not have changed.
    10221022        $current_value = get_post_meta( self::$post_id, 'test_single', true );
    1023         $this->assertEquals( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value );
     1023        $this->assertSame( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value );
    10241024
    10251025        // Ensure the post content update was not processed.
    10261026        $post_updated = get_post( self::$post_id );
    1027         $this->assertEquals( $post_original->post_content, $post_updated->post_content );
     1027        $this->assertSame( $post_original->post_content, $post_updated->post_content );
    10281028    }
    10291029
     
    10311031        add_post_meta( self::$post_id, 'test_multi', 'val1' );
    10321032        $values = get_post_meta( self::$post_id, 'test_multi', false );
    1033         $this->assertEquals( array( 'val1' ), $values );
     1033        $this->assertSame( array( 'val1' ), $values );
    10341034
    10351035        $this->grant_write_permission();
     
    10621062        add_post_meta( self::$post_id, 'test_single', 'val1' );
    10631063        $current = get_post_meta( self::$post_id, 'test_single', true );
    1064         $this->assertEquals( 'val1', $current );
     1064        $this->assertSame( 'val1', $current );
    10651065
    10661066        $this->grant_write_permission();
     
    10751075
    10761076        $response = rest_get_server()->dispatch( $request );
    1077         $this->assertEquals( 200, $response->get_status() );
     1077        $this->assertSame( 200, $response->get_status() );
    10781078
    10791079        $meta = get_post_meta( self::$post_id, 'test_single', false );
     
    10871087        add_post_meta( self::$post_id, 'test_bad_auth', 'val1' );
    10881088        $current = get_post_meta( self::$post_id, 'test_bad_auth', true );
    1089         $this->assertEquals( 'val1', $current );
     1089        $this->assertSame( 'val1', $current );
    10901090
    10911091        $this->grant_write_permission();
     
    11031103
    11041104        $meta = get_post_meta( self::$post_id, 'test_bad_auth', true );
    1105         $this->assertEquals( 'val1', $meta );
     1105        $this->assertSame( 'val1', $meta );
    11061106    }
    11071107
     
    11121112        add_post_meta( self::$post_id, 'test_single', 'val1' );
    11131113        $current = get_post_meta( self::$post_id, 'test_single', true );
    1114         $this->assertEquals( 'val1', $current );
     1114        $this->assertSame( 'val1', $current );
    11151115
    11161116        $this->grant_write_permission();
     
    11411141        add_post_meta( self::$post_id, 'test_custom_name', 'janet' );
    11421142        $current = get_post_meta( self::$post_id, 'test_custom_name', true );
    1143         $this->assertEquals( 'janet', $current );
     1143        $this->assertSame( 'janet', $current );
    11441144
    11451145        $this->grant_write_permission();
     
    11541154
    11551155        $response = rest_get_server()->dispatch( $request );
    1156         $this->assertEquals( 200, $response->get_status() );
     1156        $this->assertSame( 200, $response->get_status() );
    11571157
    11581158        $meta = get_post_meta( self::$post_id, 'test_custom_name', false );
     
    11711171
    11721172        $this->assertArrayHasKey( 'test_single', $meta_schema );
    1173         $this->assertEquals( 'string', $meta_schema['test_single']['type'] );
     1173        $this->assertSame( 'string', $meta_schema['test_single']['type'] );
    11741174
    11751175        $this->assertArrayHasKey( 'test_multi', $meta_schema );
    1176         $this->assertEquals( 'array', $meta_schema['test_multi']['type'] );
     1176        $this->assertSame( 'array', $meta_schema['test_multi']['type'] );
    11771177        $this->assertArrayHasKey( 'items', $meta_schema['test_multi'] );
    1178         $this->assertEquals( 'string', $meta_schema['test_multi']['items']['type'] );
     1178        $this->assertSame( 'string', $meta_schema['test_multi']['items']['type'] );
    11791179
    11801180        $this->assertArrayHasKey( 'test_custom_schema', $meta_schema );
    1181         $this->assertEquals( 'number', $meta_schema['test_custom_schema']['type'] );
     1181        $this->assertSame( 'number', $meta_schema['test_custom_schema']['type'] );
    11821182
    11831183        $this->assertArrayNotHasKey( 'test_no_rest', $meta_schema );
     
    12071207        $response = rest_get_server()->dispatch( $request );
    12081208
    1209         $this->assertEquals( 200, $response->get_status() );
     1209        $this->assertSame( 200, $response->get_status() );
    12101210
    12111211        $data = $response->get_data();
     
    12211221
    12221222            $this->assertArrayHasKey( $meta_key, $data['meta'] );
    1223             $this->assertEquals( $expected_value, $data['meta'][ $meta_key ] );
     1223            $this->assertSame( $expected_value, $data['meta'][ $meta_key ] );
    12241224        } else {
    12251225            $this->assertArrayNotHasKey( $meta_key, $data['meta'] );
     
    12681268        $response = rest_get_server()->dispatch( $request );
    12691269        if ( ! $can_write ) {
    1270             $this->assertEquals( 403, $response->get_status() );
     1270            $this->assertSame( 403, $response->get_status() );
    12711271            $this->assertEmpty( get_post_meta( $post_id, $meta_key, $single ) );
    12721272
     
    12741274        }
    12751275
    1276         $this->assertEquals( 200, $response->get_status() );
     1276        $this->assertSame( 200, $response->get_status() );
    12771277
    12781278        $data = $response->get_data();
     
    12861286            }
    12871287
    1288             $this->assertEquals( $expected_value, get_post_meta( $post_id, $meta_key, $single ) );
     1288            $this->assertSame( $expected_value, get_post_meta( $post_id, $meta_key, $single ) );
    12891289            $this->assertArrayHasKey( $meta_key, $data['meta'] );
    1290             $this->assertEquals( $expected_value, $data['meta'][ $meta_key ] );
     1290            $this->assertSame( $expected_value, $data['meta'][ $meta_key ] );
    12911291        } else {
    12921292            $this->assertEmpty( get_post_meta( $post_id, $meta_key, $single ) );
     
    13331333        $response = rest_get_server()->dispatch( $request );
    13341334
    1335         $this->assertEquals( 200, $response->get_status() );
     1335        $this->assertSame( 200, $response->get_status() );
    13361336    }
    13371337
     
    13601360
    13611361        $this->assertArrayHasKey( 'test\'slashed\'key', $data['meta'] );
    1362         $this->assertEquals( 'Hello', $data['meta']['test\'slashed\'key'] );
     1362        $this->assertSame( 'Hello', $data['meta']['test\'slashed\'key'] );
    13631363    }
    13641364
     
    14041404        $this->assertArrayHasKey( 'object', $data['meta'] );
    14051405        $this->assertArrayHasKey( 'project', $data['meta']['object'] );
    1406         $this->assertEquals( 'WordPress', $data['meta']['object']['project'] );
     1406        $this->assertSame( 'WordPress', $data['meta']['object']['project'] );
    14071407
    14081408        $meta = get_post_meta( self::$post_id, 'object', true );
    14091409        $this->assertArrayHasKey( 'project', $meta );
    1410         $this->assertEquals( 'WordPress', $meta['project'] );
     1410        $this->assertSame( 'WordPress', $meta['project'] );
    14111411    }
    14121412
     
    14591459
    14601460        $this->assertArrayHasKey( 'project', $data['meta']['object'][0] );
    1461         $this->assertEquals( 'WordPress', $data['meta']['object'][0]['project'] );
     1461        $this->assertSame( 'WordPress', $data['meta']['object'][0]['project'] );
    14621462
    14631463        $this->assertArrayHasKey( 'project', $data['meta']['object'][1] );
    1464         $this->assertEquals( 'bbPress', $data['meta']['object'][1]['project'] );
     1464        $this->assertSame( 'bbPress', $data['meta']['object'][1]['project'] );
    14651465
    14661466        $meta = get_post_meta( self::$post_id, 'object' );
     
    14691469
    14701470        $this->assertArrayHasKey( 'project', $meta[0] );
    1471         $this->assertEquals( 'WordPress', $meta[0]['project'] );
     1471        $this->assertSame( 'WordPress', $meta[0]['project'] );
    14721472
    14731473        $this->assertArrayHasKey( 'project', $meta[1] );
    1474         $this->assertEquals( 'bbPress', $meta[1]['project'] );
     1474        $this->assertSame( 'bbPress', $meta[1]['project'] );
    14751475    }
    14761476
     
    15111511
    15121512        $this->assertArrayHasKey( 'list', $data['meta'] );
    1513         $this->assertEquals( array( 'WordPress', 'bbPress' ), $data['meta']['list'] );
     1513        $this->assertSame( array( 'WordPress', 'bbPress' ), $data['meta']['list'] );
    15141514
    15151515        $meta = get_post_meta( self::$post_id, 'list', true );
    1516         $this->assertEquals( array( 'WordPress', 'bbPress' ), $meta );
     1516        $this->assertSame( array( 'WordPress', 'bbPress' ), $meta );
    15171517    }
    15181518
     
    15821582        $this->assertCount( 2, $data['meta']['list_of_objects'] );
    15831583
    1584         $this->assertEquals(
     1584        $this->assertSame(
    15851585            array(
    15861586                array(
     
    15961596        );
    15971597
    1598         $this->assertEquals(
     1598        $this->assertSame(
    15991599            array(
    16001600                array(
     
    16101610        $this->assertCount( 2, $meta );
    16111611
    1612         $this->assertEquals(
     1612        $this->assertSame(
    16131613            array(
    16141614                array(
     
    16241624        );
    16251625
    1626         $this->assertEquals(
     1626        $this->assertSame(
    16271627            array(
    16281628                array(
     
    17041704        $this->assertArrayHasKey( 'object', $data['meta'] );
    17051705        $this->assertCount( 2, $data['meta']['object'] );
    1706         $this->assertEquals( array( 'project' => 'bbPress' ), $data['meta']['object'][0] );
     1706        $this->assertSame( array( 'project' => 'bbPress' ), $data['meta']['object'][0] );
    17071707        $this->assertNull( $data['meta']['object'][1] );
    17081708    }
     
    17401740
    17411741        $this->assertArrayHasKey( 'object', $data['meta'] );
    1742         $this->assertEquals( array( 'project' => 'WordPress' ), $data['meta']['object'] );
     1742        $this->assertSame( array( 'project' => 'WordPress' ), $data['meta']['object'] );
    17431743    }
    17441744
     
    17821782
    17831783        $response = rest_get_server()->dispatch( $request );
    1784         $this->assertEquals( 500, $response->get_status() );
     1784        $this->assertSame( 500, $response->get_status() );
    17851785    }
    17861786
     
    18281828
    18291829        $response = rest_get_server()->dispatch( $request );
    1830         $this->assertEquals( 500, $response->get_status() );
     1830        $this->assertSame( 500, $response->get_status() );
    18311831    }
    18321832
     
    18691869
    18701870        $response = rest_get_server()->dispatch( $request );
    1871         $this->assertEquals( 400, $response->get_status() );
     1871        $this->assertSame( 400, $response->get_status() );
    18721872    }
    18731873
     
    19131913
    19141914        $response = rest_get_server()->dispatch( $request );
    1915         $this->assertEquals( 200, $response->get_status() );
    1916         $this->assertEquals( $value, $response->get_data()['meta']['object'] );
    1917 
    1918         $this->assertEquals( $value, get_post_meta( self::$post_id, 'object', true ) );
     1915        $this->assertSame( 200, $response->get_status() );
     1916        $this->assertSame( $value, $response->get_data()['meta']['object'] );
     1917
     1918        $this->assertSame( $value, get_post_meta( self::$post_id, 'object', true ) );
    19191919    }
    19201920
     
    19621962
    19631963        $response = rest_get_server()->dispatch( $request );
    1964         $this->assertEquals( 400, $response->get_status() );
     1964        $this->assertSame( 400, $response->get_status() );
    19651965    }
    19661966
     
    20892089
    20902090        $response = rest_get_server()->dispatch( $request );
    2091         $this->assertEquals( 200, $response->get_status() );
     2091        $this->assertSame( 200, $response->get_status() );
    20922092
    20932093        $data = $response->get_data();
     
    20952095
    20962096        $this->assertCount( 2, $data['meta']['object'] );
    2097         $this->assertEquals( array( 'project' => 'WordPress' ), $data['meta']['object'][0] );
    2098         $this->assertEquals( array( 'project' => 'BuddyPress' ), $data['meta']['object'][1] );
     2097        $this->assertSame( array( 'project' => 'WordPress' ), $data['meta']['object'][0] );
     2098        $this->assertSame( array( 'project' => 'BuddyPress' ), $data['meta']['object'][1] );
    20992099
    21002100        $meta = get_post_meta( self::$post_id, 'object' );
    21012101        $this->assertCount( 2, $meta );
    2102         $this->assertEquals( array( 'project' => 'WordPress' ), $meta[0] );
    2103         $this->assertEquals( array( 'project' => 'BuddyPress' ), $meta[1] );
     2102        $this->assertSame( array( 'project' => 'WordPress' ), $meta[0] );
     2103        $this->assertSame( array( 'project' => 'BuddyPress' ), $meta[1] );
    21042104    }
    21052105
     
    21422142
    21432143        $response = rest_get_server()->dispatch( $request );
    2144         $this->assertEquals( 200, $response->get_status() );
     2144        $this->assertSame( 200, $response->get_status() );
    21452145
    21462146        $data = $response->get_data();
     
    21482148
    21492149        $this->assertCount( 2, $data['meta']['list'] );
    2150         $this->assertEquals( array( 'WordPress', 'bbPress' ), $data['meta']['list'][0] );
    2151         $this->assertEquals( array( 'BuddyPress' ), $data['meta']['list'][1] );
     2150        $this->assertSame( array( 'WordPress', 'bbPress' ), $data['meta']['list'][0] );
     2151        $this->assertSame( array( 'BuddyPress' ), $data['meta']['list'][1] );
    21522152
    21532153        $meta = get_post_meta( self::$post_id, 'list' );
    21542154        $this->assertCount( 2, $meta );
    2155         $this->assertEquals( array( 'WordPress', 'bbPress' ), $meta[0] );
    2156         $this->assertEquals( array( 'BuddyPress' ), $meta[1] );
     2155        $this->assertSame( array( 'WordPress', 'bbPress' ), $meta[0] );
     2156        $this->assertSame( array( 'BuddyPress' ), $meta[1] );
    21572157    }
    21582158
     
    21922192
    21932193        $response = rest_get_server()->dispatch( $request );
    2194         $this->assertEquals( 200, $response->get_status() );
     2194        $this->assertSame( 200, $response->get_status() );
    21952195
    21962196        $data = $response->get_data();
    2197         $this->assertEquals( array( 'WordCamp' ), $data['meta']['list'] );
     2197        $this->assertSame( array( 'WordCamp' ), $data['meta']['list'] );
    21982198    }
    21992199
     
    22352235
    22362236        $response = rest_get_server()->dispatch( $request );
    2237         $this->assertEquals( 200, $response->get_status() );
     2237        $this->assertSame( 200, $response->get_status() );
    22382238
    22392239        $data = $response->get_data();
    2240         $this->assertEquals( array( 'project' => 'WordCamp' ), $data['meta']['object'] );
     2240        $this->assertSame( array( 'project' => 'WordCamp' ), $data['meta']['object'] );
    22412241    }
    22422242
     
    23332333        rest_get_server()->dispatch( $request );
    23342334        $response = rest_get_server()->dispatch( $request );
    2335         $this->assertEquals( 200, $response->get_status() );
     2335        $this->assertSame( 200, $response->get_status() );
    23362336    }
    23372337
     
    23592359        update_post_meta( self::$post_id, 'items', array( '1', '2', '3' ) );
    23602360        $response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ) );
    2361         $this->assertEquals( array( 1, 2, 3 ), $response->get_data()['meta']['items'] );
     2361        $this->assertSame( array( 1, 2, 3 ), $response->get_data()['meta']['items'] );
    23622362
    23632363        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     
    23712371
    23722372        $response = rest_get_server()->dispatch( $request );
    2373         $this->assertEquals( 200, $response->get_status() );
     2373        $this->assertSame( 200, $response->get_status() );
    23742374        $this->assertSame( array( 1, 2, 3 ), get_post_meta( self::$post_id, 'items', true ) );
    23752375    }
     
    24082408
    24092409        $response = rest_get_server()->dispatch( $request );
    2410         $this->assertEquals( 200, $response->get_status() );
     2410        $this->assertSame( 200, $response->get_status() );
    24112411        $this->assertSame( array( 1, 2, 3 ), get_post_meta( self::$post_id, 'items', true ) );
    24122412    }
     
    24452445
    24462446        $response = rest_get_server()->dispatch( $request );
    2447         $this->assertEquals( 200, $response->get_status() );
     2447        $this->assertSame( 200, $response->get_status() );
    24482448        $this->assertSame( array( 1, 2, 3 ), get_post_meta( self::$post_id, 'items', true ) );
    24492449    }
     
    24812481        rest_get_server()->dispatch( $request );
    24822482        $response = rest_get_server()->dispatch( $request );
    2483         $this->assertEquals( 200, $response->get_status() );
     2483        $this->assertSame( 200, $response->get_status() );
    24842484    }
    24852485
     
    25082508
    25092509        $response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ) );
    2510         $this->assertEquals( array( true, false ), $response->get_data()['meta']['items'] );
     2510        $this->assertSame( array( true, false ), $response->get_data()['meta']['items'] );
    25112511
    25122512        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     
    25202520
    25212521        $response = rest_get_server()->dispatch( $request );
    2522         $this->assertEquals( 200, $response->get_status() );
     2522        $this->assertSame( 200, $response->get_status() );
    25232523        $this->assertSame( array( true, false ), get_post_meta( self::$post_id, 'items', true ) );
    25242524    }
     
    25572557
    25582558        $response = rest_get_server()->dispatch( $request );
    2559         $this->assertEquals( 200, $response->get_status() );
     2559        $this->assertSame( 200, $response->get_status() );
    25602560        $this->assertSame( array( true, false ), get_post_meta( self::$post_id, 'items', true ) );
    25612561    }
     
    25942594
    25952595        $response = rest_get_server()->dispatch( $request );
    2596         $this->assertEquals( 200, $response->get_status() );
     2596        $this->assertSame( 200, $response->get_status() );
    25972597        $this->assertSame( array( true, false ), get_post_meta( self::$post_id, 'items', true ) );
    25982598    }
     
    26312631
    26322632        $response = rest_get_server()->dispatch( $request );
    2633         $this->assertEquals( 200, $response->get_status() );
     2633        $this->assertSame( 200, $response->get_status() );
    26342634        $this->assertSame( array( false, true ), get_post_meta( self::$post_id, 'items', true ) );
    26352635    }
     
    26662666
    26672667        $response = rest_get_server()->dispatch( $request );
    2668         $this->assertEquals( 200, $response->get_status() );
    2669         $this->assertEquals( '0', get_post_meta( self::$post_id, 'boolean', true ) );
     2668        $this->assertSame( 200, $response->get_status() );
     2669        $this->assertSame( '0', get_post_meta( self::$post_id, 'boolean', true ) );
    26702670    }
    26712671
     
    26992699        $response = rest_get_server()->dispatch( $request );
    27002700
    2701         $this->assertEquals( 200, $response->get_status() );
    2702         $this->assertEquals( array( 2, 3 ), $response->get_data()['meta']['multi_integer'] );
     2701        $this->assertSame( 200, $response->get_status() );
     2702        $this->assertSame( array( 2, 3 ), $response->get_data()['meta']['multi_integer'] );
    27032703
    27042704        $this->assertFalse( get_metadata_by_mid( 'post', $mid1 ) );
     
    27362736        $response = rest_get_server()->dispatch( $request );
    27372737
    2738         $this->assertEquals( 200, $response->get_status() );
     2738        $this->assertSame( 200, $response->get_status() );
    27392739        $this->assertEquals( array( 0 ), $response->get_data()['meta']['multi_boolean'] );
    27402740
     
    27842784        $response = rest_get_server()->dispatch( $request );
    27852785
    2786         $this->assertEquals( 200, $response->get_status() );
    2787         $this->assertEquals(
     2786        $this->assertSame( 200, $response->get_status() );
     2787        $this->assertSame(
    27882788            array(
    27892789                array( 'a' => 'anaconda' ),
     
    28162816        $response = rest_get_server()->dispatch( $request );
    28172817
    2818         $this->assertEquals( 200, $response->get_status() );
     2818        $this->assertSame( 200, $response->get_status() );
    28192819
    28202820        $data = $response->get_data();
     
    28232823        $meta = (array) $data['meta'];
    28242824        $this->assertArrayHasKey( $meta_key, $meta );
    2825         $this->assertEquals( $expected, $meta[ $meta_key ] );
     2825        $this->assertSame( $expected, $meta[ $meta_key ] );
    28262826    }
    28272827
     
    29822982
    29832983        $response = rest_do_request( '/wp/v2/posts/' . self::$post_id );
    2984         $this->assertEquals( 'Hello World', $response->get_data()['meta']['greeting'] );
     2984        $this->assertSame( 'Hello World', $response->get_data()['meta']['greeting'] );
    29852985    }
    29862986
     
    29942994        $schema = $response->get_data()['schema']['properties']['meta']['properties']['with_default'];
    29952995        $this->assertArrayHasKey( 'default', $schema );
    2996         $this->assertEquals( 'Goodnight Moon', $schema['default'] );
     2996        $this->assertSame( 'Goodnight Moon', $schema['default'] );
    29972997    }
    29982998
Note: See TracChangeset for help on using the changeset viewer.