Changeset 50283
- Timestamp:
- 02/10/2021 01:23:42 PM (4 years ago)
- Location:
- trunk/tests/phpunit/includes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase-canonical.php
r49603 r50283 309 309 // Just test the path and query if present. 310 310 if ( isset( $expected['url'] ) ) { 311 $this->assert Equals( $expected['url'], $parsed_can_url['path'] . ( ! empty( $parsed_can_url['query'] ) ? '?' . $parsed_can_url['query'] : '' ), $ticket_ref );311 $this->assertSame( $expected['url'], $parsed_can_url['path'] . ( ! empty( $parsed_can_url['query'] ) ? '?' . $parsed_can_url['query'] : '' ), $ticket_ref ); 312 312 } 313 313 … … 329 329 // $_qv should not contain any elements which are set in $query_vars already 330 330 // (i.e. $_GET vars should not be present in the Rewrite). 331 $this->assert Equals( array(), array_intersect( $query_vars, $_qv ), 'Query vars are duplicated from the Rewrite into $_GET; ' . $ticket_ref );331 $this->assertSame( array(), array_intersect( $query_vars, $_qv ), 'Query vars are duplicated from the Rewrite into $_GET; ' . $ticket_ref ); 332 332 333 333 $query_vars = array_merge( $query_vars, $_qv ); -
trunk/tests/phpunit/includes/testcase-rest-api.php
r49606 r50283 9 9 10 10 $this->assertWPError( $response ); 11 $this->assert Equals( $code, $response->get_error_code() );11 $this->assertSame( $code, $response->get_error_code() ); 12 12 13 13 if ( null !== $status ) { 14 14 $data = $response->get_error_data(); 15 15 $this->assertArrayHasKey( 'status', $data ); 16 $this->assert Equals( $status, $data['status'] );16 $this->assertSame( $status, $data['status'] ); 17 17 } 18 18 } -
trunk/tests/phpunit/includes/testcase-rest-post-type-controller.php
r47122 r50283 7 7 8 8 // Standard fields. 9 $this->assert Equals( $post->ID, $data['id'] );10 $this->assert Equals( $post->post_name, $data['slug'] );11 $this->assert Equals( get_permalink( $post->ID ), $data['link'] );9 $this->assertSame( $post->ID, $data['id'] ); 10 $this->assertSame( $post->post_name, $data['slug'] ); 11 $this->assertSame( get_permalink( $post->ID ), $data['link'] ); 12 12 if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { 13 13 $post_date_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) ); 14 $this->assert Equals( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] );15 } else { 16 $this->assert Equals( mysql_to_rfc3339( $post->post_date_gmt ), $data['date_gmt'] );17 } 18 $this->assert Equals( mysql_to_rfc3339( $post->post_date ), $data['date'] );14 $this->assertSame( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] ); 15 } else { 16 $this->assertSame( mysql_to_rfc3339( $post->post_date_gmt ), $data['date_gmt'] ); 17 } 18 $this->assertSame( mysql_to_rfc3339( $post->post_date ), $data['date'] ); 19 19 20 20 if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { 21 21 $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); 22 $this->assert Equals( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] );23 } else { 24 $this->assert Equals( mysql_to_rfc3339( $post->post_modified_gmt ), $data['modified_gmt'] );25 } 26 $this->assert Equals( mysql_to_rfc3339( $post->post_modified ), $data['modified'] );22 $this->assertSame( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] ); 23 } else { 24 $this->assertSame( mysql_to_rfc3339( $post->post_modified_gmt ), $data['modified_gmt'] ); 25 } 26 $this->assertSame( mysql_to_rfc3339( $post->post_modified ), $data['modified'] ); 27 27 28 28 // Author. … … 38 38 if ( $post->post_parent ) { 39 39 if ( is_int( $data['parent'] ) ) { 40 $this->assert Equals( $post->post_parent, $data['parent'] );40 $this->assertSame( $post->post_parent, $data['parent'] ); 41 41 } else { 42 $this->assert Equals( $post->post_parent, $data['parent']['id'] );42 $this->assertSame( $post->post_parent, $data['parent']['id'] ); 43 43 $this->check_get_post_response( $data['parent'], get_post( $data['parent']['id'] ), 'view-parent' ); 44 44 } … … 52 52 // Page attributes. 53 53 if ( $post_type_obj->hierarchical && post_type_supports( $post->post_type, 'page-attributes' ) ) { 54 $this->assert Equals( $post->menu_order, $data['menu_order'] );54 $this->assertSame( $post->menu_order, $data['menu_order'] ); 55 55 } else { 56 56 $this->assertFalse( isset( $data['menu_order'] ) ); … … 59 59 // Comments. 60 60 if ( post_type_supports( $post->post_type, 'comments' ) ) { 61 $this->assert Equals( $post->comment_status, $data['comment_status'] );62 $this->assert Equals( $post->ping_status, $data['ping_status'] );61 $this->assertSame( $post->comment_status, $data['comment_status'] ); 62 $this->assertSame( $post->ping_status, $data['ping_status'] ); 63 63 } else { 64 64 $this->assertFalse( isset( $data['comment_status'] ) ); … … 67 67 68 68 if ( 'post' === $post->post_type ) { 69 $this->assert Equals( is_sticky( $post->ID ), $data['sticky'] );69 $this->assertSame( is_sticky( $post->ID ), $data['sticky'] ); 70 70 } 71 71 72 72 if ( 'post' === $post->post_type && 'edit' === $context ) { 73 $this->assert Equals( $post->post_password, $data['password'] );73 $this->assertSame( $post->post_password, $data['password'] ); 74 74 } 75 75 76 76 if ( 'page' === $post->post_type ) { 77 $this->assert Equals( get_page_template_slug( $post->ID ), $data['template'] );77 $this->assertSame( get_page_template_slug( $post->ID ), $data['template'] ); 78 78 } 79 79 80 80 if ( post_type_supports( $post->post_type, 'thumbnail' ) ) { 81 $this->assert Equals( (int) get_post_thumbnail_id( $post->ID ), $data['featured_media'] );81 $this->assertSame( (int) get_post_thumbnail_id( $post->ID ), $data['featured_media'] ); 82 82 } else { 83 83 $this->assertFalse( isset( $data['featured_media'] ) ); … … 88 88 $post_format = get_post_format( $post->ID ); 89 89 if ( empty( $post_format ) ) { 90 $this->assert Equals( 'standard', $data['format'] );91 } else { 92 $this->assert Equals( get_post_format( $post->ID ), $data['format'] );90 $this->assertSame( 'standard', $data['format'] ); 91 } else { 92 $this->assertSame( get_post_format( $post->ID ), $data['format'] ); 93 93 } 94 94 } else { … … 99 99 if ( post_type_supports( $post->post_type, 'title' ) ) { 100 100 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 101 $this->assert Equals( get_the_title( $post->ID ), $data['title']['rendered'] );101 $this->assertSame( get_the_title( $post->ID ), $data['title']['rendered'] ); 102 102 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 103 103 if ( 'edit' === $context ) { 104 $this->assert Equals( $post->post_title, $data['title']['raw'] );104 $this->assertSame( $post->post_title, $data['title']['raw'] ); 105 105 } else { 106 106 $this->assertFalse( isset( $data['title']['raw'] ) ); … … 113 113 // TODO: Apply content filter for more accurate testing. 114 114 if ( ! $post->post_password ) { 115 $this->assert Equals( wpautop( $post->post_content ), $data['content']['rendered'] );115 $this->assertSame( wpautop( $post->post_content ), $data['content']['rendered'] ); 116 116 } 117 117 118 118 if ( 'edit' === $context ) { 119 $this->assert Equals( $post->post_content, $data['content']['raw'] );119 $this->assertSame( $post->post_content, $data['content']['raw'] ); 120 120 } else { 121 121 $this->assertFalse( isset( $data['content']['raw'] ) ); … … 128 128 if ( empty( $post->post_password ) ) { 129 129 // TODO: Apply excerpt filter for more accurate testing. 130 $this->assert Equals( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] );130 $this->assertSame( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] ); 131 131 } else { 132 132 // TODO: Better testing for excerpts for password protected posts. 133 133 } 134 134 if ( 'edit' === $context ) { 135 $this->assert Equals( $post->post_excerpt, $data['excerpt']['raw'] );135 $this->assertSame( $post->post_excerpt, $data['excerpt']['raw'] ); 136 136 } else { 137 137 $this->assertFalse( isset( $data['excerpt']['raw'] ) ); … … 141 141 } 142 142 143 $this->assert Equals( $post->post_status, $data['status'] );144 $this->assert Equals( $post->guid, $data['guid']['rendered'] );143 $this->assertSame( $post->post_status, $data['status'] ); 144 $this->assertSame( $post->guid, $data['guid']['rendered'] ); 145 145 146 146 if ( 'edit' === $context ) { 147 $this->assert Equals( $post->guid, $data['guid']['raw'] );147 $this->assertSame( $post->guid, $data['guid']['raw'] ); 148 148 } 149 149 … … 154 154 sort( $terms ); 155 155 sort( $data[ $taxonomy->rest_base ] ); 156 $this->assert Equals( $terms, $data[ $taxonomy->rest_base ] );156 $this->assertSame( $terms, $data[ $taxonomy->rest_base ] ); 157 157 } 158 158 … … 162 162 $links = test_rest_expand_compact_links( $links ); 163 163 $post_type = get_post_type_object( $data['type'] ); 164 $this->assert Equals( $links['self'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base . '/' . $data['id'] ) );165 $this->assert Equals( $links['collection'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base ) );166 $this->assert Equals( $links['about'][0]['href'], rest_url( 'wp/v2/types/' . $data['type'] ) );164 $this->assertSame( $links['self'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base . '/' . $data['id'] ) ); 165 $this->assertSame( $links['collection'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base ) ); 166 $this->assertSame( $links['about'][0]['href'], rest_url( 'wp/v2/types/' . $data['type'] ) ); 167 167 168 168 if ( post_type_supports( $post->post_type, 'author' ) && $data['author'] ) { 169 $this->assert Equals( $links['author'][0]['href'], rest_url( 'wp/v2/users/' . $data['author'] ) );169 $this->assertSame( $links['author'][0]['href'], rest_url( 'wp/v2/users/' . $data['author'] ) ); 170 170 } 171 171 172 172 if ( post_type_supports( $post->post_type, 'comments' ) ) { 173 $this->assert Equals( $links['replies'][0]['href'], add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/comments' ) ) );173 $this->assertSame( $links['replies'][0]['href'], add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/comments' ) ) ); 174 174 } 175 175 176 176 if ( post_type_supports( $post->post_type, 'revisions' ) ) { 177 $this->assert Equals( $links['version-history'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base . '/' . $data['id'] . '/revisions' ) );177 $this->assertSame( $links['version-history'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base . '/' . $data['id'] . '/revisions' ) ); 178 178 } 179 179 180 180 if ( $post_type->hierarchical && ! empty( $data['parent'] ) ) { 181 $this->assert Equals( $links['up'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base . '/' . $data['parent'] ) );181 $this->assertSame( $links['up'][0]['href'], rest_url( 'wp/v2/' . $post_type->rest_base . '/' . $data['parent'] ) ); 182 182 } 183 183 184 184 if ( ! in_array( $data['type'], array( 'attachment', 'nav_menu_item', 'revision' ), true ) ) { 185 $this->assert Equals( $links['https://api.w.org/attachment'][0]['href'], add_query_arg( 'parent', $data['id'], rest_url( 'wp/v2/media' ) ) );185 $this->assertSame( $links['https://api.w.org/attachment'][0]['href'], add_query_arg( 'parent', $data['id'], rest_url( 'wp/v2/media' ) ) ); 186 186 } 187 187 188 188 if ( ! empty( $data['featured_media'] ) ) { 189 $this->assert Equals( $links['https://api.w.org/featuredmedia'][0]['href'], rest_url( 'wp/v2/media/' . $data['featured_media'] ) );189 $this->assertSame( $links['https://api.w.org/featuredmedia'][0]['href'], rest_url( 'wp/v2/media/' . $data['featured_media'] ) ); 190 190 } 191 191 192 192 $num = 0; 193 193 foreach ( $taxonomies as $key => $taxonomy ) { 194 $this->assert Equals( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] );195 $this->assert Equals( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] );194 $this->assertSame( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] ); 195 $this->assertSame( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] ); 196 196 $num++; 197 197 } … … 203 203 $this->assertNotWPError( $response ); 204 204 $response = rest_ensure_response( $response ); 205 $this->assert Equals( 200, $response->get_status() );205 $this->assertSame( 200, $response->get_status() ); 206 206 207 207 $headers = $response->get_headers(); … … 236 236 $this->assertNotWPError( $response ); 237 237 $response = rest_ensure_response( $response ); 238 $this->assert Equals( 200, $response->get_status() );238 $this->assertSame( 200, $response->get_status() ); 239 239 240 240 $data = $response->get_data(); … … 248 248 $response = rest_ensure_response( $response ); 249 249 250 $this->assert Equals( 201, $response->get_status() );250 $this->assertSame( 201, $response->get_status() ); 251 251 $headers = $response->get_headers(); 252 252 $this->assertArrayHasKey( 'Location', $headers ); … … 261 261 $response = rest_ensure_response( $response ); 262 262 263 $this->assert Equals( 200, $response->get_status() );263 $this->assertSame( 200, $response->get_status() ); 264 264 $headers = $response->get_headers(); 265 265 $this->assertArrayNotHasKey( 'Location', $headers ); -
trunk/tests/phpunit/includes/testcase-xml.php
r48072 r50283 70 70 */ 71 71 public function assertXMLEquals( $expectedXml, $actualXml, $message = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase 72 $this->assert Equals( $this->normalizeXML( $expectedXml ), $this->normalizeXML( $actualXml ), $message ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase72 $this->assertSame( $this->normalizeXML( $expectedXml ), $this->normalizeXML( $actualXml ), $message ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase 73 73 } 74 74
Note: See TracChangeset
for help on using the changeset viewer.