Changeset 42343 for trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php
r41684 r42343 10 10 11 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 ) ); 12 self::$parent_term = $factory->term->create( 13 array( 14 'taxonomy' => 'category', 15 ) 16 ); 17 self::$child_term = $factory->term->create( 18 array( 19 'taxonomy' => 'category', 20 ) 21 ); 22 self::$post_tag = $factory->term->create( 23 array( 24 'taxonomy' => 'post_tag', 25 ) 26 ); 21 27 } 22 28 … … 60 66 $this->assertIXRError( $result ); 61 67 $this->assertEquals( 404, $result->code ); 62 $this->assertEquals( 68 $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); 63 69 } 64 70 … … 69 75 $this->assertIXRError( $result ); 70 76 $this->assertEquals( 500, $result->code ); 71 $this->assertEquals( __( 'Empty Term.'), $result->message );77 $this->assertEquals( __( 'Empty Term.' ), $result->message ); 72 78 } 73 79 … … 75 81 $this->make_user_by_role( 'editor' ); 76 82 77 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) ); 83 $result = $this->myxmlrpcserver->wp_editTerm( 84 array( 85 1, 86 'editor', 87 'editor', 88 self::$parent_term, 89 array( 90 'taxonomy' => 'category', 91 'name' => '', 92 ), 93 ) 94 ); 78 95 $this->assertIXRError( $result ); 79 96 $this->assertEquals( 403, $result->code ); … … 84 101 $this->make_user_by_role( 'editor' ); 85 102 86 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) ); 103 $result = $this->myxmlrpcserver->wp_editTerm( 104 array( 105 1, 106 'editor', 107 'editor', 108 self::$post_tag, 109 array( 110 'taxonomy' => 'post_tag', 111 'parent' => self::$parent_term, 112 ), 113 ) 114 ); 87 115 $this->assertIXRError( $result ); 88 116 $this->assertEquals( 403, $result->code ); … … 93 121 $this->make_user_by_role( 'editor' ); 94 122 95 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) ); 123 $result = $this->myxmlrpcserver->wp_editTerm( 124 array( 125 1, 126 'editor', 127 'editor', 128 self::$child_term, 129 array( 130 'taxonomy' => 'category', 131 'parent' => '', 132 'name' => 'test', 133 ), 134 ) 135 ); 96 136 $this->assertNotIXRError( $result ); 97 137 $this->assertTrue( $result ); … … 101 141 $this->make_user_by_role( 'editor' ); 102 142 103 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) ); 143 $result = $this->myxmlrpcserver->wp_editTerm( 144 array( 145 1, 146 'editor', 147 'editor', 148 self::$child_term, 149 array( 150 'taxonomy' => 'category', 151 'parent' => null, 152 'name' => 'test', 153 ), 154 ) 155 ); 104 156 105 157 $this->assertNotIXRError( $result ); … … 113 165 $this->make_user_by_role( 'editor' ); 114 166 115 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) ); 167 $result = $this->myxmlrpcserver->wp_editTerm( 168 array( 169 1, 170 'editor', 171 'editor', 172 self::$child_term, 173 array( 174 'taxonomy' => 'category', 175 'parent' => 'dasda', 176 'name' => 'test', 177 ), 178 ) 179 ); 116 180 $this->assertIXRError( $result ); 117 181 $this->assertEquals( 500, $result->code ); … … 121 185 $this->make_user_by_role( 'editor' ); 122 186 123 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) ); 187 $result = $this->myxmlrpcserver->wp_editTerm( 188 array( 189 1, 190 'editor', 191 'editor', 192 self::$child_term, 193 array( 194 'taxonomy' => 'category', 195 'parent' => 9999, 196 'name' => 'test', 197 ), 198 ) 199 ); 124 200 $this->assertIXRError( $result ); 125 201 $this->assertEquals( 403, $result->code ); … … 131 207 132 208 $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 ) ) ); 209 $result = $this->myxmlrpcserver->wp_editTerm( 210 array( 211 1, 212 'editor', 213 'editor', 214 self::$child_term, 215 array( 216 'taxonomy' => 'category', 217 'slug' => $parent_term->slug, 218 ), 219 ) 220 ); 134 221 $this->assertIXRError( $result ); 135 222 $this->assertEquals( 500, $result->code ); 136 $this->assertEquals( htmlspecialchars( sprintf( __( 'The slug “%s” is already in use by another term.'), $parent_term->slug ) ), $result->message );223 $this->assertEquals( htmlspecialchars( sprintf( __( 'The slug “%s” is already in use by another term.' ), $parent_term->slug ) ), $result->message ); 137 224 } 138 225 … … 140 227 $this->make_user_by_role( 'editor' ); 141 228 142 $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' ); 229 $fields = array( 230 'taxonomy' => 'category', 231 'name' => 'Child 2', 232 'parent' => self::$parent_term, 233 'description' => 'Child term', 234 'slug' => 'child_2', 235 ); 143 236 $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) ); 144 237 … … 153 246 register_taxonomy( 'wptests_tax', 'post' ); 154 247 155 $t = self::factory()->term->create( array( 156 'taxonomy' => 'wptests_tax', 157 ) ); 248 $t = self::factory()->term->create( 249 array( 250 'taxonomy' => 'wptests_tax', 251 ) 252 ); 158 253 $meta_id = add_term_meta( $t, 'foo', 'bar' ); 159 254 160 255 $this->make_user_by_role( 'editor' ); 161 256 162 $result = $this->myxmlrpcserver->wp_editTerm( array( 163 1, 164 'editor', 165 'editor', 166 $t, 167 array( 168 'taxonomy' => 'wptests_tax', 169 'custom_fields' => array( 170 array( 171 'id' => $meta_id, 172 'key' => 'foo', 173 'value' => 'baz', 257 $result = $this->myxmlrpcserver->wp_editTerm( 258 array( 259 1, 260 'editor', 261 'editor', 262 $t, 263 array( 264 'taxonomy' => 'wptests_tax', 265 'custom_fields' => array( 266 array( 267 'id' => $meta_id, 268 'key' => 'foo', 269 'value' => 'baz', 270 ), 174 271 ), 175 272 ), 176 ) ,177 ) );273 ) 274 ); 178 275 179 276 $this->assertNotIXRError( $result ); … … 189 286 register_taxonomy( 'wptests_tax', 'post' ); 190 287 191 $t = self::factory()->term->create( array( 192 'taxonomy' => 'wptests_tax', 193 ) ); 288 $t = self::factory()->term->create( 289 array( 290 'taxonomy' => 'wptests_tax', 291 ) 292 ); 194 293 $meta_id = add_term_meta( $t, 'foo', 'bar' ); 195 294 196 295 $this->make_user_by_role( 'editor' ); 197 296 198 $result = $this->myxmlrpcserver->wp_editTerm( array( 199 1, 200 'editor', 201 'editor', 202 $t, 203 array( 204 'taxonomy' => 'wptests_tax', 205 'custom_fields' => array( 206 array( 207 'id' => $meta_id, 297 $result = $this->myxmlrpcserver->wp_editTerm( 298 array( 299 1, 300 'editor', 301 'editor', 302 $t, 303 array( 304 'taxonomy' => 'wptests_tax', 305 'custom_fields' => array( 306 array( 307 'id' => $meta_id, 308 ), 208 309 ), 209 310 ), 210 ) ,211 ) );311 ) 312 ); 212 313 213 314 $this->assertNotIXRError( $result );
Note: See TracChangeset
for help on using the changeset viewer.