Changeset 39189 for trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php
- Timestamp:
- 11/10/2016 01:53:08 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php
r38698 r39189 5 5 */ 6 6 class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { 7 var$parent_term;8 var$child_term;9 var$post_tag;7 protected static $parent_term; 8 protected static $child_term; 9 protected static $post_tag; 10 10 11 function setUp() { 12 parent::setUp(); 13 14 $this->parent_term = wp_insert_term( 'parent' . rand_str() , 'category' ); 15 $this->assertInternalType( 'array', $this->parent_term ); 16 $this->child_term = wp_insert_term( 'child' . rand_str() , 'category' ); 17 $this->assertInternalType( 'array', $this->child_term ); 18 $this->post_tag = wp_insert_term( 'test' . rand_str() , 'post_tag' ); 19 $this->assertInternalType( 'array', $this->post_tag ); 11 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 12 self::$parent_term = $factory->term->create( array( 13 'taxonomy' => 'category', 14 ) ); 15 self::$child_term = $factory->term->create( array( 16 'taxonomy' => 'category', 17 ) ); 18 self::$post_tag = $factory->term->create( array( 19 'taxonomy' => 'post_tag', 20 ) ); 20 21 } 21 22 … … 38 39 $this->make_user_by_role( 'subscriber' ); 39 40 40 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'not_existing' ) ) );41 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) ); 41 42 $this->assertInstanceOf( 'IXR_Error', $result ); 42 43 $this->assertEquals( 403, $result->code ); … … 47 48 $this->make_user_by_role( 'subscriber' ); 48 49 49 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'category' ) ) );50 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) ); 50 51 $this->assertInstanceOf( 'IXR_Error', $result ); 51 52 $this->assertEquals( 401, $result->code ); … … 74 75 $this->make_user_by_role( 'editor' ); 75 76 76 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->parent_term['term_id'], array( 'taxonomy' => 'category', 'name' => '' ) ) );77 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) ); 77 78 $this->assertInstanceOf( 'IXR_Error', $result ); 78 79 $this->assertEquals( 403, $result->code ); … … 83 84 $this->make_user_by_role( 'editor' ); 84 85 85 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->post_tag['term_id'], array( 'taxonomy' => 'post_tag', 'parent' => $this->parent_term['term_id']) ) );86 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) ); 86 87 $this->assertInstanceOf( 'IXR_Error', $result ); 87 88 $this->assertEquals( 403, $result->code ); … … 92 93 $this->make_user_by_role( 'editor' ); 93 94 94 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );95 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) ); 95 96 $this->assertNotInstanceOf( 'IXR_Error', $result ); 96 97 $this->assertTrue( $result ); … … 100 101 $this->make_user_by_role( 'editor' ); 101 102 102 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );103 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) ); 103 104 104 105 $this->assertNotInstanceOf( 'IXR_Error', $result ); 105 106 $this->assertInternalType( 'boolean', $result ); 106 107 107 $term = get_term( $this->child_term['term_id'], 'category' );108 $term = get_term( self::$child_term, 'category' ); 108 109 $this->assertEquals( '0', $term->parent ); 109 110 } … … 112 113 $this->make_user_by_role( 'editor' ); 113 114 114 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );115 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) ); 115 116 $this->assertInstanceOf( 'IXR_Error', $result ); 116 117 $this->assertEquals( 500, $result->code ); … … 120 121 $this->make_user_by_role( 'editor' ); 121 122 122 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );123 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) ); 123 124 $this->assertInstanceOf( 'IXR_Error', $result ); 124 125 $this->assertEquals( 403, $result->code ); … … 129 130 $this->make_user_by_role( 'editor' ); 130 131 131 $parent_term = get_term_by( 'id', $this->parent_term['term_id'], 'category' );132 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );132 $parent_term = get_term_by( 'id', self::$parent_term, 'category' ); 133 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) ); 133 134 $this->assertInstanceOf( 'IXR_Error', $result ); 134 135 $this->assertEquals( 500, $result->code ); … … 139 140 $this->make_user_by_role( 'editor' ); 140 141 141 $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => $this->parent_term['term_id'], 'description' => 'Child term', 'slug' => 'child_2' );142 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], $fields ) );142 $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' ); 143 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) ); 143 144 144 145 $this->assertNotInstanceOf( 'IXR_Error', $result );
Note: See TracChangeset
for help on using the changeset viewer.