- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
r48273 r48937 38 38 $response = rest_get_server()->dispatch( $request ); 39 39 $data = $response->get_data(); 40 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );40 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 41 41 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 42 42 // Single. … … 44 44 $response = rest_get_server()->dispatch( $request ); 45 45 $data = $response->get_data(); 46 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );46 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 47 47 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 48 48 } … … 53 53 $data = $response->get_data(); 54 54 $taxonomies = $this->get_public_taxonomies( get_taxonomies( '', 'objects' ) ); 55 $this->assert Equals( count( $taxonomies ), count( $data ) );56 $this->assert Equals( 'Categories', $data['category']['name'] );57 $this->assert Equals( 'category', $data['category']['slug'] );58 $this->assert Equals( true,$data['category']['hierarchical'] );59 $this->assert Equals( 'Tags', $data['post_tag']['name'] );60 $this->assert Equals( 'post_tag', $data['post_tag']['slug'] );61 $this->assert Equals( false,$data['post_tag']['hierarchical'] );62 $this->assert Equals( 'tags', $data['post_tag']['rest_base'] );55 $this->assertSame( count( $taxonomies ), count( $data ) ); 56 $this->assertSame( 'Categories', $data['category']['name'] ); 57 $this->assertSame( 'category', $data['category']['slug'] ); 58 $this->assertTrue( $data['category']['hierarchical'] ); 59 $this->assertSame( 'Tags', $data['post_tag']['name'] ); 60 $this->assertSame( 'post_tag', $data['post_tag']['slug'] ); 61 $this->assertFalse( $data['post_tag']['hierarchical'] ); 62 $this->assertSame( 'tags', $data['post_tag']['rest_base'] ); 63 63 } 64 64 … … 70 70 $data = $response->get_data(); 71 71 $taxonomies = $this->get_public_taxonomies( get_taxonomies( '', 'objects' ) ); 72 $this->assert Equals( count( $taxonomies ), count( $data ) );73 $this->assert Equals( 'Categories', $data['category']['name'] );74 $this->assert Equals( 'category', $data['category']['slug'] );75 $this->assert Equals( true,$data['category']['hierarchical'] );76 $this->assert Equals( 'Tags', $data['post_tag']['name'] );77 $this->assert Equals( 'post_tag', $data['post_tag']['slug'] );78 $this->assert Equals( false,$data['post_tag']['hierarchical'] );79 $this->assert Equals( 'tags', $data['post_tag']['rest_base'] );72 $this->assertSame( count( $taxonomies ), count( $data ) ); 73 $this->assertSame( 'Categories', $data['category']['name'] ); 74 $this->assertSame( 'category', $data['category']['slug'] ); 75 $this->assertTrue( $data['category']['hierarchical'] ); 76 $this->assertSame( 'Tags', $data['post_tag']['name'] ); 77 $this->assertSame( 'post_tag', $data['post_tag']['slug'] ); 78 $this->assertFalse( $data['post_tag']['hierarchical'] ); 79 $this->assertSame( 'tags', $data['post_tag']['rest_base'] ); 80 80 } 81 81 … … 99 99 $request->set_param( 'type', 'wingding' ); 100 100 $response = rest_get_server()->dispatch( $request ); 101 $this->assert Equals( 200, $response->get_status() );101 $this->assertSame( 200, $response->get_status() ); 102 102 $data = $response->get_data(); 103 $this->assert Equals( '{}', json_encode( $data ) );103 $this->assertSame( '{}', json_encode( $data ) ); 104 104 } 105 105 … … 154 154 $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies' ); 155 155 $response = rest_get_server()->dispatch( $request ); 156 $this->assert Equals( 404, $response->get_status() );156 $this->assertSame( 404, $response->get_status() ); 157 157 } 158 158 … … 161 161 $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies/category' ); 162 162 $response = rest_get_server()->dispatch( $request ); 163 $this->assert Equals( 404, $response->get_status() );163 $this->assertSame( 404, $response->get_status() ); 164 164 } 165 165 … … 168 168 $request = new WP_REST_Request( 'DELETE', '/wp/v2/taxonomies/category' ); 169 169 $response = rest_get_server()->dispatch( $request ); 170 $this->assert Equals( 404, $response->get_status() );170 $this->assertSame( 404, $response->get_status() ); 171 171 } 172 172 … … 187 187 $request->set_param( '_fields', 'id,name' ); 188 188 $response = $endpoint->prepare_item_for_response( $tax, $request ); 189 $this->assert Equals(189 $this->assertSame( 190 190 array( 191 191 // 'id' doesn't exist in this context. … … 209 209 $types = $response->get_data()['types']; 210 210 $this->assertArrayHasKey( 0, $types ); 211 $this->assert Equals( 'post', $types[0] );211 $this->assertSame( 'post', $types[0] ); 212 212 $this->assertArrayHasKey( 1, $types ); 213 $this->assert Equals( 'attachment', $types[1] );214 $this->assert Equals( 2, count( $types ) );213 $this->assertSame( 'attachment', $types[1] ); 214 $this->assertSame( 2, count( $types ) ); 215 215 } 216 216 … … 220 220 $data = $response->get_data(); 221 221 $properties = $data['schema']['properties']; 222 $this->assert Equals( 10, count( $properties ) );222 $this->assertSame( 10, count( $properties ) ); 223 223 $this->assertArrayHasKey( 'capabilities', $properties ); 224 224 $this->assertArrayHasKey( 'description', $properties ); … … 252 252 253 253 protected function check_taxonomy_object( $context, $tax_obj, $data, $links ) { 254 $this->assert Equals( $tax_obj->label, $data['name'] );255 $this->assert Equals( $tax_obj->name, $data['slug'] );256 $this->assert Equals( $tax_obj->description, $data['description'] );257 $this->assert Equals( $tax_obj->hierarchical, $data['hierarchical'] );258 $this->assert Equals( $tax_obj->rest_base, $data['rest_base'] );259 $this->assert Equals( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] );254 $this->assertSame( $tax_obj->label, $data['name'] ); 255 $this->assertSame( $tax_obj->name, $data['slug'] ); 256 $this->assertSame( $tax_obj->description, $data['description'] ); 257 $this->assertSame( $tax_obj->hierarchical, $data['hierarchical'] ); 258 $this->assertSame( $tax_obj->rest_base, $data['rest_base'] ); 259 $this->assertSame( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] ); 260 260 $this->assertArrayHasKey( 'https://api.w.org/items', $links ); 261 261 if ( 'edit' === $context ) { 262 $this->assert Equals( $tax_obj->cap, $data['capabilities'] );263 $this->assert Equals( $tax_obj->labels, $data['labels'] );264 $this->assert Equals( $tax_obj->show_tagcloud, $data['show_cloud'] );265 266 $this->assert Equals( $tax_obj->public, $data['visibility']['public'] );267 $this->assert Equals( $tax_obj->publicly_queryable, $data['visibility']['publicly_queryable'] );268 $this->assert Equals( $tax_obj->show_admin_column, $data['visibility']['show_admin_column'] );269 $this->assert Equals( $tax_obj->show_in_nav_menus, $data['visibility']['show_in_nav_menus'] );270 $this->assert Equals( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] );271 $this->assert Equals( $tax_obj->show_ui, $data['visibility']['show_ui'] );262 $this->assertSame( $tax_obj->cap, $data['capabilities'] ); 263 $this->assertSame( $tax_obj->labels, $data['labels'] ); 264 $this->assertSame( $tax_obj->show_tagcloud, $data['show_cloud'] ); 265 266 $this->assertSame( $tax_obj->public, $data['visibility']['public'] ); 267 $this->assertSame( $tax_obj->publicly_queryable, $data['visibility']['publicly_queryable'] ); 268 $this->assertSame( $tax_obj->show_admin_column, $data['visibility']['show_admin_column'] ); 269 $this->assertSame( $tax_obj->show_in_nav_menus, $data['visibility']['show_in_nav_menus'] ); 270 $this->assertSame( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] ); 271 $this->assertSame( $tax_obj->show_ui, $data['visibility']['show_ui'] ); 272 272 } else { 273 273 $this->assertFalse( isset( $data['capabilities'] ) ); … … 279 279 280 280 protected function check_taxonomy_object_response( $context, $response ) { 281 $this->assert Equals( 200, $response->get_status() );281 $this->assertSame( 200, $response->get_status() ); 282 282 $data = $response->get_data(); 283 283 $category = get_taxonomy( 'category' ); … … 286 286 287 287 protected function check_taxonomies_for_type_response( $type, $response ) { 288 $this->assert Equals( 200, $response->get_status() );288 $this->assertSame( 200, $response->get_status() ); 289 289 $data = $response->get_data(); 290 290 $taxonomies = $this->get_public_taxonomies( get_object_taxonomies( $type, 'objects' ) ); 291 $this->assert Equals( count( $taxonomies ), count( $data ) );291 $this->assertSame( count( $taxonomies ), count( $data ) ); 292 292 } 293 293
Note: See TracChangeset
for help on using the changeset viewer.