- Timestamp:
- 09/06/2022 10:09:49 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r53909 r54090 140 140 $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 141 141 // Single. 142 $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) );142 $tag1 = self::factory()->tag->create( array( 'name' => 'Season 5' ) ); 143 143 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags/' . $tag1 ); 144 144 $response = rest_get_server()->dispatch( $request ); … … 175 175 176 176 public function test_get_items() { 177 $this->factory->tag->create();177 self::factory()->tag->create(); 178 178 179 179 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 193 193 194 194 public function test_get_items_hide_empty_arg() { 195 $post_id = $this->factory->post->create();196 $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) );197 $tag2 = $this->factory->tag->create( array( 'name' => 'The Be Sharps' ) );195 $post_id = self::factory()->post->create(); 196 $tag1 = self::factory()->tag->create( array( 'name' => 'Season 5' ) ); 197 $tag2 = self::factory()->tag->create( array( 'name' => 'The Be Sharps' ) ); 198 198 199 199 wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' ); … … 214 214 215 215 public function test_get_items_include_query() { 216 $id1 = $this->factory->tag->create();217 $id2 = $this->factory->tag->create();216 $id1 = self::factory()->tag->create(); 217 $id2 = self::factory()->tag->create(); 218 218 219 219 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 240 240 241 241 public function test_get_items_exclude_query() { 242 $id1 = $this->factory->tag->create();243 $id2 = $this->factory->tag->create();242 $id1 = self::factory()->tag->create(); 243 $id2 = self::factory()->tag->create(); 244 244 245 245 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 289 289 290 290 public function test_get_items_orderby_args() { 291 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );292 $tag2 = $this->factory->tag->create( array( 'name' => 'Zucchini' ) );291 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 292 $tag2 = self::factory()->tag->create( array( 'name' => 'Zucchini' ) ); 293 293 294 294 /* … … 325 325 326 326 public function test_get_items_orderby_id() { 327 $tag0 = $this->factory->tag->create( array( 'name' => 'Cantaloupe' ) );328 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );329 $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );327 $tag0 = self::factory()->tag->create( array( 'name' => 'Cantaloupe' ) ); 328 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 329 $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) ); 330 330 331 331 // Defaults to 'orderby' => 'name', 'order' => 'asc'. … … 361 361 362 362 public function test_get_items_orderby_slugs() { 363 $this->factory->tag->create( array( 'name' => 'Burrito' ) );364 $this->factory->tag->create( array( 'name' => 'Taco' ) );365 $this->factory->tag->create( array( 'name' => 'Chalupa' ) );363 self::factory()->tag->create( array( 'name' => 'Burrito' ) ); 364 self::factory()->tag->create( array( 'name' => 'Taco' ) ); 365 self::factory()->tag->create( array( 'name' => 'Chalupa' ) ); 366 366 367 367 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 377 377 378 378 public function test_get_items_post_args() { 379 $post_id = $this->factory->post->create();380 $tag1 = $this->factory->tag->create( array( 'name' => 'DC' ) );381 $tag2 = $this->factory->tag->create( array( 'name' => 'Marvel' ) );382 $this->factory->tag->create( array( 'name' => 'Dark Horse' ) );379 $post_id = self::factory()->post->create(); 380 $tag1 = self::factory()->tag->create( array( 'name' => 'DC' ) ); 381 $tag2 = self::factory()->tag->create( array( 'name' => 'Marvel' ) ); 382 self::factory()->tag->create( array( 'name' => 'Dark Horse' ) ); 383 383 384 384 wp_set_object_terms( $post_id, array( $tag1, $tag2 ), 'post_tag' ); … … 401 401 402 402 public function test_get_terms_post_args_paging() { 403 $post_id = $this->factory->post->create();403 $post_id = self::factory()->post->create(); 404 404 405 405 wp_set_object_terms( $post_id, self::$tag_ids, 'post_tag' ); … … 438 438 439 439 public function test_get_items_post_empty() { 440 $post_id = $this->factory->post->create();440 $post_id = self::factory()->post->create(); 441 441 442 442 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 453 453 $controller = new WP_REST_Terms_Controller( 'batman' ); 454 454 $controller->register_routes(); 455 $term1 = $this->factory->term->create(455 $term1 = self::factory()->term->create( 456 456 array( 457 457 'name' => 'Cape', … … 459 459 ) 460 460 ); 461 $term2 = $this->factory->term->create(461 $term2 = self::factory()->term->create( 462 462 array( 463 463 'name' => 'Mask', … … 465 465 ) 466 466 ); 467 $this->factory->term->create(467 self::factory()->term->create( 468 468 array( 469 469 'name' => 'Car', … … 471 471 ) 472 472 ); 473 $post_id = $this->factory->post->create();473 $post_id = self::factory()->post->create(); 474 474 475 475 wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); … … 486 486 487 487 public function test_get_items_search_args() { 488 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );489 $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );488 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 489 $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) ); 490 490 491 491 /* … … 510 510 511 511 public function test_get_items_slug_arg() { 512 $tag1 = $this->factory->tag->create( array( 'name' => 'Apple' ) );513 $tag2 = $this->factory->tag->create( array( 'name' => 'Banana' ) );512 $tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) ); 513 $tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) ); 514 514 515 515 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 523 523 524 524 public function test_get_items_slug_array_arg() { 525 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) );526 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) );527 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) );528 $this->factory->tag->create( array( 'name' => 'Pizza' ) );525 $id1 = self::factory()->tag->create( array( 'name' => 'Taco' ) ); 526 $id2 = self::factory()->tag->create( array( 'name' => 'Enchilada' ) ); 527 $id3 = self::factory()->tag->create( array( 'name' => 'Burrito' ) ); 528 self::factory()->tag->create( array( 'name' => 'Pizza' ) ); 529 529 530 530 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 546 546 547 547 public function test_get_items_slug_csv_arg() { 548 $id1 = $this->factory->tag->create( array( 'name' => 'Taco' ) );549 $id2 = $this->factory->tag->create( array( 'name' => 'Enchilada' ) );550 $id3 = $this->factory->tag->create( array( 'name' => 'Burrito' ) );551 $this->factory->tag->create( array( 'name' => 'Pizza' ) );548 $id1 = self::factory()->tag->create( array( 'name' => 'Taco' ) ); 549 $id2 = self::factory()->tag->create( array( 'name' => 'Enchilada' ) ); 550 $id3 = self::factory()->tag->create( array( 'name' => 'Burrito' ) ); 551 self::factory()->tag->create( array( 'name' => 'Pizza' ) ); 552 552 553 553 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); … … 563 563 public function test_get_terms_private_taxonomy() { 564 564 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 565 $term1 = $this->factory->term->create(565 $term1 = self::factory()->term->create( 566 566 array( 567 567 'name' => 'Cape', … … 569 569 ) 570 570 ); 571 $term2 = $this->factory->term->create(571 $term2 = self::factory()->term->create( 572 572 array( 573 573 'name' => 'Mask', … … 601 601 602 602 // 3rd page. 603 $this->factory->tag->create();603 self::factory()->tag->create(); 604 604 $total_tags++; 605 605 $total_pages++; … … 666 666 667 667 public function test_get_item() { 668 $id = $this->factory->tag->create();668 $id = self::factory()->tag->create(); 669 669 670 670 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); … … 677 677 */ 678 678 public function test_get_item_meta() { 679 $id = $this->factory->tag->create();679 $id = self::factory()->tag->create(); 680 680 681 681 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); … … 699 699 */ 700 700 public function test_get_item_meta_registered_for_different_taxonomy() { 701 $id = $this->factory->tag->create();701 $id = self::factory()->tag->create(); 702 702 703 703 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); … … 717 717 718 718 public function test_get_item_invalid_permission_for_context() { 719 $id = $this->factory->tag->create();719 $id = self::factory()->tag->create(); 720 720 721 721 wp_set_current_user( 0 ); … … 729 729 public function test_get_term_private_taxonomy() { 730 730 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 731 $term1 = $this->factory->term->create(731 $term1 = self::factory()->term->create( 732 732 array( 733 733 'name' => 'Cape', … … 743 743 public function test_get_item_incorrect_taxonomy() { 744 744 register_taxonomy( 'robin', 'post' ); 745 $term1 = $this->factory->term->create(745 $term1 = self::factory()->term->create( 746 746 array( 747 747 'name' => 'Cape', … … 834 834 wp_set_current_user( self::$administrator ); 835 835 836 $existing_tag_id = $this->factory->tag->create( array( 'name' => 'My Not So Awesome Term' ) );836 $existing_tag_id = self::factory()->tag->create( array( 'name' => 'My Not So Awesome Term' ) ); 837 837 838 838 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); … … 859 859 ); 860 860 861 $term = get_term_by( 'id', $this->factory->tag->create( $orig_args ), 'post_tag' );861 $term = get_term_by( 'id', self::factory()->tag->create( $orig_args ), 'post_tag' ); 862 862 863 863 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 887 887 wp_set_current_user( self::$administrator ); 888 888 889 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );889 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 890 890 891 891 $request = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id ); … … 915 915 wp_set_current_user( self::$subscriber ); 916 916 917 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );917 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 918 918 919 919 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 929 929 wp_set_current_user( self::$subscriber ); 930 930 931 $term = $this->factory->tag->create_and_get();931 $term = self::factory()->tag->create_and_get(); 932 932 933 933 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 956 956 wp_set_current_user( self::$administrator ); 957 957 958 $term = $this->factory->tag->create_and_get();958 $term = self::factory()->tag->create_and_get(); 959 959 960 960 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 978 978 wp_set_current_user( self::$administrator ); 979 979 980 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );980 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 981 981 982 982 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 1105 1105 wp_set_current_user( self::$administrator ); 1106 1106 1107 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1107 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1108 1108 1109 1109 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1119 1119 wp_set_current_user( self::$administrator ); 1120 1120 1121 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1121 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1122 1122 1123 1123 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1141 1141 wp_set_current_user( self::$subscriber ); 1142 1142 1143 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );1143 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 1144 1144 1145 1145 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1154 1154 wp_set_current_user( self::$subscriber ); 1155 1155 1156 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1156 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1157 1157 1158 1158 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1182 1182 wp_set_current_user( self::$administrator ); 1183 1183 1184 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' );1184 $term = get_term_by( 'id', self::factory()->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 1185 1185 1186 1186 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 1202 1202 1203 1203 public function test_prepare_item() { 1204 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );1204 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 1205 1205 1206 1206 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $term->term_id ); … … 1215 1215 $endpoint = new WP_REST_Terms_Controller( 'post_tag' ); 1216 1216 $request->set_param( '_fields', 'id,name' ); 1217 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );1217 $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); 1218 1218 $response = $endpoint->prepare_item_for_response( $term, $request ); 1219 1219 $this->assertSame( … … 1277 1277 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 1278 1278 1279 $tag_id = $this->factory->tag->create();1279 $tag_id = self::factory()->tag->create(); 1280 1280 1281 1281 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $tag_id ); … … 1307 1307 wp_set_current_user( self::$administrator ); 1308 1308 1309 $tag_id = $this->factory->tag->create();1309 $tag_id = self::factory()->tag->create(); 1310 1310 1311 1311 // Check for error on update. … … 1331 1331 global $wpdb; 1332 1332 1333 $tags = $this->factory->tag->create_many( 2 );1334 $p = $this->factory->post->create();1333 $tags = self::factory()->tag->create_many( 2 ); 1334 $p = self::factory()->post->create(); 1335 1335 wp_set_object_terms( $p, $tags[0], 'post_tag' ); 1336 1336
Note: See TracChangeset
for help on using the changeset viewer.