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

    r48858 r48937  
    130130        $expected_clause = str_replace( '{posts}', $wpdb->posts, $pattern );
    131131        $this->assertCount( 1, $this->posts_clauses );
    132         $this->assertEquals( $expected_clause, $wpdb->remove_placeholder_escape( $this->posts_clauses[0][ $clause ] ) );
     132        $this->assertSame( $expected_clause, $wpdb->remove_placeholder_escape( $this->posts_clauses[0][ $clause ] ) );
    133133    }
    134134
     
    155155        $response = rest_get_server()->dispatch( $request );
    156156        $data     = $response->get_data();
    157         $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    158         $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
     157        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
     158        $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    159159        // Single.
    160160        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id );
    161161        $response = rest_get_server()->dispatch( $request );
    162162        $data     = $response->get_data();
    163         $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
    164         $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
     163        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
     164        $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    165165    }
    166166
     
    171171        $keys     = array_keys( $data['endpoints'][0]['args'] );
    172172        sort( $keys );
    173         $this->assertEquals(
     173        $this->assertSame(
    174174            array(
    175175                'after',
     
    205205        $keys     = array_keys( $data['endpoints'][0]['args'] );
    206206        sort( $keys );
    207         $this->assertEquals( array( 'context', 'id', 'password' ), $keys );
     207        $this->assertSame( array( 'context', 'id', 'password' ), $keys );
    208208    }
    209209
     
    218218
    219219        $this->assertNotEmpty( $headers['Allow'] );
    220         $this->assertEquals( $headers['Allow'], 'GET' );
     220        $this->assertSame( $headers['Allow'], 'GET' );
    221221
    222222        wp_set_current_user( self::$editor_id );
     
    228228
    229229        $this->assertNotEmpty( $headers['Allow'] );
    230         $this->assertEquals( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' );
     230        $this->assertSame( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' );
    231231    }
    232232
     
    253253
    254254        $this->assertEmpty( $response->get_data() );
    255         $this->assertEquals( 200, $response->get_status() );
     255        $this->assertSame( 200, $response->get_status() );
    256256    }
    257257
     
    266266        $request->set_param( 'per_page', self::$per_page );
    267267        $response = rest_get_server()->dispatch( $request );
    268         $this->assertEquals( 200, $response->get_status() );
    269         $this->assertEquals( $total_posts, count( $response->get_data() ) );
     268        $this->assertSame( 200, $response->get_status() );
     269        $this->assertSame( $total_posts, count( $response->get_data() ) );
    270270
    271271        // Limit to editor and author.
     
    273273        $request->set_param( 'author', array( self::$editor_id, self::$author_id ) );
    274274        $response = rest_get_server()->dispatch( $request );
    275         $this->assertEquals( 200, $response->get_status() );
     275        $this->assertSame( 200, $response->get_status() );
    276276        $data = $response->get_data();
    277         $this->assertEquals( 2, count( $data ) );
     277        $this->assertSame( 2, count( $data ) );
    278278        $this->assertEqualSets( array( self::$editor_id, self::$author_id ), wp_list_pluck( $data, 'author' ) );
    279279
     
    282282        $request->set_param( 'author', self::$editor_id );
    283283        $response = rest_get_server()->dispatch( $request );
    284         $this->assertEquals( 200, $response->get_status() );
     284        $this->assertSame( 200, $response->get_status() );
    285285        $data = $response->get_data();
    286         $this->assertEquals( 1, count( $data ) );
    287         $this->assertEquals( self::$editor_id, $data[0]['author'] );
     286        $this->assertSame( 1, count( $data ) );
     287        $this->assertSame( self::$editor_id, $data[0]['author'] );
    288288    }
    289289
     
    298298        $request->set_param( 'per_page', self::$per_page );
    299299        $response = rest_get_server()->dispatch( $request );
    300         $this->assertEquals( 200, $response->get_status() );
    301         $this->assertEquals( $total_posts, count( $response->get_data() ) );
     300        $this->assertSame( 200, $response->get_status() );
     301        $this->assertSame( $total_posts, count( $response->get_data() ) );
    302302
    303303        // Exclude editor and author.
     
    306306        $request->set_param( 'author_exclude', array( self::$editor_id, self::$author_id ) );
    307307        $response = rest_get_server()->dispatch( $request );
    308         $this->assertEquals( 200, $response->get_status() );
     308        $this->assertSame( 200, $response->get_status() );
    309309        $data = $response->get_data();
    310         $this->assertEquals( $total_posts - 2, count( $data ) );
     310        $this->assertSame( $total_posts - 2, count( $data ) );
    311311        $this->assertNotEquals( self::$editor_id, $data[0]['author'] );
    312312        $this->assertNotEquals( self::$author_id, $data[0]['author'] );
     
    317317        $request->set_param( 'author_exclude', self::$editor_id );
    318318        $response = rest_get_server()->dispatch( $request );
    319         $this->assertEquals( 200, $response->get_status() );
     319        $this->assertSame( 200, $response->get_status() );
    320320        $data = $response->get_data();
    321         $this->assertEquals( $total_posts - 1, count( $data ) );
     321        $this->assertSame( $total_posts - 1, count( $data ) );
    322322        $this->assertNotEquals( self::$editor_id, $data[0]['author'] );
    323323        $this->assertNotEquals( self::$editor_id, $data[1]['author'] );
     
    350350        $response = rest_get_server()->dispatch( $request );
    351351        $data     = $response->get_data();
    352         $this->assertEquals( 2, count( $data ) );
    353         $this->assertEquals( $id2, $data[0]['id'] );
     352        $this->assertSame( 2, count( $data ) );
     353        $this->assertSame( $id2, $data[0]['id'] );
    354354        $this->assertPostsOrderedBy( '{posts}.post_date DESC' );
    355355
     
    358358        $response = rest_get_server()->dispatch( $request );
    359359        $data     = $response->get_data();
    360         $this->assertEquals( 2, count( $data ) );
    361         $this->assertEquals( $id1, $data[0]['id'] );
     360        $this->assertSame( 2, count( $data ) );
     361        $this->assertSame( $id1, $data[0]['id'] );
    362362        $this->assertPostsOrderedBy( "FIELD({posts}.ID,$id1,$id2)" );
    363363
     
    396396        $data     = $response->get_data();
    397397
    398         $this->assertEquals( 200, $response->get_status() );
    399         $this->assertEquals( self::$author_id, $data[0]['author'] );
    400         $this->assertEquals( self::$editor_id, $data[1]['author'] );
    401         $this->assertEquals( self::$editor_id, $data[2]['author'] );
     398        $this->assertSame( 200, $response->get_status() );
     399        $this->assertSame( self::$author_id, $data[0]['author'] );
     400        $this->assertSame( self::$editor_id, $data[1]['author'] );
     401        $this->assertSame( self::$editor_id, $data[2]['author'] );
    402402
    403403        $this->assertPostsOrderedBy( '{posts}.post_author DESC' );
     
    420420        $data     = $response->get_data();
    421421
    422         $this->assertEquals( 200, $response->get_status() );
    423         $this->assertEquals( $id1, $data[0]['id'] );
    424         $this->assertEquals( $id3, $data[1]['id'] );
    425         $this->assertEquals( $id2, $data[2]['id'] );
     422        $this->assertSame( 200, $response->get_status() );
     423        $this->assertSame( $id1, $data[0]['id'] );
     424        $this->assertSame( $id3, $data[1]['id'] );
     425        $this->assertSame( $id2, $data[2]['id'] );
    426426
    427427        $this->assertPostsOrderedBy( '{posts}.post_modified DESC' );
     
    456456        $data     = $response->get_data();
    457457
    458         $this->assertEquals( 200, $response->get_status() );
    459         $this->assertEquals( $id3, $data[0]['id'] );
     458        $this->assertSame( 200, $response->get_status() );
     459        $this->assertSame( $id3, $data[0]['id'] );
    460460        // Check ordering. Default ORDER is DESC.
    461         $this->assertEquals( $id1, $data[0]['parent'] );
    462         $this->assertEquals( 0, $data[1]['parent'] );
    463         $this->assertEquals( 0, $data[2]['parent'] );
     461        $this->assertSame( $id1, $data[0]['parent'] );
     462        $this->assertSame( 0, $data[1]['parent'] );
     463        $this->assertSame( 0, $data[2]['parent'] );
    464464
    465465        $this->assertPostsOrderedBy( '{posts}.post_parent DESC' );
     
    508508        $request->set_param( 'per_page', self::$per_page );
    509509        $response = rest_get_server()->dispatch( $request );
    510         $this->assertEquals( $total_posts, count( $response->get_data() ) );
     510        $this->assertSame( $total_posts, count( $response->get_data() ) );
    511511
    512512        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    514514        $response = rest_get_server()->dispatch( $request );
    515515        $data     = $response->get_data();
    516         $this->assertEquals( 1, count( $data ) );
    517         $this->assertEquals( 'Search Result', $data[0]['title']['rendered'] );
     516        $this->assertSame( 1, count( $data ) );
     517        $this->assertSame( 'Search Result', $data[0]['title']['rendered'] );
    518518    }
    519519
     
    535535        $request->set_param( 'slug', 'apple' );
    536536        $response = rest_get_server()->dispatch( $request );
    537         $this->assertEquals( 200, $response->get_status() );
     537        $this->assertSame( 200, $response->get_status() );
    538538        $data = $response->get_data();
    539         $this->assertEquals( 1, count( $data ) );
    540         $this->assertEquals( 'Apple', $data[0]['title']['rendered'] );
     539        $this->assertSame( 1, count( $data ) );
     540        $this->assertSame( 'Apple', $data[0]['title']['rendered'] );
    541541    }
    542542
     
    564564        $request->set_param( 'slug', array( 'banana', 'peach' ) );
    565565        $response = rest_get_server()->dispatch( $request );
    566         $this->assertEquals( 200, $response->get_status() );
     566        $this->assertSame( 200, $response->get_status() );
    567567        $data = $response->get_data();
    568         $this->assertEquals( 2, count( $data ) );
     568        $this->assertSame( 2, count( $data ) );
    569569        $titles = array(
    570570            $data[0]['title']['rendered'],
     
    572572        );
    573573        sort( $titles );
    574         $this->assertEquals( array( 'Banana', 'Peach' ), $titles );
     574        $this->assertSame( array( 'Banana', 'Peach' ), $titles );
    575575    }
    576576
     
    598598        $request->set_param( 'slug', 'apple,banana' );
    599599        $response = rest_get_server()->dispatch( $request );
    600         $this->assertEquals( 200, $response->get_status() );
     600        $this->assertSame( 200, $response->get_status() );
    601601        $data = $response->get_data();
    602         $this->assertEquals( 2, count( $data ) );
     602        $this->assertSame( 2, count( $data ) );
    603603        $titles = array(
    604604            $data[0]['title']['rendered'],
     
    606606        );
    607607        sort( $titles );
    608         $this->assertEquals( array( 'Apple', 'Banana' ), $titles );
     608        $this->assertSame( array( 'Apple', 'Banana' ), $titles );
    609609    }
    610610
     
    618618        $request->set_param( 'status', 'publish' );
    619619        $response = rest_get_server()->dispatch( $request );
    620         $this->assertEquals( 200, $response->get_status() );
    621         $this->assertEquals( self::$total_posts, count( $response->get_data() ) );
     620        $this->assertSame( 200, $response->get_status() );
     621        $this->assertSame( self::$total_posts, count( $response->get_data() ) );
    622622
    623623        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     
    631631        $request->set_param( 'status', 'draft' );
    632632        $response = rest_get_server()->dispatch( $request );
    633         $this->assertEquals( 200, $response->get_status() );
    634         $this->assertEquals( 1, count( $response->get_data() ) );
     633        $this->assertSame( 200, $response->get_status() );
     634        $this->assertSame( 1, count( $response->get_data() ) );
    635635    }
    636636
     
    647647
    648648        $response = rest_get_server()->dispatch( $request );
    649         $this->assertEquals( 200, $response->get_status() );
     649        $this->assertSame( 200, $response->get_status() );
    650650        $data = $response->get_data();
    651         $this->assertEquals( 2, count( $data ) );
     651        $this->assertSame( 2, count( $data ) );
    652652        $statuses = array(
    653653            $data[0]['status'],
     
    655655        );
    656656        sort( $statuses );
    657         $this->assertEquals( array( 'draft', 'private' ), $statuses );
     657        $this->assertSame( array( 'draft', 'private' ), $statuses );
    658658    }
    659659
     
    670670
    671671        $response = rest_get_server()->dispatch( $request );
    672         $this->assertEquals( 200, $response->get_status() );
     672        $this->assertSame( 200, $response->get_status() );
    673673        $data = $response->get_data();
    674         $this->assertEquals( 2, count( $data ) );
     674        $this->assertSame( 2, count( $data ) );
    675675        $statuses = array(
    676676            $data[0]['status'],
     
    678678        );
    679679        sort( $statuses );
    680         $this->assertEquals( array( 'draft', 'pending' ), $statuses );
     680        $this->assertSame( array( 'draft', 'pending' ), $statuses );
    681681    }
    682682
     
    725725        $response = rest_get_server()->dispatch( $request );
    726726
    727         $this->assertEquals( 200, $response->get_status() );
     727        $this->assertSame( 200, $response->get_status() );
    728728
    729729        $all_data = $response->get_data();
     
    766766        $response = rest_get_server()->dispatch( $request );
    767767        $data     = $response->get_data();
    768         $this->assertEquals( 'Apple Sauce', $data[0]['title']['rendered'] );
     768        $this->assertSame( 'Apple Sauce', $data[0]['title']['rendered'] );
    769769        $this->assertPostsOrderedBy( '{posts}.post_title DESC' );
    770770
     
    773773        $response = rest_get_server()->dispatch( $request );
    774774        $data     = $response->get_data();
    775         $this->assertEquals( 'Apple Cobbler', $data[0]['title']['rendered'] );
     775        $this->assertSame( 'Apple Cobbler', $data[0]['title']['rendered'] );
    776776        $this->assertPostsOrderedBy( '{posts}.post_title ASC' );
    777777
     
    827827
    828828        // Default ORDER is DESC.
    829         $this->assertEquals( $id3, $data[0]['id'] );
    830         $this->assertEquals( $id2, $data[1]['id'] );
    831         $this->assertEquals( $id1, $data[2]['id'] );
     829        $this->assertSame( $id3, $data[0]['id'] );
     830        $this->assertSame( $id2, $data[1]['id'] );
     831        $this->assertSame( $id1, $data[2]['id'] );
    832832        $this->assertPostsOrderedBy( '{posts}.ID DESC' );
    833833    }
     
    857857
    858858        // Default ORDER is DESC.
    859         $this->assertEquals( 'xyz', $data[0]['slug'] );
    860         $this->assertEquals( 'abc', $data[1]['slug'] );
     859        $this->assertSame( 'xyz', $data[0]['slug'] );
     860        $this->assertSame( 'abc', $data[1]['slug'] );
    861861        $this->assertPostsOrderedBy( '{posts}.post_name DESC' );
    862862    }
     
    881881        $data     = $response->get_data();
    882882
    883         $this->assertEquals( 'taco', $data[0]['slug'] );
    884         $this->assertEquals( 'chalupa', $data[1]['slug'] );
    885         $this->assertEquals( 'burrito', $data[2]['slug'] );
     883        $this->assertSame( 'taco', $data[0]['slug'] );
     884        $this->assertSame( 'chalupa', $data[1]['slug'] );
     885        $this->assertSame( 'burrito', $data[2]['slug'] );
    886886    }
    887887
     
    906906        $request->set_param( 'search', 'relevant' );
    907907        $response = rest_get_server()->dispatch( $request );
    908         $this->assertEquals( 200, $response->get_status() );
     908        $this->assertSame( 200, $response->get_status() );
    909909        $data = $response->get_data();
    910910        $this->assertCount( 2, $data );
    911         $this->assertEquals( $id1, $data[0]['id'] );
    912         $this->assertEquals( $id2, $data[1]['id'] );
     911        $this->assertSame( $id1, $data[0]['id'] );
     912        $this->assertSame( $id2, $data[1]['id'] );
    913913        $this->assertPostsOrderedBy( '{posts}.post_title LIKE \'%relevant%\' DESC, {posts}.post_date DESC' );
    914914    }
     
    934934        $request->set_param( 'search', 'relevant content' );
    935935        $response = rest_get_server()->dispatch( $request );
    936         $this->assertEquals( 200, $response->get_status() );
     936        $this->assertSame( 200, $response->get_status() );
    937937        $data = $response->get_data();
    938938        $this->assertCount( 2, $data );
    939         $this->assertEquals( $id1, $data[0]['id'] );
    940         $this->assertEquals( $id2, $data[1]['id'] );
     939        $this->assertSame( $id1, $data[0]['id'] );
     940        $this->assertSame( $id2, $data[1]['id'] );
    941941        $this->assertPostsOrderedBy( '(CASE WHEN {posts}.post_title LIKE \'%relevant content%\' THEN 1 WHEN {posts}.post_title LIKE \'%relevant%\' AND {posts}.post_title LIKE \'%content%\' THEN 2 WHEN {posts}.post_title LIKE \'%relevant%\' OR {posts}.post_title LIKE \'%content%\' THEN 3 WHEN {posts}.post_excerpt LIKE \'%relevant content%\' THEN 4 WHEN {posts}.post_content LIKE \'%relevant content%\' THEN 5 ELSE 6 END), {posts}.post_date DESC' );
    942942    }
     
    984984        $data     = $response->get_data();
    985985        $this->assertCount( 1, $data );
    986         $this->assertEquals( $id1, $data[0]['id'] );
     986        $this->assertSame( $id1, $data[0]['id'] );
    987987    }
    988988
     
    10051005        $data     = $response->get_data();
    10061006        $this->assertCount( $total_posts - 1, $data );
    1007         $this->assertEquals( $id4, $data[0]['id'] );
    1008         $this->assertEquals( $id3, $data[1]['id'] );
    1009         $this->assertEquals( $id2, $data[2]['id'] );
     1007        $this->assertSame( $id4, $data[0]['id'] );
     1008        $this->assertSame( $id3, $data[1]['id'] );
     1009        $this->assertSame( $id2, $data[2]['id'] );
    10101010    }
    10111011
     
    10531053        $data     = $response->get_data();
    10541054        $this->assertCount( 2, $data );
    1055         $this->assertEquals( $id2, $data[0]['id'] );
    1056         $this->assertEquals( $id1, $data[1]['id'] );
     1055        $this->assertSame( $id2, $data[0]['id'] );
     1056        $this->assertSame( $id1, $data[1]['id'] );
    10571057    }
    10581058
     
    10741074        $data     = $response->get_data();
    10751075        $this->assertCount( 1, $data );
    1076         $this->assertEquals( $id2, $data[0]['id'] );
     1076        $this->assertSame( $id2, $data[0]['id'] );
    10771077
    10781078        $request->set_param( 'tags_exclude', array( 'my-tag' ) );
     
    11091109        $data     = $response->get_data();
    11101110        $this->assertCount( $total_posts - 1, $data );
    1111         $this->assertEquals( $id4, $data[0]['id'] );
    1112         $this->assertEquals( $id2, $data[1]['id'] );
    1113         $this->assertEquals( $id1, $data[2]['id'] );
     1111        $this->assertSame( $id4, $data[0]['id'] );
     1112        $this->assertSame( $id2, $data[1]['id'] );
     1113        $this->assertSame( $id1, $data[2]['id'] );
    11141114    }
    11151115
     
    11231123
    11241124        $response = rest_get_server()->dispatch( $request );
    1125         $this->assertEquals( 200, $response->get_status() );
     1125        $this->assertSame( 200, $response->get_status() );
    11261126        $this->assertCount( 1, $response->get_data() );
    1127         $this->assertEquals( self::$post_id, $response->get_data()[0]['id'] );
     1127        $this->assertSame( self::$post_id, $response->get_data()[0]['id'] );
    11281128    }
    11291129
     
    11421142        $posts = $response->get_data();
    11431143        $post  = $posts[0];
    1144         $this->assertEquals( $id2, $post['id'] );
     1144        $this->assertSame( $id2, $post['id'] );
    11451145
    11461146        $request->set_param( 'sticky', 'nothanks' );
     
    11801180        $posts = $response->get_data();
    11811181        $post  = $posts[0];
    1182         $this->assertEquals( $id1, $post['id'] );
     1182        $this->assertSame( $id1, $post['id'] );
    11831183
    11841184        $this->assertPostsWhere( " AND {posts}.ID IN ($id1) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" );
     
    12371237        $posts = $response->get_data();
    12381238        $post  = $posts[0];
    1239         $this->assertEquals( $id1, $post['id'] );
     1239        $this->assertSame( $id1, $post['id'] );
    12401240
    12411241        $this->assertPostsWhere( " AND {posts}.ID NOT IN ($id2) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" );
     
    13021302        $response = rest_get_server()->dispatch( $request );
    13031303        $headers  = $response->get_headers();
    1304         $this->assertEquals( $total_posts, $headers['X-WP-Total'] );
    1305         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     1304        $this->assertSame( $total_posts, $headers['X-WP-Total'] );
     1305        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    13061306        $next_link = add_query_arg(
    13071307            array(
     
    13211321        $response = rest_get_server()->dispatch( $request );
    13221322        $headers  = $response->get_headers();
    1323         $this->assertEquals( $total_posts, $headers['X-WP-Total'] );
    1324         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     1323        $this->assertSame( $total_posts, $headers['X-WP-Total'] );
     1324        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    13251325        $prev_link = add_query_arg(
    13261326            array(
     
    13431343        $response = rest_get_server()->dispatch( $request );
    13441344        $headers  = $response->get_headers();
    1345         $this->assertEquals( $total_posts, $headers['X-WP-Total'] );
    1346         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     1345        $this->assertSame( $total_posts, $headers['X-WP-Total'] );
     1346        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    13471347        $prev_link = add_query_arg(
    13481348            array(
     
    13721372        $response = rest_get_server()->dispatch( $request );
    13731373        $headers  = $response->get_headers();
    1374         $this->assertEquals( $total_posts, $headers['X-WP-Total'] );
    1375         $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] );
     1374        $this->assertSame( $total_posts, $headers['X-WP-Total'] );
     1375        $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] );
    13761376        $prev_link = add_query_arg(
    13771377            array(
     
    14161416        $response = rest_get_server()->dispatch( $request );
    14171417        $data     = $response->get_data();
    1418         $this->assertEquals( $draft_id, $data[0]['id'] );
     1418        $this->assertSame( $draft_id, $data[0]['id'] );
    14191419    }
    14201420
     
    14391439        $response = rest_get_server()->dispatch( $request );
    14401440        $data     = $response->get_data();
    1441         $this->assertEquals( 200, $response->get_status() );
     1441        $this->assertSame( 200, $response->get_status() );
    14421442        $this->assertCount( 1, $data );
    1443         $this->assertEquals( $private_post_id, $data[0]['id'] );
     1443        $this->assertSame( $private_post_id, $data[0]['id'] );
    14441444    }
    14451445
     
    14881488        $data     = $response->get_data();
    14891489        $this->assertCount( 1, $data );
    1490         $this->assertEquals( $post2, $data[0]['id'] );
     1490        $this->assertSame( $post2, $data[0]['id'] );
    14911491    }
    14921492
     
    14981498        $formats = array_values( get_post_format_slugs() );
    14991499
    1500         $this->assertEquals( $formats, $data['schema']['properties']['format']['enum'] );
     1500        $this->assertSame( $formats, $data['schema']['properties']['format']['enum'] );
    15011501    }
    15021502
     
    15141514        $links = $response->get_links();
    15151515
    1516         $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] );
    1517         $this->assertEquals( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] );
     1516        $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] );
     1517        $this->assertSame( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] );
    15181518        $this->assertArrayNotHasKey( 'embeddable', $links['self'][0]['attributes'] );
    15191519
    1520         $this->assertEquals( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] );
     1520        $this->assertSame( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] );
    15211521
    15221522        $replies_url = rest_url( '/wp/v2/comments' );
    15231523        $replies_url = add_query_arg( 'post', self::$post_id, $replies_url );
    1524         $this->assertEquals( $replies_url, $links['replies'][0]['href'] );
    1525 
    1526         $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
    1527         $this->assertEquals( 0, $links['version-history'][0]['attributes']['count'] );
     1524        $this->assertSame( $replies_url, $links['replies'][0]['href'] );
     1525
     1526        $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
     1527        $this->assertSame( 0, $links['version-history'][0]['attributes']['count'] );
    15281528        $this->assertFalse( isset( $links['predecessor-version'] ) );
    15291529
    15301530        $attachments_url = rest_url( '/wp/v2/media' );
    15311531        $attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url );
    1532         $this->assertEquals( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] );
     1532        $this->assertSame( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] );
    15331533
    15341534        $term_links  = $links['https://api.w.org/term'];
     
    15501550
    15511551        $tags_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/tags' ) );
    1552         $this->assertEquals( $tags_url, $tag_link['href'] );
     1552        $this->assertSame( $tags_url, $tag_link['href'] );
    15531553
    15541554        $category_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/categories' ) );
    1555         $this->assertEquals( $category_url, $cat_link['href'] );
     1555        $this->assertSame( $category_url, $cat_link['href'] );
    15561556    }
    15571557
     
    15711571        $links = $response->get_links();
    15721572
    1573         $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
    1574         $this->assertEquals( 1, $links['version-history'][0]['attributes']['count'] );
    1575 
    1576         $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] );
    1577         $this->assertEquals( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] );
     1573        $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
     1574        $this->assertSame( 1, $links['version-history'][0]['attributes']['count'] );
     1575
     1576        $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] );
     1577        $this->assertSame( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] );
    15781578    }
    15791579
     
    15921592        $response = rest_get_server()->dispatch( $request );
    15931593        $links    = $response->get_links();
    1594         $this->assertEquals( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] );
     1594        $this->assertSame( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] );
    15951595    }
    15961596
     
    16731673
    16741674        $data = $response->get_data();
    1675         $this->assertEquals( '', $data['content']['rendered'] );
     1675        $this->assertSame( '', $data['content']['rendered'] );
    16761676        $this->assertTrue( $data['content']['protected'] );
    1677         $this->assertEquals( '', $data['excerpt']['rendered'] );
     1677        $this->assertSame( '', $data['excerpt']['rendered'] );
    16781678        $this->assertTrue( $data['excerpt']['protected'] );
    16791679    }
     
    16971697
    16981698        $data = $response->get_data();
    1699         $this->assertEquals( wpautop( $post->post_content ), $data['content']['rendered'] );
     1699        $this->assertSame( wpautop( $post->post_content ), $data['content']['rendered'] );
    17001700        $this->assertTrue( $data['content']['protected'] );
    1701         $this->assertEquals( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] );
     1701        $this->assertSame( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] );
    17021702        $this->assertTrue( $data['excerpt']['protected'] );
    17031703    }
     
    17321732        $data     = $response->get_data();
    17331733        $this->check_get_post_response( $response, 'view' );
    1734         $this->assertEquals( '', $data['content']['rendered'] );
     1734        $this->assertSame( '', $data['content']['rendered'] );
    17351735        $this->assertTrue( $data['content']['protected'] );
    1736         $this->assertEquals( '', $data['excerpt']['rendered'] );
     1736        $this->assertSame( '', $data['excerpt']['rendered'] );
    17371737        $this->assertTrue( $data['excerpt']['protected'] );
    17381738    }
     
    18121812        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
    18131813        $response = rest_get_server()->dispatch( $request );
    1814         $this->assertEquals( 200, $response->get_status() );
     1814        $this->assertSame( 200, $response->get_status() );
    18151815
    18161816        // Private status.
     
    18241824        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
    18251825        $response = rest_get_server()->dispatch( $request );
    1826         $this->assertEquals( 401, $response->get_status() );
     1826        $this->assertSame( 401, $response->get_status() );
    18271827    }
    18281828
     
    18461846        $obj      = get_post( self::$post_id );
    18471847        $response = $endpoint->prepare_item_for_response( $obj, $request );
    1848         $this->assertEquals(
     1848        $this->assertSame(
    18491849            array(
    18501850                'id',
     
    18791879        remove_filter( 'the_content', $filter_content );
    18801880
    1881         $this->assertEquals(
     1881        $this->assertSame(
    18821882            array(
    18831883                'id'      => self::$post_id,
     
    19151915        remove_filter( 'the_content', $filter_content );
    19161916
    1917         $this->assertEquals(
     1917        $this->assertSame(
    19181918            array(
    19191919                'id'      => $post->ID,
     
    20302030        update_option( 'timezone_string', '' );
    20312031
    2032         $this->assertEquals( 201, $response->get_status() );
     2032        $this->assertSame( 201, $response->get_status() );
    20332033        $data = $response->get_data();
    20342034        $post = get_post( $data['id'] );
    20352035
    2036         $this->assertEquals( $results['date'], $data['date'] );
     2036        $this->assertSame( $results['date'], $data['date'] );
    20372037        $post_date = str_replace( 'T', ' ', $results['date'] );
    2038         $this->assertEquals( $post_date, $post->post_date );
    2039 
    2040         $this->assertEquals( $results['date_gmt'], $data['date_gmt'] );
     2038        $this->assertSame( $post_date, $post->post_date );
     2039
     2040        $this->assertSame( $results['date_gmt'], $data['date_gmt'] );
    20412041        $post_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] );
    2042         $this->assertEquals( $post_date_gmt, $post->post_date_gmt );
     2042        $this->assertSame( $post_date_gmt, $post->post_date_gmt );
    20432043    }
    20442044
     
    20712071        remove_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) );
    20722072
    2073         $this->assertEquals( 'post-my-test-template.php', $data['template'] );
    2074         $this->assertEquals( 'post-my-test-template.php', $post_template );
     2073        $this->assertSame( 'post-my-test-template.php', $data['template'] );
     2074        $this->assertSame( 'post-my-test-template.php', $post_template );
    20752075    }
    20762076
     
    21142114        $post_template = get_page_template_slug( get_post( $data['id'] ) );
    21152115
    2116         $this->assertEquals( '', $data['template'] );
    2117         $this->assertEquals( '', $post_template );
     2116        $this->assertSame( '', $data['template'] );
     2117        $this->assertSame( '', $post_template );
    21182118    }
    21192119
     
    21612161        $request->set_body_params( $params );
    21622162        $response = rest_get_server()->dispatch( $request );
    2163         $this->assertEquals( 201, $response->get_status() );
     2163        $this->assertSame( 201, $response->get_status() );
    21642164
    21652165        $data = $response->get_data();
    21662166        $post = get_post( $data['id'] );
    2167         $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     2167        $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
    21682168        $this->assertNotEquals( '0000-00-00T00:00:00', $data['date_gmt'] );
    21692169
     
    21862186
    21872187        $new_data = $response->get_data();
    2188         $this->assertEquals( true, $new_data['sticky'] );
     2188        $this->assertTrue( $new_data['sticky'] );
    21892189        $post = get_post( $new_data['id'] );
    2190         $this->assertEquals( true, is_sticky( $post->ID ) );
     2190        $this->assertTrue( is_sticky( $post->ID ) );
    21912191    }
    21922192
     
    22512251        $data     = $response->get_data();
    22522252        $new_post = get_post( $data['id'] );
    2253         $this->assertEquals( 'draft', $data['status'] );
    2254         $this->assertEquals( 'draft', $new_post->post_status );
     2253        $this->assertSame( 'draft', $data['status'] );
     2254        $this->assertSame( 'draft', $new_post->post_status );
    22552255        // Confirm dates are shimmed for gmt_offset.
    22562256        $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) );
    22572257        $post_date_gmt     = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) );
    22582258
    2259         $this->assertEquals( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] );
    2260         $this->assertEquals( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] );
     2259        $this->assertSame( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] );
     2260        $this->assertSame( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] );
    22612261    }
    22622262
     
    22752275        $data     = $response->get_data();
    22762276        $new_post = get_post( $data['id'] );
    2277         $this->assertEquals( 'private', $data['status'] );
    2278         $this->assertEquals( 'private', $new_post->post_status );
     2277        $this->assertSame( 'private', $data['status'] );
     2278        $this->assertSame( 'private', $new_post->post_status );
    22792279    }
    22802280
     
    23512351        $data     = $response->get_data();
    23522352        $new_post = get_post( $data['id'] );
    2353         $this->assertEquals( 'gallery', $data['format'] );
    2354         $this->assertEquals( 'gallery', get_post_format( $new_post->ID ) );
     2353        $this->assertSame( 'gallery', $data['format'] );
     2354        $this->assertSame( 'gallery', get_post_format( $new_post->ID ) );
    23552355    }
    23562356
     
    23692369        $data     = $response->get_data();
    23702370        $new_post = get_post( $data['id'] );
    2371         $this->assertEquals( 'standard', $data['format'] );
     2371        $this->assertSame( 'standard', $data['format'] );
    23722372        $this->assertFalse( get_post_format( $new_post->ID ) );
    23732373    }
     
    24042404        $request->set_body_params( $params );
    24052405        $response = rest_get_server()->dispatch( $request );
    2406         $this->assertEquals( 201, $response->get_status() );
     2406        $this->assertSame( 201, $response->get_status() );
    24072407
    24082408        $data = $response->get_data();
    2409         $this->assertEquals( 'link', $data['format'] );
     2409        $this->assertSame( 'link', $data['format'] );
    24102410    }
    24112411
     
    24342434        $data     = $response->get_data();
    24352435        $new_post = get_post( $data['id'] );
    2436         $this->assertEquals( $this->attachment_id, $data['featured_media'] );
    2437         $this->assertEquals( $this->attachment_id, (int) get_post_thumbnail_id( $new_post->ID ) );
     2436        $this->assertSame( $this->attachment_id, $data['featured_media'] );
     2437        $this->assertSame( $this->attachment_id, (int) get_post_thumbnail_id( $new_post->ID ) );
    24382438
    24392439        $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . $new_post->ID );
     
    24462446        $response = rest_get_server()->dispatch( $request );
    24472447        $data     = $response->get_data();
    2448         $this->assertEquals( 0, $data['featured_media'] );
    2449         $this->assertEquals( 0, (int) get_post_thumbnail_id( $new_post->ID ) );
     2448        $this->assertSame( 0, $data['featured_media'] );
     2449        $this->assertSame( 0, (int) get_post_thumbnail_id( $new_post->ID ) );
    24502450    }
    24512451
     
    24932493
    24942494        $data = $response->get_data();
    2495         $this->assertEquals( 'testing', $data['password'] );
     2495        $this->assertSame( 'testing', $data['password'] );
    24962496    }
    24972497
     
    25092509
    25102510        $data = $response->get_data();
    2511         $this->assertEquals( '0', $data['password'] );
     2511        $this->assertSame( '0', $data['password'] );
    25122512    }
    25132513
     
    25252525        $response = rest_get_server()->dispatch( $request );
    25262526
    2527         $this->assertEquals( 201, $response->get_status() );
     2527        $this->assertSame( 201, $response->get_status() );
    25282528        $data = $response->get_data();
    2529         $this->assertEquals( '', $data['password'] );
     2529        $this->assertSame( '', $data['password'] );
    25302530    }
    25312531
     
    25612561        $new_post = get_post( $data['id'] );
    25622562        $time     = gmmktime( 2, 0, 0, 1, 1, 2010 );
    2563         $this->assertEquals( '2010-01-01T02:00:00', $data['date'] );
    2564         $this->assertEquals( $time, strtotime( $new_post->post_date ) );
     2563        $this->assertSame( '2010-01-01T02:00:00', $data['date'] );
     2564        $this->assertSame( $time, strtotime( $new_post->post_date ) );
    25652565    }
    25662566
     
    25812581        $time     = gmmktime( 12, 0, 0, 1, 1, 2010 );
    25822582
    2583         $this->assertEquals( '2010-01-01T12:00:00', $data['date'] );
    2584         $this->assertEquals( '2010-01-01T12:00:00', $data['modified'] );
    2585 
    2586         $this->assertEquals( $time, strtotime( $new_post->post_date ) );
    2587         $this->assertEquals( $time, strtotime( $new_post->post_modified ) );
     2583        $this->assertSame( '2010-01-01T12:00:00', $data['date'] );
     2584        $this->assertSame( '2010-01-01T12:00:00', $data['modified'] );
     2585
     2586        $this->assertSame( $time, strtotime( $new_post->post_date ) );
     2587        $this->assertSame( $time, strtotime( $new_post->post_modified ) );
    25882588    }
    25892589
     
    26532653
    26542654        $data = $response->get_data();
    2655         $this->assertEquals( "Rob O'Rourke's Diary", $data['title']['raw'] );
     2655        $this->assertSame( "Rob O'Rourke's Diary", $data['title']['raw'] );
    26562656    }
    26572657
     
    26742674
    26752675        $data = $response->get_data();
    2676         $this->assertEquals( array( $category['term_id'] ), $data['categories'] );
     2676        $this->assertSame( array( $category['term_id'] ), $data['categories'] );
    26772677    }
    26782678
     
    26932693
    26942694        $data = $response->get_data();
    2695         $this->assertEquals( array( $category['term_id'], $category2['term_id'] ), $data['categories'] );
     2695        $this->assertSame( array( $category['term_id'], $category2['term_id'] ), $data['categories'] );
    26962696    }
    26972697
     
    27122712
    27132713        $data = $response->get_data();
    2714         $this->assertEquals( array(), $data['categories'] );
     2714        $this->assertSame( array(), $data['categories'] );
    27152715    }
    27162716
     
    27582758        $this->check_update_post_response( $response );
    27592759        $new_data = $response->get_data();
    2760         $this->assertEquals( self::$post_id, $new_data['id'] );
    2761         $this->assertEquals( $params['title'], $new_data['title']['raw'] );
    2762         $this->assertEquals( $params['content'], $new_data['content']['raw'] );
    2763         $this->assertEquals( $params['excerpt'], $new_data['excerpt']['raw'] );
     2760        $this->assertSame( self::$post_id, $new_data['id'] );
     2761        $this->assertSame( $params['title'], $new_data['title']['raw'] );
     2762        $this->assertSame( $params['content'], $new_data['content']['raw'] );
     2763        $this->assertSame( $params['excerpt'], $new_data['excerpt']['raw'] );
    27642764        $post = get_post( self::$post_id );
    2765         $this->assertEquals( $params['title'], $post->post_title );
    2766         $this->assertEquals( $params['content'], $post->post_content );
    2767         $this->assertEquals( $params['excerpt'], $post->post_excerpt );
     2765        $this->assertSame( $params['title'], $post->post_title );
     2766        $this->assertSame( $params['content'], $post->post_content );
     2767        $this->assertSame( $params['excerpt'], $post->post_excerpt );
    27682768    }
    27692769
     
    27962796        $this->check_update_post_response( $response );
    27972797        $new_data = $response->get_data();
    2798         $this->assertEquals( self::$post_id, $new_data['id'] );
    2799         $this->assertEquals( $params['title'], $new_data['title']['raw'] );
    2800         $this->assertEquals( $params['content'], $new_data['content']['raw'] );
    2801         $this->assertEquals( $params['excerpt'], $new_data['excerpt']['raw'] );
     2798        $this->assertSame( self::$post_id, $new_data['id'] );
     2799        $this->assertSame( $params['title'], $new_data['title']['raw'] );
     2800        $this->assertSame( $params['content'], $new_data['content']['raw'] );
     2801        $this->assertSame( $params['excerpt'], $new_data['excerpt']['raw'] );
    28022802        $post = get_post( self::$post_id );
    2803         $this->assertEquals( $params['title'], $post->post_title );
    2804         $this->assertEquals( $params['content'], $post->post_content );
    2805         $this->assertEquals( $params['excerpt'], $post->post_excerpt );
     2803        $this->assertSame( $params['title'], $post->post_title );
     2804        $this->assertSame( $params['content'], $post->post_content );
     2805        $this->assertSame( $params['excerpt'], $post->post_excerpt );
    28062806    }
    28072807
     
    28382838
    28392839        // Verify the post is set to the future date.
    2840         $this->assertEquals( $new_data['date_gmt'], $future_date );
    2841         $this->assertEquals( $new_data['date'], $future_date );
     2840        $this->assertSame( $new_data['date_gmt'], $future_date );
     2841        $this->assertSame( $new_data['date'], $future_date );
    28422842        $this->assertNotEquals( $new_data['date_gmt'], $new_data['modified_gmt'] );
    28432843        $this->assertNotEquals( $new_data['date'], $new_data['modified'] );
     
    28592859        $this->check_update_post_response( $response );
    28602860        $new_data = $response->get_data();
    2861         $this->assertEquals( $new_data['date_gmt'], $new_data['date'] );
     2861        $this->assertSame( $new_data['date_gmt'], $new_data['date'] );
    28622862        $this->assertNotEquals( $new_data['date_gmt'], $future_date );
    28632863
    28642864        $post = get_post( $post_id, 'ARRAY_A' );
    2865         $this->assertEquals( $post['post_date_gmt'], '0000-00-00 00:00:00' );
     2865        $this->assertSame( $post['post_date_gmt'], '0000-00-00 00:00:00' );
    28662866        $this->assertNotEquals( $new_data['date_gmt'], $future_date );
    28672867        $this->assertNotEquals( $new_data['date'], $future_date );
     
    28792879        $this->check_update_post_response( $response );
    28802880        $new_data = $response->get_data();
    2881         $this->assertEquals( self::$post_id, $new_data['id'] );
    2882         $this->assertEquals( $params['title']['raw'], $new_data['title']['raw'] );
    2883         $this->assertEquals( $params['content']['raw'], $new_data['content']['raw'] );
    2884         $this->assertEquals( $params['excerpt']['raw'], $new_data['excerpt']['raw'] );
     2881        $this->assertSame( self::$post_id, $new_data['id'] );
     2882        $this->assertSame( $params['title']['raw'], $new_data['title']['raw'] );
     2883        $this->assertSame( $params['content']['raw'], $new_data['content']['raw'] );
     2884        $this->assertSame( $params['excerpt']['raw'], $new_data['excerpt']['raw'] );
    28852885        $post = get_post( self::$post_id );
    2886         $this->assertEquals( $params['title']['raw'], $post->post_title );
    2887         $this->assertEquals( $params['content']['raw'], $post->post_content );
    2888         $this->assertEquals( $params['excerpt']['raw'], $post->post_excerpt );
     2886        $this->assertSame( $params['title']['raw'], $post->post_title );
     2887        $this->assertSame( $params['content']['raw'], $post->post_content );
     2888        $this->assertSame( $params['excerpt']['raw'], $post->post_excerpt );
    28892889    }
    28902890
     
    29692969        $data     = $response->get_data();
    29702970        $new_post = get_post( $data['id'] );
    2971         $this->assertEquals( 'gallery', $data['format'] );
    2972         $this->assertEquals( 'gallery', get_post_format( $new_post->ID ) );
     2971        $this->assertSame( 'gallery', $data['format'] );
     2972        $this->assertSame( 'gallery', get_post_format( $new_post->ID ) );
    29732973    }
    29742974
     
    29872987        $data     = $response->get_data();
    29882988        $new_post = get_post( $data['id'] );
    2989         $this->assertEquals( 'standard', $data['format'] );
     2989        $this->assertSame( 'standard', $data['format'] );
    29902990        $this->assertFalse( get_post_format( $new_post->ID ) );
    29912991    }
     
    30223022        $request->set_body_params( $params );
    30233023        $response = rest_get_server()->dispatch( $request );
    3024         $this->assertEquals( 200, $response->get_status() );
     3024        $this->assertSame( 200, $response->get_status() );
    30253025
    30263026        $data = $response->get_data();
    3027         $this->assertEquals( 'link', $data['format'] );
     3027        $this->assertSame( 'link', $data['format'] );
    30283028    }
    30293029
     
    30483048        $new_post = get_post( $data['id'] );
    30493049
    3050         $this->assertEquals( $new_content, $data['content']['raw'] );
    3051         $this->assertEquals( $new_content, $new_post->post_content );
     3050        $this->assertSame( $new_content, $data['content']['raw'] );
     3051        $this->assertSame( $new_content, $new_post->post_content );
    30523052
    30533053        // The modified date should equal the current time.
    3054         $this->assertEquals( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) );
    3055         $this->assertEquals( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) );
     3054        $this->assertSame( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) );
     3055        $this->assertSame( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) );
    30563056    }
    30573057
     
    30773077        update_option( 'timezone_string', '' );
    30783078
    3079         $this->assertEquals( 200, $response->get_status() );
     3079        $this->assertSame( 200, $response->get_status() );
    30803080        $data = $response->get_data();
    30813081        $post = get_post( $data['id'] );
    30823082
    3083         $this->assertEquals( $results['date'], $data['date'] );
     3083        $this->assertSame( $results['date'], $data['date'] );
    30843084        $post_date = str_replace( 'T', ' ', $results['date'] );
    3085         $this->assertEquals( $post_date, $post->post_date );
    3086 
    3087         $this->assertEquals( $results['date_gmt'], $data['date_gmt'] );
     3085        $this->assertSame( $post_date, $post->post_date );
     3086
     3087        $this->assertSame( $results['date_gmt'], $data['date_gmt'] );
    30883088        $post_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] );
    3089         $this->assertEquals( $post_date_gmt, $post->post_date_gmt );
     3089        $this->assertSame( $post_date_gmt, $post->post_date_gmt );
    30903090    }
    30913091
     
    31453145
    31463146        $post = get_post( $post_id );
    3147         $this->assertEquals( $post->post_date, '2016-02-23 12:00:00' );
    3148         $this->assertEquals( $post->post_date_gmt, '0000-00-00 00:00:00' );
     3147        $this->assertSame( $post->post_date, '2016-02-23 12:00:00' );
     3148        $this->assertSame( $post->post_date_gmt, '0000-00-00 00:00:00' );
    31493149
    31503150        $request  = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $post_id ) );
    31513151        $response = rest_get_server()->dispatch( $request );
    3152         $this->assertEquals( 200, $response->get_status() );
     3152        $this->assertSame( 200, $response->get_status() );
    31533153        $data = $response->get_data();
    31543154
    3155         $this->assertEquals( '2016-02-23T12:00:00', $data['date'] );
    3156         $this->assertEquals( '2016-02-23T18:00:00', $data['date_gmt'] );
     3155        $this->assertSame( '2016-02-23T12:00:00', $data['date'] );
     3156        $this->assertSame( '2016-02-23T18:00:00', $data['date_gmt'] );
    31573157
    31583158        $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $post_id ) );
    31593159        $request->set_param( 'date', '2016-02-23T13:00:00' );
    31603160        $response = rest_get_server()->dispatch( $request );
    3161         $this->assertEquals( 200, $response->get_status() );
     3161        $this->assertSame( 200, $response->get_status() );
    31623162        $data = $response->get_data();
    31633163
    3164         $this->assertEquals( '2016-02-23T13:00:00', $data['date'] );
    3165         $this->assertEquals( '2016-02-23T19:00:00', $data['date_gmt'] );
     3164        $this->assertSame( '2016-02-23T13:00:00', $data['date'] );
     3165        $this->assertSame( '2016-02-23T19:00:00', $data['date_gmt'] );
    31663166
    31673167        $post = get_post( $post_id );
    3168         $this->assertEquals( $post->post_date, '2016-02-23 13:00:00' );
    3169         $this->assertEquals( $post->post_date_gmt, '2016-02-23 19:00:00' );
     3168        $this->assertSame( $post->post_date, '2016-02-23 13:00:00' );
     3169        $this->assertSame( $post->post_date_gmt, '2016-02-23 19:00:00' );
    31703170
    31713171        update_option( 'timezone_string', '' );
     
    31853185
    31863186        $new_data = $response->get_data();
    3187         $this->assertEquals( 'sample-slug', $new_data['slug'] );
     3187        $this->assertSame( 'sample-slug', $new_data['slug'] );
    31883188        $post = get_post( $new_data['id'] );
    3189         $this->assertEquals( 'sample-slug', $post->post_name );
     3189        $this->assertSame( 'sample-slug', $post->post_name );
    31903190    }
    31913191
     
    32033203
    32043204        $new_data = $response->get_data();
    3205         $this->assertEquals( 'test-accented-charaecters', $new_data['slug'] );
     3205        $this->assertSame( 'test-accented-charaecters', $new_data['slug'] );
    32063206        $post = get_post( $new_data['id'] );
    3207         $this->assertEquals( 'test-accented-charaecters', $post->post_name );
     3207        $this->assertSame( 'test-accented-charaecters', $post->post_name );
    32083208    }
    32093209
     
    32213221
    32223222        $new_data = $response->get_data();
    3223         $this->assertEquals( true, $new_data['sticky'] );
     3223        $this->assertTrue( $new_data['sticky'] );
    32243224        $post = get_post( $new_data['id'] );
    3225         $this->assertEquals( true, is_sticky( $post->ID ) );
     3225        $this->assertTrue( is_sticky( $post->ID ) );
    32263226
    32273227        // Updating another field shouldn't change sticky status.
     
    32363236
    32373237        $new_data = $response->get_data();
    3238         $this->assertEquals( true, $new_data['sticky'] );
     3238        $this->assertTrue( $new_data['sticky'] );
    32393239        $post = get_post( $new_data['id'] );
    3240         $this->assertEquals( true, is_sticky( $post->ID ) );
     3240        $this->assertTrue( is_sticky( $post->ID ) );
    32413241    }
    32423242
     
    32533253        $response = rest_get_server()->dispatch( $request );
    32543254        $new_data = $response->get_data();
    3255         $this->assertEquals( 'An Excerpt', $new_data['excerpt']['raw'] );
     3255        $this->assertSame( 'An Excerpt', $new_data['excerpt']['raw'] );
    32563256    }
    32573257
     
    32683268        $response = rest_get_server()->dispatch( $request );
    32693269        $new_data = $response->get_data();
    3270         $this->assertEquals( '', $new_data['excerpt']['raw'] );
     3270        $this->assertSame( '', $new_data['excerpt']['raw'] );
    32713271    }
    32723272
     
    32833283        $response = rest_get_server()->dispatch( $request );
    32843284        $new_data = $response->get_data();
    3285         $this->assertEquals( 'Some Content', $new_data['content']['raw'] );
     3285        $this->assertSame( 'Some Content', $new_data['content']['raw'] );
    32863286    }
    32873287
     
    32983298        $response = rest_get_server()->dispatch( $request );
    32993299        $new_data = $response->get_data();
    3300         $this->assertEquals( '', $new_data['content']['raw'] );
     3300        $this->assertSame( '', $new_data['content']['raw'] );
    33013301    }
    33023302
     
    33203320        $response = rest_get_server()->dispatch( $request );
    33213321        $data     = $response->get_data();
    3322         $this->assertEquals( '', $data['password'] );
     3322        $this->assertSame( '', $data['password'] );
    33233323    }
    33243324
     
    33903390        $response = rest_get_server()->dispatch( $request );
    33913391        $new_data = $response->get_data();
    3392         $this->assertEquals( "Rob O'Rourke's Diary", $new_data['title']['raw'] );
     3392        $this->assertSame( "Rob O'Rourke's Diary", $new_data['title']['raw'] );
    33933393    }
    33943394
     
    34103410        $response = rest_get_server()->dispatch( $request );
    34113411        $new_data = $response->get_data();
    3412         $this->assertEquals( array( $category['term_id'] ), $new_data['categories'] );
     3412        $this->assertSame( array( $category['term_id'] ), $new_data['categories'] );
    34133413        $categories_path = '';
    34143414        $links           = $response->get_links();
     
    34273427        $data     = $response->get_data();
    34283428        $this->assertCount( 1, $data );
    3429         $this->assertEquals( 'Test Category', $data[0]['name'] );
     3429        $this->assertSame( 'Test Category', $data[0]['name'] );
    34303430    }
    34313431
     
    34463446        $response = rest_get_server()->dispatch( $request );
    34473447        $new_data = $response->get_data();
    3448         $this->assertEquals( array(), $new_data['categories'] );
     3448        $this->assertSame( array(), $new_data['categories'] );
    34493449    }
    34503450
     
    35003500        $post_template = get_page_template_slug( get_post( $data['id'] ) );
    35013501
    3502         $this->assertEquals( 'post-my-test-template.php', $data['template'] );
    3503         $this->assertEquals( 'post-my-test-template.php', $post_template );
     3502        $this->assertSame( 'post-my-test-template.php', $data['template'] );
     3503        $this->assertSame( 'post-my-test-template.php', $post_template );
    35043504    }
    35053505
     
    35313531        $post_template = get_page_template_slug( get_post( $data['id'] ) );
    35323532
    3533         $this->assertEquals( '', $data['template'] );
    3534         $this->assertEquals( '', $post_template );
     3533        $this->assertSame( '', $data['template'] );
     3534        $this->assertSame( '', $post_template );
    35353535    }
    35363536
     
    35553555        $response = rest_get_server()->dispatch( $request );
    35563556
    3557         $this->assertEquals( 200, $response->get_status() );
     3557        $this->assertSame( 200, $response->get_status() );
    35583558
    35593559        $data          = $response->get_data();
    35603560        $post_template = get_page_template_slug( get_post( $data['id'] ) );
    35613561
    3562         $this->assertEquals( 'post-my-invalid-template.php', $post_template );
    3563         $this->assertEquals( 'post-my-invalid-template.php', $data['template'] );
     3562        $this->assertSame( 'post-my-invalid-template.php', $post_template );
     3563        $this->assertSame( 'post-my-invalid-template.php', $data['template'] );
    35643564    }
    35653565
     
    35713571        }
    35723572        $response = rest_get_server()->dispatch( $request );
    3573         $this->assertEquals( 201, $response->get_status() );
     3573        $this->assertSame( 201, $response->get_status() );
    35743574        $actual_output = $response->get_data();
    35753575
    35763576        // Compare expected API output to actual API output.
    3577         $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] );
    3578         $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );
    3579         $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] );
    3580         $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );
    3581         $this->assertEquals( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] );
    3582         $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );
     3577        $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] );
     3578        $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );
     3579        $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] );
     3580        $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );
     3581        $this->assertSame( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] );
     3582        $this->assertSame( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );
    35833583
    35843584        // Compare expected API output to WP internal values.
    35853585        $post = get_post( $actual_output['id'] );
    3586         $this->assertEquals( $expected_output['title']['raw'], $post->post_title );
    3587         $this->assertEquals( $expected_output['content']['raw'], $post->post_content );
    3588         $this->assertEquals( $expected_output['excerpt']['raw'], $post->post_excerpt );
     3586        $this->assertSame( $expected_output['title']['raw'], $post->post_title );
     3587        $this->assertSame( $expected_output['content']['raw'], $post->post_content );
     3588        $this->assertSame( $expected_output['excerpt']['raw'], $post->post_excerpt );
    35893589
    35903590        // Update the post.
     
    35943594        }
    35953595        $response = rest_get_server()->dispatch( $request );
    3596         $this->assertEquals( 200, $response->get_status() );
     3596        $this->assertSame( 200, $response->get_status() );
    35973597        $actual_output = $response->get_data();
    35983598
    35993599        // Compare expected API output to actual API output.
    3600         $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] );
    3601         $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );
    3602         $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] );
    3603         $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );
    3604         $this->assertEquals( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] );
    3605         $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );
     3600        $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] );
     3601        $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );
     3602        $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] );
     3603        $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );
     3604        $this->assertSame( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] );
     3605        $this->assertSame( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );
    36063606
    36073607        // Compare expected API output to WP internal values.
    36083608        $post = get_post( $actual_output['id'] );
    3609         $this->assertEquals( $expected_output['title']['raw'], $post->post_title );
    3610         $this->assertEquals( $expected_output['content']['raw'], $post->post_content );
    3611         $this->assertEquals( $expected_output['excerpt']['raw'], $post->post_excerpt );
     3609        $this->assertSame( $expected_output['title']['raw'], $post->post_title );
     3610        $this->assertSame( $expected_output['content']['raw'], $post->post_content );
     3611        $this->assertSame( $expected_output['excerpt']['raw'], $post->post_excerpt );
    36123612    }
    36133613
     
    38073807        $response = rest_get_server()->dispatch( $request );
    38083808
    3809         $this->assertEquals( 200, $response->get_status() );
     3809        $this->assertSame( 200, $response->get_status() );
    38103810        $data = $response->get_data();
    3811         $this->assertEquals( 'Deleted post', $data['title']['raw'] );
    3812         $this->assertEquals( 'trash', $data['status'] );
     3811        $this->assertSame( 'Deleted post', $data['title']['raw'] );
     3812        $this->assertSame( 'trash', $data['status'] );
    38133813    }
    38143814
     
    38223822        $response         = rest_get_server()->dispatch( $request );
    38233823
    3824         $this->assertEquals( 200, $response->get_status() );
     3824        $this->assertSame( 200, $response->get_status() );
    38253825        $data = $response->get_data();
    38263826        $this->assertTrue( $data['deleted'] );
     
    38353835        $request  = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) );
    38363836        $response = rest_get_server()->dispatch( $request );
    3837         $this->assertEquals( 200, $response->get_status() );
     3837        $this->assertSame( 200, $response->get_status() );
    38383838        $response = rest_get_server()->dispatch( $request );
    38393839        $this->assertErrorResponse( 'rest_already_trashed', $response, 410 );
     
    38903890        $data       = $response->get_data();
    38913891        $properties = $data['schema']['properties'];
    3892         $this->assertEquals( 26, count( $properties ) );
     3892        $this->assertSame( 26, count( $properties ) );
    38933893        $this->assertArrayHasKey( 'author', $properties );
    38943894        $this->assertArrayHasKey( 'comment_status', $properties );
     
    39693969        );
    39703970
    3971         $this->assertEquals( $expected_keys, $keys );
     3971        $this->assertSame( $expected_keys, $keys );
    39723972    }
    39733973
     
    40104010        );
    40114011
    4012         $this->assertEquals( $expected_keys, $keys );
     4012        $this->assertSame( $expected_keys, $keys );
    40134013    }
    40144014
     
    40324032        );
    40334033
    4034         $this->assertEquals( $expected_keys, $keys );
     4034        $this->assertSame( $expected_keys, $keys );
    40354035    }
    40364036
     
    40414041        $list_posts_args = $data['routes']['/wp/v2/posts']['endpoints'][0]['args'];
    40424042        $status_arg      = $list_posts_args['status'];
    4043         $this->assertEquals( 'array', $status_arg['type'] );
    4044         $this->assertEquals(
    4045             array(
    4046                 'type' => 'string',
     4043        $this->assertSame( 'array', $status_arg['type'] );
     4044        $this->assertSame(
     4045            array(
    40474046                'enum' => array(
    40484047                    'publish',
     
    40604059                    'any',
    40614060                ),
     4061                'type' => 'string',
    40624062            ),
    40634063            $status_arg['items']
     
    40894089
    40904090        $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
    4091         $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] );
     4091        $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
    40924092
    40934093        wp_set_current_user( 1 );
     
    45724572        $response = rest_get_server()->dispatch( $request );
    45734573        $data     = $response->get_data();
    4574         $this->assertEquals( 200, $response->get_status() );
     4574        $this->assertSame( 200, $response->get_status() );
    45754575        $this->assertArrayNotHasKey( 'permalink_template', $data );
    45764576        $this->assertArrayNotHasKey( 'generated_slug', $data );
     
    45964596        $response = rest_get_server()->dispatch( $request );
    45974597        $data     = $response->get_data();
    4598         $this->assertEquals( 200, $response->get_status() );
    4599         $this->assertEquals( $expected_permalink_template, $data['permalink_template'] );
    4600         $this->assertEquals( 'permalink-template', $data['generated_slug'] );
     4598        $this->assertSame( 200, $response->get_status() );
     4599        $this->assertSame( $expected_permalink_template, $data['permalink_template'] );
     4600        $this->assertSame( 'permalink-template', $data['generated_slug'] );
    46014601
    46024602        // Neither 'permalink_template' and 'generated_slug' are expected for context=view.
     
    46054605        $response = rest_get_server()->dispatch( $request );
    46064606        $data     = $response->get_data();
    4607         $this->assertEquals( 200, $response->get_status() );
     4607        $this->assertSame( 200, $response->get_status() );
    46084608        $this->assertArrayNotHasKey( 'permalink_template', $data );
    46094609        $this->assertArrayNotHasKey( 'generated_slug', $data );
     
    46264626        );
    46274627
    4628         $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     4628        $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
    46294629
    46304630        $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" );
     
    46434643        $this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 );
    46444644
    4645         $this->assertEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
     4645        $this->assertSame( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
    46464646    }
    46474647
     
    46624662        );
    46634663
    4664         $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     4664        $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
    46654665
    46664666        $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" );
     
    47034703        );
    47044704
    4705         $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     4705        $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
    47064706
    47074707        $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" );
     
    48604860
    48614861        $this->assertArrayHasKey( 'new_prop', $properties );
    4862         $this->assertEquals( array( 'new_context' ), $properties['new_prop']['context'] );
     4862        $this->assertSame( array( 'new_context' ), $properties['new_prop']['context'] );
    48634863    }
    48644864
Note: See TracChangeset for help on using the changeset viewer.