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-tags-controller.php

    r47122 r48937  
    136136        $response = rest_get_server()->dispatch( $request );
    137137        $data     = $response->get_data();
    138         $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
     138        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
    139139        $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    140140        // Single.
     
    143143        $response = rest_get_server()->dispatch( $request );
    144144        $data     = $response->get_data();
    145         $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
     145        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
    146146        $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    147147    }
     
    153153        $keys     = array_keys( $data['endpoints'][0]['args'] );
    154154        sort( $keys );
    155         $this->assertEquals(
     155        $this->assertSame(
    156156            array(
    157157                'context',
     
    201201        $response = rest_get_server()->dispatch( $request );
    202202        $data     = $response->get_data();
    203         $this->assertEquals( 2, count( $data ) );
    204         $this->assertEquals( 'Season 5', $data[0]['name'] );
    205         $this->assertEquals( 'The Be Sharps', $data[1]['name'] );
     203        $this->assertSame( 2, count( $data ) );
     204        $this->assertSame( 'Season 5', $data[0]['name'] );
     205        $this->assertSame( 'The Be Sharps', $data[1]['name'] );
    206206
    207207        // Invalid 'hide_empty' should error.
     
    221221        $response = rest_get_server()->dispatch( $request );
    222222        $data     = $response->get_data();
    223         $this->assertEquals( 2, count( $data ) );
    224         $this->assertEquals( $id1, $data[0]['id'] );
     223        $this->assertSame( 2, count( $data ) );
     224        $this->assertSame( $id1, $data[0]['id'] );
    225225
    226226        // 'orderby' => 'include'.
     
    228228        $response = rest_get_server()->dispatch( $request );
    229229        $data     = $response->get_data();
    230         $this->assertEquals( 2, count( $data ) );
    231         $this->assertEquals( $id2, $data[0]['id'] );
     230        $this->assertSame( 2, count( $data ) );
     231        $this->assertSame( $id2, $data[0]['id'] );
    232232
    233233        // Invalid 'include' should error.
     
    301301        $request->set_param( 'per_page', 1 );
    302302        $response = rest_get_server()->dispatch( $request );
    303         $this->assertEquals( 200, $response->get_status() );
    304         $data = $response->get_data();
    305         $this->assertEquals( 1, count( $data ) );
    306         $this->assertEquals( 'Zucchini', $data[0]['name'] );
     303        $this->assertSame( 200, $response->get_status() );
     304        $data = $response->get_data();
     305        $this->assertSame( 1, count( $data ) );
     306        $this->assertSame( 'Zucchini', $data[0]['name'] );
    307307
    308308        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
     
    311311        $request->set_param( 'per_page', 2 );
    312312        $response = rest_get_server()->dispatch( $request );
    313         $this->assertEquals( 200, $response->get_status() );
    314         $data = $response->get_data();
    315         $this->assertEquals( 2, count( $data ) );
    316         $this->assertEquals( 'Apple', $data[0]['name'] );
     313        $this->assertSame( 200, $response->get_status() );
     314        $data = $response->get_data();
     315        $this->assertSame( 2, count( $data ) );
     316        $this->assertSame( 'Apple', $data[0]['name'] );
    317317
    318318        // Invalid 'orderby' should error.
     
    330330        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    331331        $response = rest_get_server()->dispatch( $request );
    332         $this->assertEquals( 200, $response->get_status() );
    333         $data = $response->get_data();
    334         $this->assertEquals( 'Apple', $data[0]['name'] );
    335         $this->assertEquals( 'Banana', $data[1]['name'] );
    336         $this->assertEquals( 'Cantaloupe', $data[2]['name'] );
     332        $this->assertSame( 200, $response->get_status() );
     333        $data = $response->get_data();
     334        $this->assertSame( 'Apple', $data[0]['name'] );
     335        $this->assertSame( 'Banana', $data[1]['name'] );
     336        $this->assertSame( 'Cantaloupe', $data[2]['name'] );
    337337
    338338        // 'orderby' => 'id', with default 'order' => 'asc'.
     
    340340        $request->set_param( 'orderby', 'id' );
    341341        $response = rest_get_server()->dispatch( $request );
    342         $this->assertEquals( 200, $response->get_status() );
    343         $data = $response->get_data();
    344         $this->assertEquals( 'Tag 0', $data[0]['name'] );
    345         $this->assertEquals( 'Tag 1', $data[1]['name'] );
    346         $this->assertEquals( 'Tag 2', $data[2]['name'] );
     342        $this->assertSame( 200, $response->get_status() );
     343        $data = $response->get_data();
     344        $this->assertSame( 'Tag 0', $data[0]['name'] );
     345        $this->assertSame( 'Tag 1', $data[1]['name'] );
     346        $this->assertSame( 'Tag 2', $data[2]['name'] );
    347347
    348348        // 'orderby' => 'id', 'order' => 'desc'.
     
    352352        $response = rest_get_server()->dispatch( $request );
    353353        $data     = $response->get_data();
    354         $this->assertEquals( 200, $response->get_status() );
    355         $this->assertEquals( 'Banana', $data[0]['name'] );
    356         $this->assertEquals( 'Apple', $data[1]['name'] );
    357         $this->assertEquals( 'Cantaloupe', $data[2]['name'] );
     354        $this->assertSame( 200, $response->get_status() );
     355        $this->assertSame( 'Banana', $data[0]['name'] );
     356        $this->assertSame( 'Apple', $data[1]['name'] );
     357        $this->assertSame( 'Cantaloupe', $data[2]['name'] );
    358358    }
    359359
     
    368368        $response = rest_get_server()->dispatch( $request );
    369369        $data     = $response->get_data();
    370         $this->assertEquals( 200, $response->get_status() );
    371         $this->assertEquals( 'taco', $data[0]['slug'] );
    372         $this->assertEquals( 'burrito', $data[1]['slug'] );
    373         $this->assertEquals( 'chalupa', $data[2]['slug'] );
     370        $this->assertSame( 200, $response->get_status() );
     371        $this->assertSame( 'taco', $data[0]['slug'] );
     372        $this->assertSame( 'burrito', $data[1]['slug'] );
     373        $this->assertSame( 'chalupa', $data[2]['slug'] );
    374374    }
    375375
     
    385385        $request->set_param( 'post', $post_id );
    386386        $response = rest_get_server()->dispatch( $request );
    387         $this->assertEquals( 200, $response->get_status() );
    388 
    389         $data = $response->get_data();
    390         $this->assertEquals( 2, count( $data ) );
    391         $this->assertEquals( 'DC', $data[0]['name'] );
     387        $this->assertSame( 200, $response->get_status() );
     388
     389        $data = $response->get_data();
     390        $this->assertSame( 2, count( $data ) );
     391        $this->assertSame( 'DC', $data[0]['name'] );
    392392
    393393        // Invalid 'post' should error.
     
    413413        $i = 0;
    414414        foreach ( $tags as $tag ) {
    415             $this->assertEquals( $tag['name'], "Tag {$i}" );
     415            $this->assertSame( $tag['name'], "Tag {$i}" );
    416416            $i++;
    417417        }
     
    426426
    427427        foreach ( $tags as $tag ) {
    428             $this->assertEquals( $tag['name'], "Tag {$i}" );
     428            $this->assertSame( $tag['name'], "Tag {$i}" );
    429429            $i++;
    430430        }
     
    437437        $request->set_param( 'post', $post_id );
    438438        $response = rest_get_server()->dispatch( $request );
    439         $this->assertEquals( 200, $response->get_status() );
     439        $this->assertSame( 200, $response->get_status() );
    440440
    441441        $data = $response->get_data();
     
    472472        $request->set_param( 'post', $post_id );
    473473        $response = rest_get_server()->dispatch( $request );
    474         $this->assertEquals( 200, $response->get_status() );
    475 
    476         $data = $response->get_data();
    477         $this->assertEquals( 2, count( $data ) );
    478         $this->assertEquals( 'Cape', $data[0]['name'] );
     474        $this->assertSame( 200, $response->get_status() );
     475
     476        $data = $response->get_data();
     477        $this->assertSame( 2, count( $data ) );
     478        $this->assertSame( 'Cape', $data[0]['name'] );
    479479    }
    480480
     
    490490        $request->set_param( 'search', 'App' );
    491491        $response = rest_get_server()->dispatch( $request );
    492         $this->assertEquals( 200, $response->get_status() );
    493         $data = $response->get_data();
    494         $this->assertEquals( 1, count( $data ) );
    495         $this->assertEquals( 'Apple', $data[0]['name'] );
     492        $this->assertSame( 200, $response->get_status() );
     493        $data = $response->get_data();
     494        $this->assertSame( 1, count( $data ) );
     495        $this->assertSame( 'Apple', $data[0]['name'] );
    496496
    497497        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    498498        $request->set_param( 'search', 'Garbage' );
    499499        $response = rest_get_server()->dispatch( $request );
    500         $this->assertEquals( 200, $response->get_status() );
    501         $data = $response->get_data();
    502         $this->assertEquals( 0, count( $data ) );
     500        $this->assertSame( 200, $response->get_status() );
     501        $data = $response->get_data();
     502        $this->assertSame( 0, count( $data ) );
    503503    }
    504504
     
    510510        $request->set_param( 'slug', 'apple' );
    511511        $response = rest_get_server()->dispatch( $request );
    512         $this->assertEquals( 200, $response->get_status() );
    513         $data = $response->get_data();
    514         $this->assertEquals( 1, count( $data ) );
    515         $this->assertEquals( 'Apple', $data[0]['name'] );
     512        $this->assertSame( 200, $response->get_status() );
     513        $data = $response->get_data();
     514        $this->assertSame( 1, count( $data ) );
     515        $this->assertSame( 'Apple', $data[0]['name'] );
    516516    }
    517517
     
    532532        );
    533533        $response = rest_get_server()->dispatch( $request );
    534         $this->assertEquals( 200, $response->get_status() );
     534        $this->assertSame( 200, $response->get_status() );
    535535        $data  = $response->get_data();
    536536        $names = wp_list_pluck( $data, 'name' );
    537537        sort( $names );
    538         $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names );
     538        $this->assertSame( array( 'Burrito', 'Enchilada', 'Taco' ), $names );
    539539    }
    540540
     
    548548        $request->set_param( 'slug', 'taco,burrito, enchilada' );
    549549        $response = rest_get_server()->dispatch( $request );
    550         $this->assertEquals( 200, $response->get_status() );
     550        $this->assertSame( 200, $response->get_status() );
    551551        $data  = $response->get_data();
    552552        $names = wp_list_pluck( $data, 'name' );
    553553        sort( $names );
    554         $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names );
     554        $this->assertSame( array( 'Burrito', 'Enchilada', 'Taco' ), $names );
    555555    }
    556556
     
    583583        $response = rest_get_server()->dispatch( $request );
    584584        $headers  = $response->get_headers();
    585         $this->assertEquals( $total_tags, $headers['X-WP-Total'] );
    586         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     585        $this->assertSame( $total_tags, $headers['X-WP-Total'] );
     586        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    587587        $next_link = add_query_arg(
    588588            array(
     
    602602        $response = rest_get_server()->dispatch( $request );
    603603        $headers  = $response->get_headers();
    604         $this->assertEquals( $total_tags, $headers['X-WP-Total'] );
    605         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     604        $this->assertSame( $total_tags, $headers['X-WP-Total'] );
     605        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    606606        $prev_link = add_query_arg(
    607607            array(
     
    624624        $response = rest_get_server()->dispatch( $request );
    625625        $headers  = $response->get_headers();
    626         $this->assertEquals( $total_tags, $headers['X-WP-Total'] );
    627         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     626        $this->assertSame( $total_tags, $headers['X-WP-Total'] );
     627        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    628628        $prev_link = add_query_arg(
    629629            array(
     
    640640        $response = rest_get_server()->dispatch( $request );
    641641        $headers  = $response->get_headers();
    642         $this->assertEquals( $total_tags, $headers['X-WP-Total'] );
    643         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     642        $this->assertSame( $total_tags, $headers['X-WP-Total'] );
     643        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    644644        $prev_link = add_query_arg(
    645645            array(
     
    757757        $request->set_param( 'slug', 'so-awesome' );
    758758        $response = rest_get_server()->dispatch( $request );
    759         $this->assertEquals( 201, $response->get_status() );
     759        $this->assertSame( 201, $response->get_status() );
    760760        $headers = $response->get_headers();
    761761        $data    = $response->get_data();
    762762        $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] );
    763         $this->assertEquals( 'My Awesome Term', $data['name'] );
    764         $this->assertEquals( 'This term is so awesome.', $data['description'] );
    765         $this->assertEquals( 'so-awesome', $data['slug'] );
     763        $this->assertSame( 'My Awesome Term', $data['name'] );
     764        $this->assertSame( 'This term is so awesome.', $data['description'] );
     765        $this->assertSame( 'so-awesome', $data['slug'] );
    766766    }
    767767
     
    774774        $request->set_param( 'slug', 'so-awesome' );
    775775        $response = rest_get_server()->dispatch( $request );
    776         $this->assertEquals( 201, $response->get_status() );
     776        $this->assertSame( 201, $response->get_status() );
    777777        $headers = $response->get_headers();
    778778        $data    = $response->get_data();
    779779        $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] );
    780         $this->assertEquals( 'My Awesome Term', $data['name'] );
    781         $this->assertEquals( 'This term is so awesome.', $data['description'] );
    782         $this->assertEquals( 'so-awesome', $data['slug'] );
     780        $this->assertSame( 'My Awesome Term', $data['name'] );
     781        $this->assertSame( 'This term is so awesome.', $data['description'] );
     782        $this->assertSame( 'so-awesome', $data['slug'] );
    783783    }
    784784
     
    817817        $request->set_param( 'meta', array( 'test_tag_single' => 'hello' ) );
    818818        $response = rest_get_server()->dispatch( $request );
    819         $this->assertEquals( 201, $response->get_status() );
     819        $this->assertSame( 201, $response->get_status() );
    820820        $headers = $response->get_headers();
    821821        $data    = $response->get_data();
    822822        $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] );
    823         $this->assertEquals( 'My Awesome Term', $data['name'] );
    824         $this->assertEquals( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) );
     823        $this->assertSame( 'My Awesome Term', $data['name'] );
     824        $this->assertSame( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) );
    825825    }
    826826
     
    835835        $request->set_param( 'id', $existing_tag_id );
    836836        $response = rest_get_server()->dispatch( $request );
    837         $this->assertEquals( 201, $response->get_status() );
     837        $this->assertSame( 201, $response->get_status() );
    838838        $headers = $response->get_headers();
    839839        $data    = $response->get_data();
    840840        $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] );
    841         $this->assertEquals( 'My Awesome Term', $data['name'] );
    842         $this->assertEquals( '', get_term_meta( $existing_tag_id, 'test_tag_single', true ) );
    843         $this->assertEquals( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) );
     841        $this->assertSame( 'My Awesome Term', $data['name'] );
     842        $this->assertSame( '', get_term_meta( $existing_tag_id, 'test_tag_single', true ) );
     843        $this->assertSame( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) );
    844844    }
    845845
     
    868868        );
    869869        $response = rest_get_server()->dispatch( $request );
    870         $this->assertEquals( 200, $response->get_status() );
    871         $data = $response->get_data();
    872         $this->assertEquals( 'New Name', $data['name'] );
    873         $this->assertEquals( 'New Description', $data['description'] );
    874         $this->assertEquals( 'new-slug', $data['slug'] );
    875         $this->assertEquals( 'just meta', $data['meta']['test_single'] );
    876         $this->assertEquals( 'tag-specific meta', $data['meta']['test_tag_single'] );
     870        $this->assertSame( 200, $response->get_status() );
     871        $data = $response->get_data();
     872        $this->assertSame( 'New Name', $data['name'] );
     873        $this->assertSame( 'New Description', $data['description'] );
     874        $this->assertSame( 'new-slug', $data['slug'] );
     875        $this->assertSame( 'just meta', $data['meta']['test_single'] );
     876        $this->assertSame( 'tag-specific meta', $data['meta']['test_tag_single'] );
    877877        $this->assertFalse( isset( $data['meta']['test_cat_meta'] ) );
    878878    }
     
    885885        $request  = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id );
    886886        $response = rest_get_server()->dispatch( $request );
    887         $this->assertEquals( 200, $response->get_status() );
     887        $this->assertSame( 200, $response->get_status() );
    888888        $request->set_param( 'slug', $term->slug );
    889889
     
    891891        // even if no DB rows are updated.
    892892        $response = rest_get_server()->dispatch( $request );
    893         $this->assertEquals( 200, $response->get_status() );
    894 
    895         $response = rest_get_server()->dispatch( $request );
    896         $this->assertEquals( 200, $response->get_status() );
     893        $this->assertSame( 200, $response->get_status() );
     894
     895        $response = rest_get_server()->dispatch( $request );
     896        $this->assertSame( 200, $response->get_status() );
    897897    }
    898898
     
    932932        remove_filter( 'user_has_cap', array( $this, 'grant_edit_term' ), 10, 2 );
    933933
    934         $this->assertEquals( 200, $response->get_status() );
    935         $data = $response->get_data();
    936         $this->assertEquals( 'New Name', $data['name'] );
     934        $this->assertSame( 200, $response->get_status() );
     935        $data = $response->get_data();
     936        $this->assertSame( 'New Name', $data['name'] );
    937937    }
    938938
     
    987987        }
    988988        $response = rest_get_server()->dispatch( $request );
    989         $this->assertEquals( 201, $response->get_status() );
     989        $this->assertSame( 201, $response->get_status() );
    990990        $actual_output = $response->get_data();
    991991
    992992        // Compare expected API output to actual API output.
    993         $this->assertEquals( $expected_output['name'], $actual_output['name'] );
    994         $this->assertEquals( $expected_output['description'], $actual_output['description'] );
     993        $this->assertSame( $expected_output['name'], $actual_output['name'] );
     994        $this->assertSame( $expected_output['description'], $actual_output['description'] );
    995995
    996996        // Compare expected API output to WP internal values.
    997997        $tag = get_term_by( 'id', $actual_output['id'], 'post_tag' );
    998         $this->assertEquals( $expected_output['name'], $tag->name );
    999         $this->assertEquals( $expected_output['description'], $tag->description );
     998        $this->assertSame( $expected_output['name'], $tag->name );
     999        $this->assertSame( $expected_output['description'], $tag->description );
    10001000
    10011001        // Update the tag.
     
    10051005        }
    10061006        $response = rest_get_server()->dispatch( $request );
    1007         $this->assertEquals( 200, $response->get_status() );
     1007        $this->assertSame( 200, $response->get_status() );
    10081008        $actual_output = $response->get_data();
    10091009
    10101010        // Compare expected API output to actual API output.
    1011         $this->assertEquals( $expected_output['name'], $actual_output['name'] );
    1012         $this->assertEquals( $expected_output['description'], $actual_output['description'] );
     1011        $this->assertSame( $expected_output['name'], $actual_output['name'] );
     1012        $this->assertSame( $expected_output['description'], $actual_output['description'] );
    10131013
    10141014        // Compare expected API output to WP internal values.
    10151015        $tag = get_term_by( 'id', $actual_output['id'], 'post_tag' );
    1016         $this->assertEquals( $expected_output['name'], $tag->name );
    1017         $this->assertEquals( $expected_output['description'], $tag->description );
     1016        $this->assertSame( $expected_output['name'], $tag->name );
     1017        $this->assertSame( $expected_output['description'], $tag->description );
    10181018    }
    10191019
     
    10211021        wp_set_current_user( self::$editor );
    10221022
    1023         $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) );
     1023        $this->assertSame( ! is_multisite(), current_user_can( 'unfiltered_html' ) );
    10241024        $this->verify_tag_roundtrip(
    10251025            array(
     
    11041104        $request->set_param( 'force', true );
    11051105        $response = rest_get_server()->dispatch( $request );
    1106         $this->assertEquals( 200, $response->get_status() );
     1106        $this->assertSame( 200, $response->get_status() );
    11071107        $data = $response->get_data();
    11081108        $this->assertTrue( $data['deleted'] );
    1109         $this->assertEquals( 'Deleted Tag', $data['previous']['name'] );
     1109        $this->assertSame( 'Deleted Tag', $data['previous']['name'] );
    11101110    }
    11111111
     
    11571157        remove_filter( 'map_meta_cap', array( $this, 'grant_delete_term' ), 10, 2 );
    11581158
    1159         $this->assertEquals( 200, $response->get_status() );
     1159        $this->assertSame( 200, $response->get_status() );
    11601160        $data = $response->get_data();
    11611161        $this->assertTrue( $data['deleted'] );
    1162         $this->assertEquals( 'Deleted Tag', $data['previous']['name'] );
     1162        $this->assertSame( 'Deleted Tag', $data['previous']['name'] );
    11631163    }
    11641164
     
    12111211        $term     = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
    12121212        $response = $endpoint->prepare_item_for_response( $term, $request );
    1213         $this->assertEquals(
     1213        $this->assertSame(
    12141214            array(
    12151215                'id',
     
    12251225        $data       = $response->get_data();
    12261226        $properties = $data['schema']['properties'];
    1227         $this->assertEquals( 8, count( $properties ) );
     1227        $this->assertSame( 8, count( $properties ) );
    12281228        $this->assertArrayHasKey( 'id', $properties );
    12291229        $this->assertArrayHasKey( 'count', $properties );
     
    12341234        $this->assertArrayHasKey( 'slug', $properties );
    12351235        $this->assertArrayHasKey( 'taxonomy', $properties );
    1236         $this->assertEquals( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
     1236        $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
    12371237    }
    12381238
     
    12691269        $data     = $response->get_data();
    12701270        $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
    1271         $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] );
     1271        $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
    12721272
    12731273        $tag_id = $this->factory->tag->create();
     
    13771377        $create->set_param( 'name', 'My New Term' );
    13781378        $response = rest_get_server()->dispatch( $create );
    1379         $this->assertEquals( 201, $response->get_status() );
     1379        $this->assertSame( 201, $response->get_status() );
    13801380        $data = $response->get_data();
    13811381        $this->assertArrayHasKey( $edit_field, $data );
     
    13851385        $update->set_param( 'name', 'My Awesome New Term' );
    13861386        $response = rest_get_server()->dispatch( $update );
    1387         $this->assertEquals( 200, $response->get_status() );
     1387        $this->assertSame( 200, $response->get_status() );
    13881388        $data = $response->get_data();
    13891389        $this->assertArrayHasKey( $edit_field, $data );
     
    14081408
    14091409    protected function check_get_taxonomy_terms_response( $response ) {
    1410         $this->assertEquals( 200, $response->get_status() );
     1410        $this->assertSame( 200, $response->get_status() );
    14111411        $data = $response->get_data();
    14121412        $args = array(
     
    14141414        );
    14151415        $tags = get_terms( 'post_tag', $args );
    1416         $this->assertEquals( count( $tags ), count( $data ) );
    1417         $this->assertEquals( $tags[0]->term_id, $data[0]['id'] );
    1418         $this->assertEquals( $tags[0]->name, $data[0]['name'] );
    1419         $this->assertEquals( $tags[0]->slug, $data[0]['slug'] );
    1420         $this->assertEquals( $tags[0]->taxonomy, $data[0]['taxonomy'] );
    1421         $this->assertEquals( $tags[0]->description, $data[0]['description'] );
    1422         $this->assertEquals( $tags[0]->count, $data[0]['count'] );
     1416        $this->assertSame( count( $tags ), count( $data ) );
     1417        $this->assertSame( $tags[0]->term_id, $data[0]['id'] );
     1418        $this->assertSame( $tags[0]->name, $data[0]['name'] );
     1419        $this->assertSame( $tags[0]->slug, $data[0]['slug'] );
     1420        $this->assertSame( $tags[0]->taxonomy, $data[0]['taxonomy'] );
     1421        $this->assertSame( $tags[0]->description, $data[0]['description'] );
     1422        $this->assertSame( $tags[0]->count, $data[0]['count'] );
    14231423    }
    14241424
    14251425    protected function check_taxonomy_term( $term, $data, $links ) {
    1426         $this->assertEquals( $term->term_id, $data['id'] );
    1427         $this->assertEquals( $term->name, $data['name'] );
    1428         $this->assertEquals( $term->slug, $data['slug'] );
    1429         $this->assertEquals( $term->description, $data['description'] );
    1430         $this->assertEquals( get_term_link( $term ), $data['link'] );
    1431         $this->assertEquals( $term->count, $data['count'] );
     1426        $this->assertSame( $term->term_id, $data['id'] );
     1427        $this->assertSame( $term->name, $data['name'] );
     1428        $this->assertSame( $term->slug, $data['slug'] );
     1429        $this->assertSame( $term->description, $data['description'] );
     1430        $this->assertSame( get_term_link( $term ), $data['link'] );
     1431        $this->assertSame( $term->count, $data['count'] );
    14321432        $taxonomy = get_taxonomy( $term->taxonomy );
    14331433        if ( $taxonomy->hierarchical ) {
    1434             $this->assertEquals( $term->parent, $data['parent'] );
     1434            $this->assertSame( $term->parent, $data['parent'] );
    14351435        } else {
    14361436            $this->assertFalse( isset( $data['parent'] ) );
     
    14471447        $this->assertEqualSets( $expected_links, array_keys( $links ) );
    14481448        $this->assertContains( 'wp/v2/taxonomies/' . $term->taxonomy, $links['about'][0]['href'] );
    1449         $this->assertEquals( add_query_arg( 'tags', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] );
     1449        $this->assertSame( add_query_arg( 'tags', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] );
    14501450    }
    14511451
    14521452    protected function check_get_taxonomy_term_response( $response, $id ) {
    14531453
    1454         $this->assertEquals( 200, $response->get_status() );
     1454        $this->assertSame( 200, $response->get_status() );
    14551455
    14561456        $data = $response->get_data();
Note: See TracChangeset for help on using the changeset viewer.