Make WordPress Core

Ticket #36343: 36343.diff

File 36343.diff, 1.6 KB (added by swissspidy, 10 years ago)
  • tests/phpunit/tests/query/taxQuery.php

    diff --git tests/phpunit/tests/query/taxQuery.php tests/phpunit/tests/query/taxQuery.php
    index 8248b19..74a83e0 100644
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    410410        }
    411411
    412412        /**
     413         * @ticket 36343
     414         */
     415        public function test_tax_query_operator_not_exists_combined() {
     416                register_taxonomy( 'wptests_tax1', 'post' );
     417                register_taxonomy( 'wptests_tax2', 'post' );
     418
     419                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     420                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     421                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     422
     423                $p1 = self::factory()->post->create();
     424                $p2 = self::factory()->post->create();
     425                $p3 = self::factory()->post->create();
     426                $p4 = self::factory()->post->create();
     427
     428                wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
     429                wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax1' );
     430                wp_set_object_terms( $p3, array( $t3 ), 'wptests_tax2' );
     431
     432                $q = new WP_Query( array(
     433                        'fields'    => 'ids',
     434                        'orderby'   => 'ID',
     435                        'order'     => 'ASC',
     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                $this->assertEqualSets( array( $p1, $p3, $p4 ), $q->posts );
     451        }
     452
     453        /**
    413454         * @ticket 29181
    414455         */
    415456        public function test_tax_query_operator_exists() {