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

    r47122 r48937  
    118118        $response = rest_get_server()->dispatch( $request );
    119119        $data     = $response->get_data();
    120         $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
     120        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
    121121        $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    122122        // Single.
     
    125125        $response  = rest_get_server()->dispatch( $request );
    126126        $data      = $response->get_data();
    127         $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
     127        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
    128128        $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    129129    }
     
    135135        $keys     = array_keys( $data['endpoints'][0]['args'] );
    136136        sort( $keys );
    137         $this->assertEquals(
     137        $this->assertSame(
    138138            array(
    139139                'context',
     
    184184        $response = rest_get_server()->dispatch( $request );
    185185        $data     = $response->get_data();
    186         $this->assertEquals( 2, count( $data ) );
    187         $this->assertEquals( 'Season 5', $data[0]['name'] );
    188         $this->assertEquals( 'The Be Sharps', $data[1]['name'] );
     186        $this->assertSame( 2, count( $data ) );
     187        $this->assertSame( 'Season 5', $data[0]['name'] );
     188        $this->assertSame( 'The Be Sharps', $data[1]['name'] );
    189189
    190190        // Confirm the empty category "Uncategorized" category appears.
     
    192192        $response = rest_get_server()->dispatch( $request );
    193193        $data     = $response->get_data();
    194         $this->assertEquals( $total_categories, count( $data ) );
     194        $this->assertSame( $total_categories, count( $data ) );
    195195    }
    196196
     
    216216        $response = rest_get_server()->dispatch( $request );
    217217
    218         $this->assertEquals( 200, $response->get_status() );
     218        $this->assertSame( 200, $response->get_status() );
    219219        $data = $response->get_data();
    220220
     
    224224        );
    225225        $categories = get_terms( 'category', $args );
    226         $this->assertEquals( count( $categories ), count( $data ) );
     226        $this->assertSame( count( $categories ), count( $data ) );
    227227    }
    228228
     
    248248        $response = rest_get_server()->dispatch( $request );
    249249
    250         $this->assertEquals( 200, $response->get_status() );
     250        $this->assertSame( 200, $response->get_status() );
    251251        $data = $response->get_data();
    252252
     
    256256        );
    257257        $categories = get_terms( 'category', $args );
    258         $this->assertEquals( count( $categories ), count( $data ) );
     258        $this->assertSame( count( $categories ), count( $data ) );
    259259    }
    260260
     
    266266        $response = rest_get_server()->dispatch( $request );
    267267
    268         $this->assertEquals( 200, $response->get_status() );
    269         $data = $response->get_data();
    270 
    271         $this->assertEquals( array(), $data );
     268        $this->assertSame( 200, $response->get_status() );
     269        $data = $response->get_data();
     270
     271        $this->assertSame( array(), $data );
    272272    }
    273273
     
    292292        $response = rest_get_server()->dispatch( $request );
    293293        $data     = $response->get_data();
    294         $this->assertEquals( 2, count( $data ) );
    295         $this->assertEquals( $id1, $data[0]['id'] );
     294        $this->assertSame( 2, count( $data ) );
     295        $this->assertSame( $id1, $data[0]['id'] );
    296296
    297297        // 'orderby' => 'include'.
     
    299299        $response = rest_get_server()->dispatch( $request );
    300300        $data     = $response->get_data();
    301         $this->assertEquals( 2, count( $data ) );
    302         $this->assertEquals( $id2, $data[0]['id'] );
     301        $this->assertSame( 2, count( $data ) );
     302        $this->assertSame( $id2, $data[0]['id'] );
    303303    }
    304304
     
    338338        $request->set_param( 'per_page', 1 );
    339339        $response = rest_get_server()->dispatch( $request );
    340         $this->assertEquals( 200, $response->get_status() );
    341         $data = $response->get_data();
    342         $this->assertEquals( 1, count( $data ) );
    343         $this->assertEquals( 'Uncategorized', $data[0]['name'] );
     340        $this->assertSame( 200, $response->get_status() );
     341        $data = $response->get_data();
     342        $this->assertSame( 1, count( $data ) );
     343        $this->assertSame( 'Uncategorized', $data[0]['name'] );
    344344
    345345        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
     
    348348        $request->set_param( 'per_page', 2 );
    349349        $response = rest_get_server()->dispatch( $request );
    350         $this->assertEquals( 200, $response->get_status() );
    351         $data = $response->get_data();
    352         $this->assertEquals( 2, count( $data ) );
    353         $this->assertEquals( 'Apple', $data[0]['name'] );
     350        $this->assertSame( 200, $response->get_status() );
     351        $data = $response->get_data();
     352        $this->assertSame( 2, count( $data ) );
     353        $this->assertSame( 'Apple', $data[0]['name'] );
    354354    }
    355355
     
    362362        $request  = new WP_REST_Request( 'GET', '/wp/v2/categories' );
    363363        $response = rest_get_server()->dispatch( $request );
    364         $this->assertEquals( 200, $response->get_status() );
    365         $data = $response->get_data();
    366         $this->assertEquals( 'Apple', $data[0]['name'] );
    367         $this->assertEquals( 'Banana', $data[1]['name'] );
    368         $this->assertEquals( 'Cantaloupe', $data[2]['name'] );
     364        $this->assertSame( 200, $response->get_status() );
     365        $data = $response->get_data();
     366        $this->assertSame( 'Apple', $data[0]['name'] );
     367        $this->assertSame( 'Banana', $data[1]['name'] );
     368        $this->assertSame( 'Cantaloupe', $data[2]['name'] );
    369369
    370370        // 'orderby' => 'id', with default 'order' => 'asc'.
     
    372372        $request->set_param( 'orderby', 'id' );
    373373        $response = rest_get_server()->dispatch( $request );
    374         $this->assertEquals( 200, $response->get_status() );
    375         $data = $response->get_data();
    376         $this->assertEquals( 'Category 0', $data[1]['name'] );
    377         $this->assertEquals( 'Category 1', $data[2]['name'] );
    378         $this->assertEquals( 'Category 2', $data[3]['name'] );
     374        $this->assertSame( 200, $response->get_status() );
     375        $data = $response->get_data();
     376        $this->assertSame( 'Category 0', $data[1]['name'] );
     377        $this->assertSame( 'Category 1', $data[2]['name'] );
     378        $this->assertSame( 'Category 2', $data[3]['name'] );
    379379
    380380        // 'orderby' => 'id', 'order' => 'desc'.
     
    384384        $response = rest_get_server()->dispatch( $request );
    385385        $data     = $response->get_data();
    386         $this->assertEquals( 200, $response->get_status() );
    387         $this->assertEquals( 'Banana', $data[0]['name'] );
    388         $this->assertEquals( 'Apple', $data[1]['name'] );
    389         $this->assertEquals( 'Cantaloupe', $data[2]['name'] );
     386        $this->assertSame( 200, $response->get_status() );
     387        $this->assertSame( 'Banana', $data[0]['name'] );
     388        $this->assertSame( 'Apple', $data[1]['name'] );
     389        $this->assertSame( 'Cantaloupe', $data[2]['name'] );
    390390    }
    391391
     
    400400        $response = rest_get_server()->dispatch( $request );
    401401        $data     = $response->get_data();
    402         $this->assertEquals( 200, $response->get_status() );
    403         $this->assertEquals( 'taco', $data[0]['slug'] );
    404         $this->assertEquals( 'burrito', $data[1]['slug'] );
    405         $this->assertEquals( 'chalupa', $data[2]['slug'] );
     402        $this->assertSame( 200, $response->get_status() );
     403        $this->assertSame( 'taco', $data[0]['slug'] );
     404        $this->assertSame( 'burrito', $data[1]['slug'] );
     405        $this->assertSame( 'chalupa', $data[2]['slug'] );
    406406    }
    407407
     
    437437        $request->set_param( 'post', $post_id );
    438438        $response = rest_get_server()->dispatch( $request );
    439         $this->assertEquals( 200, $response->get_status() );
    440 
    441         $data = $response->get_data();
    442         $this->assertEquals( 3, count( $data ) );
     439        $this->assertSame( 200, $response->get_status() );
     440
     441        $data = $response->get_data();
     442        $this->assertSame( 3, count( $data ) );
    443443
    444444        // Check ordered by name by default.
    445445        $names = wp_list_pluck( $data, 'name' );
    446         $this->assertEquals( array( 'DC', 'Image', 'Marvel' ), $names );
     446        $this->assertSame( array( 'DC', 'Image', 'Marvel' ), $names );
    447447    }
    448448
     
    455455        $request->set_param( 'orderby', 'description' );
    456456        $response = rest_get_server()->dispatch( $request );
    457         $this->assertEquals( 200, $response->get_status() );
    458 
    459         $data = $response->get_data();
    460         $this->assertEquals( 3, count( $data ) );
     457        $this->assertSame( 200, $response->get_status() );
     458
     459        $data = $response->get_data();
     460        $this->assertSame( 3, count( $data ) );
    461461        $names = wp_list_pluck( $data, 'name' );
    462         $this->assertEquals( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' );
     462        $this->assertSame( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' );
    463463
    464464        // Flip the order.
    465465        $request->set_param( 'order', 'desc' );
    466466        $response = rest_get_server()->dispatch( $request );
    467         $this->assertEquals( 200, $response->get_status() );
    468 
    469         $data = $response->get_data();
    470         $this->assertEquals( 3, count( $data ) );
     467        $this->assertSame( 200, $response->get_status() );
     468
     469        $data = $response->get_data();
     470        $this->assertSame( 3, count( $data ) );
    471471        $names = wp_list_pluck( $data, 'name' );
    472         $this->assertEquals( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' );
     472        $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' );
    473473    }
    474474
     
    480480        $request->set_param( 'orderby', 'id' );
    481481        $response = rest_get_server()->dispatch( $request );
    482         $this->assertEquals( 200, $response->get_status() );
    483 
    484         $data = $response->get_data();
    485         $this->assertEquals( 3, count( $data ) );
     482        $this->assertSame( 200, $response->get_status() );
     483
     484        $data = $response->get_data();
     485        $this->assertSame( 3, count( $data ) );
    486486        $names = wp_list_pluck( $data, 'name' );
    487         $this->assertEquals( array( 'DC', 'Marvel', 'Image' ), $names );
     487        $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names );
    488488    }
    489489
     
    516516        $request->set_param( 'post', $post_id );
    517517        $response = rest_get_server()->dispatch( $request );
    518         $this->assertEquals( 200, $response->get_status() );
    519 
    520         $data = $response->get_data();
    521         $this->assertEquals( 2, count( $data ) );
    522         $this->assertEquals( 'Cape', $data[0]['name'] );
     518        $this->assertSame( 200, $response->get_status() );
     519
     520        $data = $response->get_data();
     521        $this->assertSame( 2, count( $data ) );
     522        $this->assertSame( 'Cape', $data[0]['name'] );
    523523    }
    524524
     
    534534        $request->set_param( 'search', 'App' );
    535535        $response = rest_get_server()->dispatch( $request );
    536         $this->assertEquals( 200, $response->get_status() );
    537         $data = $response->get_data();
    538         $this->assertEquals( 1, count( $data ) );
    539         $this->assertEquals( 'Apple', $data[0]['name'] );
     536        $this->assertSame( 200, $response->get_status() );
     537        $data = $response->get_data();
     538        $this->assertSame( 1, count( $data ) );
     539        $this->assertSame( 'Apple', $data[0]['name'] );
    540540
    541541        $request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
    542542        $request->set_param( 'search', 'Garbage' );
    543543        $response = rest_get_server()->dispatch( $request );
    544         $this->assertEquals( 200, $response->get_status() );
    545         $data = $response->get_data();
    546         $this->assertEquals( 0, count( $data ) );
     544        $this->assertSame( 200, $response->get_status() );
     545        $data = $response->get_data();
     546        $this->assertSame( 0, count( $data ) );
    547547    }
    548548
     
    554554        $request->set_param( 'slug', 'apple' );
    555555        $response = rest_get_server()->dispatch( $request );
    556         $this->assertEquals( 200, $response->get_status() );
    557         $data = $response->get_data();
    558         $this->assertEquals( 1, count( $data ) );
    559         $this->assertEquals( 'Apple', $data[0]['name'] );
     556        $this->assertSame( 200, $response->get_status() );
     557        $data = $response->get_data();
     558        $this->assertSame( 1, count( $data ) );
     559        $this->assertSame( 'Apple', $data[0]['name'] );
    560560    }
    561561
     
    573573        $response = rest_get_server()->dispatch( $request );
    574574        $data     = $response->get_data();
    575         $this->assertEquals( 1, count( $data ) );
    576         $this->assertEquals( 'Child', $data[0]['name'] );
     575        $this->assertSame( 1, count( $data ) );
     576        $this->assertSame( 'Child', $data[0]['name'] );
    577577    }
    578578
     
    618618        $response = rest_get_server()->dispatch( $request );
    619619        $headers  = $response->get_headers();
    620         $this->assertEquals( $total_categories, $headers['X-WP-Total'] );
    621         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     620        $this->assertSame( $total_categories, $headers['X-WP-Total'] );
     621        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    622622        $this->assertCount( 10, $response->get_data() );
    623623        $next_link = add_query_arg(
     
    638638        $response = rest_get_server()->dispatch( $request );
    639639        $headers  = $response->get_headers();
    640         $this->assertEquals( $total_categories, $headers['X-WP-Total'] );
    641         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     640        $this->assertSame( $total_categories, $headers['X-WP-Total'] );
     641        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    642642        $this->assertCount( 10, $response->get_data() );
    643643        $prev_link = add_query_arg(
     
    661661        $response = rest_get_server()->dispatch( $request );
    662662        $headers  = $response->get_headers();
    663         $this->assertEquals( $total_categories, $headers['X-WP-Total'] );
    664         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     663        $this->assertSame( $total_categories, $headers['X-WP-Total'] );
     664        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    665665        $this->assertCount( 1, $response->get_data() );
    666666        $prev_link = add_query_arg(
     
    678678        $response = rest_get_server()->dispatch( $request );
    679679        $headers  = $response->get_headers();
    680         $this->assertEquals( $total_categories, $headers['X-WP-Total'] );
    681         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     680        $this->assertSame( $total_categories, $headers['X-WP-Total'] );
     681        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    682682        $this->assertCount( 0, $response->get_data() );
    683683        $prev_link = add_query_arg(
     
    698698        $response = rest_get_server()->dispatch( $request );
    699699        $headers  = $response->get_headers();
    700         $this->assertEquals( self::$total_categories, $headers['X-WP-Total'] );
    701         $this->assertEquals( 1, $headers['X-WP-TotalPages'] );
     700        $this->assertSame( self::$total_categories, $headers['X-WP-Total'] );
     701        $this->assertSame( 1, $headers['X-WP-TotalPages'] );
    702702        $this->assertCount( self::$total_categories, $response->get_data() );
    703703
     
    707707        $response = rest_get_server()->dispatch( $request );
    708708        $headers  = $response->get_headers();
    709         $this->assertEquals( self::$total_categories, $headers['X-WP-Total'] );
    710         $this->assertEquals( 1, $headers['X-WP-TotalPages'] );
     709        $this->assertSame( self::$total_categories, $headers['X-WP-Total'] );
     710        $this->assertSame( 1, $headers['X-WP-TotalPages'] );
    711711        $this->assertCount( 0, $response->get_data() );
    712712    }
     
    808808        $request->set_param( 'slug', 'so-awesome' );
    809809        $response = rest_get_server()->dispatch( $request );
    810         $this->assertEquals( 201, $response->get_status() );
     810        $this->assertSame( 201, $response->get_status() );
    811811        $headers = $response->get_headers();
    812812        $data    = $response->get_data();
    813813        $this->assertContains( '/wp/v2/categories/' . $data['id'], $headers['Location'] );
    814         $this->assertEquals( 'My Awesome Term', $data['name'] );
    815         $this->assertEquals( 'This term is so awesome.', $data['description'] );
    816         $this->assertEquals( 'so-awesome', $data['slug'] );
     814        $this->assertSame( 'My Awesome Term', $data['name'] );
     815        $this->assertSame( 'This term is so awesome.', $data['description'] );
     816        $this->assertSame( 'so-awesome', $data['slug'] );
    817817    }
    818818
     
    829829
    830830        $response = rest_get_server()->dispatch( $request );
    831         $this->assertEquals( 400, $response->get_status() );
    832         $data = $response->get_data();
    833         $this->assertEquals( 'term_exists', $data['code'] );
    834         $this->assertEquals( $existing_id, (int) $data['data']['term_id'] );
     831        $this->assertSame( 400, $response->get_status() );
     832        $data = $response->get_data();
     833        $this->assertSame( 'term_exists', $data['code'] );
     834        $this->assertSame( $existing_id, (int) $data['data']['term_id'] );
    835835
    836836        wp_delete_term( $existing_id, 'category' );
     
    881881        $request->set_param( 'parent', $parent['term_id'] );
    882882        $response = rest_get_server()->dispatch( $request );
    883         $this->assertEquals( 201, $response->get_status() );
    884         $data = $response->get_data();
    885         $this->assertEquals( $parent['term_id'], $data['parent'] );
     883        $this->assertSame( 201, $response->get_status() );
     884        $data = $response->get_data();
     885        $this->assertSame( $parent['term_id'], $data['parent'] );
    886886    }
    887887
     
    907907        $request->set_param( 'parent', $parent );
    908908        $response = rest_get_server()->dispatch( $request );
    909         $this->assertEquals( 201, $response->get_status() );
    910         $data = $response->get_data();
    911         $this->assertEquals( $parent, $data['parent'] );
     909        $this->assertSame( 201, $response->get_status() );
     910        $data = $response->get_data();
     911        $this->assertSame( $parent, $data['parent'] );
    912912    }
    913913
     
    936936        );
    937937        $response = rest_get_server()->dispatch( $request );
    938         $this->assertEquals( 200, $response->get_status() );
    939         $data = $response->get_data();
    940         $this->assertEquals( 'New Name', $data['name'] );
    941         $this->assertEquals( 'New Description', $data['description'] );
    942         $this->assertEquals( 'new-slug', $data['slug'] );
    943         $this->assertEquals( 'just meta', $data['meta']['test_single'] );
    944         $this->assertEquals( 'category-specific meta', $data['meta']['test_cat_single'] );
     938        $this->assertSame( 200, $response->get_status() );
     939        $data = $response->get_data();
     940        $this->assertSame( 'New Name', $data['name'] );
     941        $this->assertSame( 'New Description', $data['description'] );
     942        $this->assertSame( 'new-slug', $data['slug'] );
     943        $this->assertSame( 'just meta', $data['meta']['test_single'] );
     944        $this->assertSame( 'category-specific meta', $data['meta']['test_cat_single'] );
    945945        $this->assertFalse( isset( $data['meta']['test_tag_meta'] ) );
    946946    }
     
    984984        $request->set_param( 'parent', $parent->term_id );
    985985        $response = rest_get_server()->dispatch( $request );
    986         $this->assertEquals( 200, $response->get_status() );
    987 
    988         $data = $response->get_data();
    989         $this->assertEquals( $parent->term_id, $data['parent'] );
     986        $this->assertSame( 200, $response->get_status() );
     987
     988        $data = $response->get_data();
     989        $this->assertSame( $parent->term_id, $data['parent'] );
    990990    }
    991991
     
    10061006        );
    10071007
    1008         $this->assertEquals( $old_parent_term->term_id, $term->parent );
     1008        $this->assertSame( $old_parent_term->term_id, $term->parent );
    10091009
    10101010        $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
    10111011        $request->set_param( 'parent', $new_parent_id );
    10121012        $response = rest_get_server()->dispatch( $request );
    1013         $this->assertEquals( 200, $response->get_status() );
    1014 
    1015         $data = $response->get_data();
    1016         $this->assertEquals( $new_parent_id, $data['parent'] );
     1013        $this->assertSame( 200, $response->get_status() );
     1014
     1015        $data = $response->get_data();
     1016        $this->assertSame( $new_parent_id, $data['parent'] );
    10171017    }
    10181018
     
    10361036        $request->set_param( 'force', true );
    10371037        $response = rest_get_server()->dispatch( $request );
    1038         $this->assertEquals( 200, $response->get_status() );
     1038        $this->assertSame( 200, $response->get_status() );
    10391039        $data = $response->get_data();
    10401040        $this->assertTrue( $data['deleted'] );
    1041         $this->assertEquals( 'Deleted Category', $data['previous']['name'] );
     1041        $this->assertSame( 'Deleted Category', $data['previous']['name'] );
    10421042    }
    10431043
     
    10971097        $term     = get_term( 1, 'category' );
    10981098        $response = $endpoint->prepare_item_for_response( $term, $request );
    1099         $this->assertEquals(
     1099        $this->assertSame(
    11001100            array(
    11011101                'id',
     
    11201120        $this->check_taxonomy_term( $term, $data, $response->get_links() );
    11211121
    1122         $this->assertEquals( 1, $data['parent'] );
     1122        $this->assertSame( 1, $data['parent'] );
    11231123
    11241124        $links = $response->get_links();
    1125         $this->assertEquals( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] );
     1125        $this->assertSame( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] );
    11261126    }
    11271127
     
    11311131        $data       = $response->get_data();
    11321132        $properties = $data['schema']['properties'];
    1133         $this->assertEquals( 9, count( $properties ) );
     1133        $this->assertSame( 9, count( $properties ) );
    11341134        $this->assertArrayHasKey( 'id', $properties );
    11351135        $this->assertArrayHasKey( 'count', $properties );
     
    11411141        $this->assertArrayHasKey( 'slug', $properties );
    11421142        $this->assertArrayHasKey( 'taxonomy', $properties );
    1143         $this->assertEquals( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
     1143        $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
    11441144    }
    11451145
     
    11671167        $data     = $response->get_data();
    11681168        $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
    1169         $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] );
     1169        $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
    11701170
    11711171        $category_id = $this->factory->category->create();
     
    11901190
    11911191    protected function check_get_taxonomy_terms_response( $response ) {
    1192         $this->assertEquals( 200, $response->get_status() );
     1192        $this->assertSame( 200, $response->get_status() );
    11931193        $data       = $response->get_data();
    11941194        $args       = array(
     
    11961196        );
    11971197        $categories = get_terms( 'category', $args );
    1198         $this->assertEquals( count( $categories ), count( $data ) );
    1199         $this->assertEquals( $categories[0]->term_id, $data[0]['id'] );
    1200         $this->assertEquals( $categories[0]->name, $data[0]['name'] );
    1201         $this->assertEquals( $categories[0]->slug, $data[0]['slug'] );
    1202         $this->assertEquals( $categories[0]->taxonomy, $data[0]['taxonomy'] );
    1203         $this->assertEquals( $categories[0]->description, $data[0]['description'] );
    1204         $this->assertEquals( $categories[0]->count, $data[0]['count'] );
     1198        $this->assertSame( count( $categories ), count( $data ) );
     1199        $this->assertSame( $categories[0]->term_id, $data[0]['id'] );
     1200        $this->assertSame( $categories[0]->name, $data[0]['name'] );
     1201        $this->assertSame( $categories[0]->slug, $data[0]['slug'] );
     1202        $this->assertSame( $categories[0]->taxonomy, $data[0]['taxonomy'] );
     1203        $this->assertSame( $categories[0]->description, $data[0]['description'] );
     1204        $this->assertSame( $categories[0]->count, $data[0]['count'] );
    12051205    }
    12061206
    12071207    protected function check_taxonomy_term( $term, $data, $links ) {
    1208         $this->assertEquals( $term->term_id, $data['id'] );
    1209         $this->assertEquals( $term->name, $data['name'] );
    1210         $this->assertEquals( $term->slug, $data['slug'] );
    1211         $this->assertEquals( $term->description, $data['description'] );
    1212         $this->assertEquals( get_term_link( $term ), $data['link'] );
    1213         $this->assertEquals( $term->count, $data['count'] );
     1208        $this->assertSame( $term->term_id, $data['id'] );
     1209        $this->assertSame( $term->name, $data['name'] );
     1210        $this->assertSame( $term->slug, $data['slug'] );
     1211        $this->assertSame( $term->description, $data['description'] );
     1212        $this->assertSame( get_term_link( $term ), $data['link'] );
     1213        $this->assertSame( $term->count, $data['count'] );
    12141214        $taxonomy = get_taxonomy( $term->taxonomy );
    12151215        if ( $taxonomy->hierarchical ) {
    1216             $this->assertEquals( $term->parent, $data['parent'] );
     1216            $this->assertSame( $term->parent, $data['parent'] );
    12171217        } else {
    12181218            $this->assertFalse( isset( $term->parent ) );
     
    12321232        $this->assertEqualSets( $relations, array_keys( $links ) );
    12331233        $this->assertContains( 'wp/v2/taxonomies/' . $term->taxonomy, $links['about'][0]['href'] );
    1234         $this->assertEquals( add_query_arg( 'categories', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] );
     1234        $this->assertSame( add_query_arg( 'categories', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] );
    12351235    }
    12361236
    12371237    protected function check_get_taxonomy_term_response( $response ) {
    12381238
    1239         $this->assertEquals( 200, $response->get_status() );
     1239        $this->assertSame( 200, $response->get_status() );
    12401240
    12411241        $data     = $response->get_data();
Note: See TracChangeset for help on using the changeset viewer.