| | 413 | * @ticket 36343 |
| | 414 | */ |
| | 415 | public function test_tax_query_operator_not_exists_combined() { |
| | 416 | register_post_type( 'wptests_cpt1' ); |
| | 417 | register_taxonomy( 'wptests_tax1', 'wptests_cpt1' ); |
| | 418 | register_taxonomy( 'wptests_tax2', 'wptests_cpt1' ); |
| | 419 | |
| | 420 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| | 421 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| | 422 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| | 423 | |
| | 424 | $p1 = self::factory()->post->create( array( 'post_type' => 'wptests_cpt1' ) ); |
| | 425 | $p2 = self::factory()->post->create( array( 'post_type' => 'wptests_cpt1' ) ); |
| | 426 | $p3 = self::factory()->post->create( array( 'post_type' => 'wptests_cpt1' ) ); |
| | 427 | $p4 = self::factory()->post->create( array( 'post_type' => 'wptests_cpt1' ) ); |
| | 428 | |
| | 429 | wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); |
| | 430 | wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax1' ); |
| | 431 | wp_set_object_terms( $p3, array( $t3 ), 'wptests_tax2' ); |
| | 432 | |
| | 433 | $q = new WP_Query( array( |
| | 434 | 'post_type' => 'wptests_cpt1', |
| | 435 | 'fields' => 'ids', |
| | 436 | 'tax_query' => array( |
| | 437 | 'relation' => 'OR', |
| | 438 | array( |
| | 439 | 'taxonomy' => 'wptests_tax1', |
| | 440 | 'operator' => 'NOT EXISTS', |
| | 441 | ), |
| | 442 | array( |
| | 443 | 'taxonomy' => 'wptests_tax1', |
| | 444 | 'field' => 'slug', |
| | 445 | 'terms' => get_term_field( 'slug', $t1 ), |
| | 446 | ), |
| | 447 | ), |
| | 448 | ) ); |
| | 449 | |
| | 450 | unregister_post_type( 'wptests_cpt1' ); |
| | 451 | unregister_taxonomy( 'wptests_tax1' ); |
| | 452 | unregister_taxonomy( 'wptests_tax2' ); |
| | 453 | |
| | 454 | $this->assertEqualSets( array( $p1, $p3, $p4 ), $q->posts ); |
| | 455 | } |
| | 456 | |
| | 457 | /** |