- 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-categories-controller.php
r53909 r54090 122 122 $this->assertSameSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 123 123 // Single. 124 $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) );124 $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) ); 125 125 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories/' . $category1 ); 126 126 $response = rest_get_server()->dispatch( $request ); … … 173 173 174 174 public function test_get_items_hide_empty_arg() { 175 $post_id = $this->factory->post->create();176 $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) );177 $category2 = $this->factory->category->create( array( 'name' => 'The Be Sharps' ) );175 $post_id = self::factory()->post->create(); 176 $category1 = self::factory()->category->create( array( 'name' => 'Season 5' ) ); 177 $category2 = self::factory()->category->create( array( 'name' => 'The Be Sharps' ) ); 178 178 179 179 $total_categories = self::$total_categories + 2; … … 198 198 199 199 public function test_get_items_parent_zero_arg() { 200 $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );201 $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) );202 $this->factory->category->create(200 $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); 201 $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) ); 202 self::factory()->category->create( 203 203 array( 204 204 'name' => 'Bart', … … 206 206 ) 207 207 ); 208 $this->factory->category->create(208 self::factory()->category->create( 209 209 array( 210 210 'name' => 'Lisa', … … 230 230 231 231 public function test_get_items_parent_zero_arg_string() { 232 $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );233 $parent2 = $this->factory->category->create( array( 'name' => 'Marge' ) );234 $this->factory->category->create(232 $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); 233 $parent2 = self::factory()->category->create( array( 'name' => 'Marge' ) ); 234 self::factory()->category->create( 235 235 array( 236 236 'name' => 'Bart', … … 238 238 ) 239 239 ); 240 $this->factory->category->create(240 self::factory()->category->create( 241 241 array( 242 242 'name' => 'Lisa', … … 262 262 263 263 public function test_get_items_by_parent_non_found() { 264 $parent1 = $this->factory->category->create( array( 'name' => 'Homer' ) );264 $parent1 = self::factory()->category->create( array( 'name' => 'Homer' ) ); 265 265 266 266 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 285 285 286 286 public function test_get_items_include_query() { 287 $id1 = $this->factory->category->create();288 $id2 = $this->factory->category->create();287 $id1 = self::factory()->category->create(); 288 $id2 = self::factory()->category->create(); 289 289 290 290 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 306 306 307 307 public function test_get_items_exclude_query() { 308 $id1 = $this->factory->category->create();309 $id2 = $this->factory->category->create();308 $id1 = self::factory()->category->create(); 309 $id2 = self::factory()->category->create(); 310 310 311 311 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 326 326 327 327 public function test_get_items_orderby_args() { 328 $this->factory->category->create( array( 'name' => 'Apple' ) );329 $this->factory->category->create( array( 'name' => 'Banana' ) );328 self::factory()->category->create( array( 'name' => 'Apple' ) ); 329 self::factory()->category->create( array( 'name' => 'Banana' ) ); 330 330 331 331 /* … … 357 357 358 358 public function test_get_items_orderby_id() { 359 $this->factory->category->create( array( 'name' => 'Cantaloupe' ) );360 $this->factory->category->create( array( 'name' => 'Apple' ) );361 $this->factory->category->create( array( 'name' => 'Banana' ) );359 self::factory()->category->create( array( 'name' => 'Cantaloupe' ) ); 360 self::factory()->category->create( array( 'name' => 'Apple' ) ); 361 self::factory()->category->create( array( 'name' => 'Banana' ) ); 362 362 363 363 // Defaults to 'orderby' => 'name', 'order' => 'asc'. … … 393 393 394 394 public function test_get_items_orderby_slugs() { 395 $this->factory->category->create( array( 'name' => 'Burrito' ) );396 $this->factory->category->create( array( 'name' => 'Taco' ) );397 $this->factory->category->create( array( 'name' => 'Chalupa' ) );395 self::factory()->category->create( array( 'name' => 'Burrito' ) ); 396 self::factory()->category->create( array( 'name' => 'Taco' ) ); 397 self::factory()->category->create( array( 'name' => 'Chalupa' ) ); 398 398 399 399 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 409 409 410 410 protected function post_with_categories() { 411 $post_id = $this->factory->post->create();412 $category1 = $this->factory->category->create(411 $post_id = self::factory()->post->create(); 412 $category1 = self::factory()->category->create( 413 413 array( 414 414 'name' => 'DC', … … 416 416 ) 417 417 ); 418 $category2 = $this->factory->category->create(418 $category2 = self::factory()->category->create( 419 419 array( 420 420 'name' => 'Marvel', … … 422 422 ) 423 423 ); 424 $category3 = $this->factory->category->create(424 $category3 = self::factory()->category->create( 425 425 array( 426 426 'name' => 'Image', … … 494 494 $controller = new WP_REST_Terms_Controller( 'batman' ); 495 495 $controller->register_routes(); 496 $term1 = $this->factory->term->create(496 $term1 = self::factory()->term->create( 497 497 array( 498 498 'name' => 'Cape', … … 500 500 ) 501 501 ); 502 $term2 = $this->factory->term->create(502 $term2 = self::factory()->term->create( 503 503 array( 504 504 'name' => 'Mask', … … 506 506 ) 507 507 ); 508 $this->factory->term->create(508 self::factory()->term->create( 509 509 array( 510 510 'name' => 'Car', … … 512 512 ) 513 513 ); 514 $post_id = $this->factory->post->create();514 $post_id = self::factory()->post->create(); 515 515 wp_set_object_terms( $post_id, array( $term1, $term2 ), 'batman' ); 516 516 … … 526 526 527 527 public function test_get_items_search_args() { 528 $this->factory->category->create( array( 'name' => 'Apple' ) );529 $this->factory->category->create( array( 'name' => 'Banana' ) );528 self::factory()->category->create( array( 'name' => 'Apple' ) ); 529 self::factory()->category->create( array( 'name' => 'Banana' ) ); 530 530 531 531 /* … … 550 550 551 551 public function test_get_items_slug_arg() { 552 $this->factory->category->create( array( 'name' => 'Apple' ) );553 $this->factory->category->create( array( 'name' => 'Banana' ) );552 self::factory()->category->create( array( 'name' => 'Apple' ) ); 553 self::factory()->category->create( array( 'name' => 'Banana' ) ); 554 554 555 555 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 563 563 564 564 public function test_get_terms_parent_arg() { 565 $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) );566 $this->factory->category->create(565 $category1 = self::factory()->category->create( array( 'name' => 'Parent' ) ); 566 self::factory()->category->create( 567 567 array( 568 568 'name' => 'Child', … … 588 588 public function test_get_terms_private_taxonomy() { 589 589 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 590 $this->factory->term->create(590 self::factory()->term->create( 591 591 array( 592 592 'name' => 'Cape', … … 594 594 ) 595 595 ); 596 $this->factory->term->create(596 self::factory()->term->create( 597 597 array( 598 598 'name' => 'Mask', … … 633 633 634 634 // 3rd page. 635 $this->factory->category->create();635 self::factory()->category->create(); 636 636 $total_categories++; 637 637 $total_pages++; … … 776 776 public function test_get_term_private_taxonomy() { 777 777 register_taxonomy( 'robin', 'post', array( 'public' => false ) ); 778 $term1 = $this->factory->term->create(778 $term1 = self::factory()->term->create( 779 779 array( 780 780 'name' => 'Cape', … … 790 790 public function test_get_item_incorrect_taxonomy() { 791 791 register_taxonomy( 'robin', 'post' ); 792 $term1 = $this->factory->term->create(792 $term1 = self::factory()->term->create( 793 793 array( 794 794 'name' => 'Cape', … … 825 825 wp_set_current_user( self::$administrator ); 826 826 827 $existing_id = $this->factory->category->create( array( 'name' => 'Existing' ) );827 $existing_id = self::factory()->category->create( array( 'name' => 'Existing' ) ); 828 828 829 829 $request = new WP_REST_Request( 'POST', '/wp/v2/categories' ); … … 891 891 wp_set_current_user( self::$administrator ); 892 892 893 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );893 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 894 894 895 895 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 923 923 ); 924 924 925 $term = get_term_by( 'id', $this->factory->category->create( $orig_args ), 'category' );925 $term = get_term_by( 'id', self::factory()->category->create( $orig_args ), 'category' ); 926 926 927 927 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 969 969 wp_set_current_user( self::$subscriber ); 970 970 971 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );971 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 972 972 973 973 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 980 980 wp_set_current_user( self::$administrator ); 981 981 982 $parent = get_term_by( 'id', $this->factory->category->create(), 'category' );983 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );982 $parent = get_term_by( 'id', self::factory()->category->create(), 'category' ); 983 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 984 984 985 985 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 995 995 wp_set_current_user( self::$administrator ); 996 996 997 $old_parent_term = get_term_by( 'id', $this->factory->category->create(), 'category' );997 $old_parent_term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 998 998 $new_parent_id = 0; 999 999 1000 1000 $term = get_term_by( 1001 1001 'id', 1002 $this->factory->category->create(1002 self::factory()->category->create( 1003 1003 array( 1004 1004 'parent' => $old_parent_term->term_id, … … 1022 1022 wp_set_current_user( self::$administrator ); 1023 1023 1024 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );1024 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 1025 1025 1026 1026 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); … … 1033 1033 wp_set_current_user( self::$administrator ); 1034 1034 1035 $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );1035 $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); 1036 1036 1037 1037 $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); … … 1047 1047 wp_set_current_user( self::$administrator ); 1048 1048 1049 $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );1049 $term = get_term_by( 'id', self::factory()->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); 1050 1050 1051 1051 $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); … … 1077 1077 wp_set_current_user( self::$subscriber ); 1078 1078 1079 $term = get_term_by( 'id', $this->factory->category->create(), 'category' );1079 $term = get_term_by( 'id', self::factory()->category->create(), 'category' ); 1080 1080 $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); 1081 1081 $response = rest_get_server()->dispatch( $request ); … … 1109 1109 1110 1110 public function test_prepare_taxonomy_term_child() { 1111 $child = $this->factory->category->create(1111 $child = self::factory()->category->create( 1112 1112 array( 1113 1113 'parent' => 1, … … 1171 1171 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 1172 1172 1173 $category_id = $this->factory->category->create();1173 $category_id = self::factory()->category->create(); 1174 1174 $request = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $category_id ); 1175 1175
Note: See TracChangeset
for help on using the changeset viewer.