- Timestamp:
- 09/02/2020 12:35:36 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php
r47122 r48937 23 23 $response = rest_get_server()->dispatch( $request ); 24 24 $data = $response->get_data(); 25 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );25 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 26 26 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 27 27 // Single. … … 29 29 $response = rest_get_server()->dispatch( $request ); 30 30 $data = $response->get_data(); 31 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );31 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 32 32 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 33 33 } … … 39 39 $data = $response->get_data(); 40 40 $post_types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); 41 $this->assert Equals( count( $post_types ), count( $data ) );42 $this->assert Equals( $post_types['post']->name, $data['post']['slug'] );41 $this->assertSame( count( $post_types ), count( $data ) ); 42 $this->assertSame( $post_types['post']->name, $data['post']['slug'] ); 43 43 $this->check_post_type_obj( 'view', $post_types['post'], $data['post'], $data['post']['_links'] ); 44 $this->assert Equals( $post_types['page']->name, $data['page']['slug'] );44 $this->assertSame( $post_types['page']->name, $data['page']['slug'] ); 45 45 $this->check_post_type_obj( 'view', $post_types['page'], $data['page'], $data['page']['_links'] ); 46 46 $this->assertFalse( isset( $data['revision'] ) ); … … 60 60 $this->check_post_type_object_response( 'view', $response ); 61 61 $data = $response->get_data(); 62 $this->assert Equals( array( 'category', 'post_tag' ), $data['taxonomies'] );62 $this->assertSame( array( 'category', 'post_tag' ), $data['taxonomies'] ); 63 63 } 64 64 … … 68 68 $this->check_post_type_object_response( 'view', $response, 'page' ); 69 69 $data = $response->get_data(); 70 $this->assert Equals( array(), $data['taxonomies'] );70 $this->assertSame( array(), $data['taxonomies'] ); 71 71 } 72 72 … … 98 98 $request = new WP_REST_Request( 'POST', '/wp/v2/types' ); 99 99 $response = rest_get_server()->dispatch( $request ); 100 $this->assert Equals( 404, $response->get_status() );100 $this->assertSame( 404, $response->get_status() ); 101 101 } 102 102 … … 105 105 $request = new WP_REST_Request( 'POST', '/wp/v2/types/post' ); 106 106 $response = rest_get_server()->dispatch( $request ); 107 $this->assert Equals( 404, $response->get_status() );107 $this->assertSame( 404, $response->get_status() ); 108 108 } 109 109 … … 112 112 $request = new WP_REST_Request( 'DELETE', '/wp/v2/types/post' ); 113 113 $response = rest_get_server()->dispatch( $request ); 114 $this->assert Equals( 404, $response->get_status() );114 $this->assertSame( 404, $response->get_status() ); 115 115 } 116 116 … … 131 131 $request->set_param( '_fields', 'id,name' ); 132 132 $response = $endpoint->prepare_item_for_response( $obj, $request ); 133 $this->assert Equals(133 $this->assertSame( 134 134 array( 135 135 // 'id' doesn't exist in this context. … … 145 145 $data = $response->get_data(); 146 146 $properties = $data['schema']['properties']; 147 $this->assert Equals( 10, count( $properties ) );147 $this->assertSame( 10, count( $properties ) ); 148 148 $this->assertArrayHasKey( 'capabilities', $properties ); 149 149 $this->assertArrayHasKey( 'description', $properties ); … … 183 183 184 184 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); 185 $this->assert Equals( $schema, $data['schema']['properties']['my_custom_int'] );185 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 186 186 187 187 $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); … … 199 199 200 200 protected function check_post_type_obj( $context, $post_type_obj, $data, $links ) { 201 $this->assert Equals( $post_type_obj->label, $data['name'] );202 $this->assert Equals( $post_type_obj->name, $data['slug'] );203 $this->assert Equals( $post_type_obj->description, $data['description'] );204 $this->assert Equals( $post_type_obj->hierarchical, $data['hierarchical'] );205 $this->assert Equals( $post_type_obj->rest_base, $data['rest_base'] );201 $this->assertSame( $post_type_obj->label, $data['name'] ); 202 $this->assertSame( $post_type_obj->name, $data['slug'] ); 203 $this->assertSame( $post_type_obj->description, $data['description'] ); 204 $this->assertSame( $post_type_obj->hierarchical, $data['hierarchical'] ); 205 $this->assertSame( $post_type_obj->rest_base, $data['rest_base'] ); 206 206 207 207 $links = test_rest_expand_compact_links( $links ); 208 $this->assert Equals( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] );208 $this->assertSame( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] ); 209 209 $this->assertArrayHasKey( 'https://api.w.org/items', $links ); 210 210 if ( 'edit' === $context ) { 211 $this->assert Equals( $post_type_obj->cap, $data['capabilities'] );212 $this->assert Equals( $post_type_obj->labels, $data['labels'] );211 $this->assertSame( $post_type_obj->cap, $data['capabilities'] ); 212 $this->assertSame( $post_type_obj->labels, $data['labels'] ); 213 213 if ( in_array( $post_type_obj->name, array( 'post', 'page' ), true ) ) { 214 214 $viewable = true; … … 216 216 $viewable = is_post_type_viewable( $post_type_obj ); 217 217 } 218 $this->assert Equals( $viewable, $data['viewable'] );219 $this->assert Equals( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] );218 $this->assertSame( $viewable, $data['viewable'] ); 219 $this->assertSame( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] ); 220 220 } else { 221 221 $this->assertFalse( isset( $data['capabilities'] ) ); … … 227 227 228 228 protected function check_post_type_object_response( $context, $response, $post_type = 'post' ) { 229 $this->assert Equals( 200, $response->get_status() );229 $this->assertSame( 200, $response->get_status() ); 230 230 $data = $response->get_data(); 231 231 $obj = get_post_type_object( $post_type );
Note: See TracChangeset
for help on using the changeset viewer.