Make WordPress Core

Ticket #16863: 16863-test.diff

File 16863-test.diff, 1.2 KB (added by boonebgorges, 9 years ago)
  • tests/phpunit/tests/term/getTerms.php

    diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
    index 46db77e..42e3091 100644
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    196196        }
    197197
    198198        /**
     199         * @ticket 16863
     200         */
     201        public function test_include_should_work_for_all_hierarchy_levels_when_hide_empty_is_true() {
     202                register_taxonomy( 'wptests_tax', 'post' );
     203
     204                $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     205                $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $t1 ) );
     206                $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $t2 ) );
     207                $t4 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'parent' => $t3 ) );
     208
     209                $p = $this->factory->post->create();
     210                wp_set_object_terms( $p, array( $t2, $t4 ), 'wptests_tax' );
     211
     212                $found = get_terms( 'wptests_tax', array(
     213                        'hide_empty' => true,
     214                        'hierarchical' => true,
     215                        'include' => array( $t1, $t2, $t3 ),
     216                        'fields' => 'ids',
     217                ) );
     218
     219                $this->assertEqualSets( array( $t2 ), $found );
     220        }
     221
     222        /**
    199223         * @ticket 25710
    200224         */
    201225        function test_get_terms_exclude_tree() {