Changeset 30141 for trunk/tests/phpunit/tests/taxonomy.php
- Timestamp:
- 11/01/2014 02:57:31 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/taxonomy.php
r29830 r30141 235 235 $this->assertEquals( 0, wp_insert_category( $cat, false ) ); 236 236 } 237 238 public function test_get_ancestors_taxonomy_non_hierarchical() { 239 register_taxonomy( 'wptests_tax', 'post' ); 240 $t = $this->factory->term->create( array( 241 'taxonomy' => 'wptests_tax', 242 ) ); 243 244 $this->assertSame( array(), get_ancestors( $t, 'wptests_tax' ) ); 245 _unregister_taxonomy( 'wptests_tax' ); 246 } 247 248 public function test_get_ancestors_taxonomy() { 249 register_taxonomy( 'wptests_tax', 'post', array( 250 'hierarchical' => true, 251 ) ); 252 $t1 = $this->factory->term->create( array( 253 'taxonomy' => 'wptests_tax', 254 ) ); 255 $t2 = $this->factory->term->create( array( 256 'taxonomy' => 'wptests_tax', 257 'parent' => $t1, 258 ) ); 259 $t3 = $this->factory->term->create( array( 260 'taxonomy' => 'wptests_tax', 261 'parent' => $t2, 262 ) ); 263 $t4 = $this->factory->term->create( array( 264 'taxonomy' => 'wptests_tax', 265 'parent' => $t1, 266 ) ); 267 268 $this->assertEqualSets( array( $t2, $t1 ), get_ancestors( $t3, 'wptests_tax' ) ); 269 _unregister_taxonomy( 'wptests_tax' ); 270 } 271 272 public function test_get_ancestors_post_type_non_hierarchical() { 273 register_post_type( 'wptests_pt' ); 274 $p = $this->factory->post->create( array( 275 'taxonomy' => 'wptests_pt', 276 ) ); 277 278 $this->assertEqualSets( array(), get_ancestors( $p, 'wptests_tax' ) ); 279 } 280 281 public function test_get_ancestors_post_type() { 282 register_post_type( 'wptests_pt', array( 283 'hierarchical' => true, 284 ) ); 285 $p1 = $this->factory->post->create( array( 286 'post_type' => 'wptests_pt', 287 ) ); 288 $p2 = $this->factory->post->create( array( 289 'post_type' => 'wptests_pt', 290 'post_parent' => $p1, 291 ) ); 292 $p3 = $this->factory->post->create( array( 293 'post_type' => 'wptests_pt', 294 'post_parent' => $p2, 295 ) ); 296 $p4 = $this->factory->post->create( array( 297 'post_type' => 'wptests_pt', 298 'post_parent' => $p1, 299 ) ); 300 301 $this->assertEqualSets( array( $p2, $p1 ), get_ancestors( $p3, 'wptests_pt' ) ); 302 _unregister_post_type( 'wptests_pt' ); 303 } 304 305 /** 306 * @ticket 15029 307 */ 308 public function test_get_ancestors_taxonomy_post_type_conflict_resource_type_taxonomy() { 309 register_post_type( 'wptests_conflict', array( 310 'hierarchical' => true, 311 ) ); 312 $p1 = $this->factory->post->create( array( 313 'post_type' => 'wptests_conflict', 314 ) ); 315 $p2 = $this->factory->post->create( array( 316 'post_type' => 'wptests_conflict', 317 'post_parent' => $p1, 318 ) ); 319 320 register_taxonomy( 'wptests_conflict', 'post', array( 321 'hierarchical' => true, 322 ) ); 323 $t1 = $this->factory->term->create( array( 324 'taxonomy' => 'wptests_conflict', 325 ) ); 326 $t2 = $this->factory->term->create( array( 327 'taxonomy' => 'wptests_conflict', 328 'parent' => $t1, 329 ) ); 330 331 $this->assertEqualSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) ); 332 $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict', 'taxonomy' ) ); 333 $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) ); 334 _unregister_post_type( 'wptests_pt' ); 335 } 237 336 }
Note: See TracChangeset
for help on using the changeset viewer.