Make WordPress Core

Ticket #44279: 44279.test.diff

File 44279.test.diff, 1.3 KB (added by boonebgorges, 6 years ago)
  • tests/phpunit/tests/term/query.php

    diff --git tests/phpunit/tests/term/query.php tests/phpunit/tests/term/query.php
    index 09925cdc7b..55a39629e3 100644
    class Tests_Term_Query extends WP_UnitTestCase { 
    713713
    714714                return $term;
    715715        }
     716
     717        /**
     718         * @ticket 44279
     719         */
     720        public function test_childless_with_child_of() {
     721                register_taxonomy(
     722                        'wptests_tax',
     723                        'post',
     724                        array(
     725                                'hierarchical' => true,
     726                        )
     727                );
     728
     729                $t1 = self::factory()->term->create(
     730                        array(
     731                                'taxonomy' => 'wptests_tax',
     732                        )
     733                );
     734
     735                $t2 = self::factory()->term->create(
     736                        array(
     737                                'taxonomy' => 'wptests_tax',
     738                                'parent'   => $t1,
     739                        )
     740                );
     741
     742                $t3 = self::factory()->term->create(
     743                        array(
     744                                'taxonomy' => 'wptests_tax',
     745                                'parent'   => $t1,
     746                        )
     747                );
     748
     749                $t4 = self::factory()->term->create(
     750                        array(
     751                                'taxonomy' => 'wptests_tax',
     752                        )
     753                );
     754
     755                $t5 = self::factory()->term->create(
     756                        array(
     757                                'taxonomy' => 'wptests_tax',
     758                                'parent'   => $t3,
     759                        )
     760                );
     761
     762                $q = new WP_Term_Query(
     763                        array(
     764                                'taxonomy'   => 'wptests_tax',
     765                                'childless'  => true,
     766                                'child_of'   => $t1,
     767                                'hide_empty' => false,
     768                                'fields'     => 'ids',
     769                        )
     770                );
     771
     772                $this->assertEqualSets( array( $t2 ), $q->terms );
     773        }
    716774}