- Timestamp:
- 07/13/2018 04:23:35 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r43087 r43440 14 14 protected static $administrator; 15 15 protected static $editor; 16 protected static $contributor; 16 17 protected static $subscriber; 17 18 … … 31 32 array( 32 33 'role' => 'editor', 34 ) 35 ); 36 self::$contributor = $factory->user->create( 37 array( 38 'role' => 'contributor', 33 39 ) 34 40 ); … … 611 617 public function test_create_item() { 612 618 wp_set_current_user( self::$administrator ); 619 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); 620 $request->set_param( 'name', 'My Awesome Term' ); 621 $request->set_param( 'description', 'This term is so awesome.' ); 622 $request->set_param( 'slug', 'so-awesome' ); 623 $response = rest_get_server()->dispatch( $request ); 624 $this->assertEquals( 201, $response->get_status() ); 625 $headers = $response->get_headers(); 626 $data = $response->get_data(); 627 $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] ); 628 $this->assertEquals( 'My Awesome Term', $data['name'] ); 629 $this->assertEquals( 'This term is so awesome.', $data['description'] ); 630 $this->assertEquals( 'so-awesome', $data['slug'] ); 631 } 632 633 public function test_create_item_contributor() { 634 wp_set_current_user( self::$contributor ); 613 635 $request = new WP_REST_Request( 'POST', '/wp/v2/tags' ); 614 636 $request->set_param( 'name', 'My Awesome Term' );
Note: See TracChangeset
for help on using the changeset viewer.