Changeset 38941
- Timestamp:
- 10/26/2016 01:59:00 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r38834 r38941 11 11 */ 12 12 class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 13 14 public function setUp() { 15 parent::setUp(); 16 $this->administrator = $this->factory->user->create( array( 13 protected static $administrator; 14 protected static $subscriber; 15 16 public static function wpSetUpBeforeClass( $factory ) { 17 self::$administrator = $factory->user->create( array( 17 18 'role' => 'administrator', 18 19 ) ); 19 $this->subscriber = $this->factory->user->create( array(20 self::$subscriber = $factory->user->create( array( 20 21 'role' => 'subscriber', 21 22 ) ); 23 } 24 25 public static function wpTearDownAfterClass() { 26 self::delete_user( self::$administrator ); 27 self::delete_user( self::$subscriber ); 22 28 } 23 29 … … 451 457 452 458 public function test_create_item() { 453 wp_set_current_user( $this->administrator );459 wp_set_current_user( self::$administrator ); 454 460 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); 455 461 $request->set_param( 'name', 'My Awesome Term' ); … … 467 473 468 474 public function test_create_item_incorrect_permissions() { 469 wp_set_current_user( $this->subscriber );475 wp_set_current_user( self::$subscriber ); 470 476 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); 471 477 $request->set_param( 'name', 'Incorrect permissions' ); … … 475 481 476 482 public function test_create_item_missing_arguments() { 477 wp_set_current_user( $this->administrator );483 wp_set_current_user( self::$administrator ); 478 484 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); 479 485 $response = $this->server->dispatch( $request ); … … 482 488 483 489 public function test_create_item_parent_non_hierarchical_taxonomy() { 484 wp_set_current_user( $this->administrator );490 wp_set_current_user( self::$administrator ); 485 491 486 492 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); … … 492 498 493 499 public function test_update_item() { 494 wp_set_current_user( $this->administrator );500 wp_set_current_user( self::$administrator ); 495 501 $orig_args = array( 496 502 'name' => 'Original Name', … … 512 518 513 519 public function test_update_item_invalid_term() { 514 wp_set_current_user( $this->administrator );520 wp_set_current_user( self::$administrator ); 515 521 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 516 522 $request->set_param( 'name', 'Invalid Term' ); … … 520 526 521 527 public function test_update_item_incorrect_permissions() { 522 wp_set_current_user( $this->subscriber );528 wp_set_current_user( self::$subscriber ); 523 529 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' ); 524 530 $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); … … 529 535 530 536 public function test_update_item_parent_non_hierarchical_taxonomy() { 531 wp_set_current_user( $this->administrator );537 wp_set_current_user( self::$administrator ); 532 538 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' ); 533 539 … … 539 545 540 546 public function test_delete_item() { 541 wp_set_current_user( $this->administrator );547 wp_set_current_user( self::$administrator ); 542 548 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 543 549 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 550 556 551 557 public function test_delete_item_force_false() { 552 wp_set_current_user( $this->administrator );558 wp_set_current_user( self::$administrator ); 553 559 $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); 554 560 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 559 565 560 566 public function test_delete_item_invalid_term() { 561 wp_set_current_user( $this->administrator );567 wp_set_current_user( self::$administrator ); 562 568 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 563 569 $response = $this->server->dispatch( $request ); … … 566 572 567 573 public function test_delete_item_incorrect_permissions() { 568 wp_set_current_user( $this->subscriber );574 wp_set_current_user( self::$subscriber ); 569 575 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' ); 570 576 $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); … … 653 659 ) ); 654 660 655 wp_set_current_user( $this->administrator );661 wp_set_current_user( self::$administrator ); 656 662 $tag_id = $this->factory->tag->create(); 657 663 // Check for error on update.
Note: See TracChangeset
for help on using the changeset viewer.