WordPress.org

Make WordPress Core

Ticket #39120: 39120.term-query-test.patch

File 39120.term-query-test.patch, 1.2 KB (added by birgire, 2 years ago)

Added tests

  • tests/phpunit/tests/term/query.php

     
    427427                $terms = wp_get_object_terms( $post_id, array( 'category', 'wptests_tax' ) );
    428428                $this->assertEquals( array( $term_ids[1], $term_ids[0], 1 ), wp_list_pluck( $terms, 'term_id' ) );
    429429        }
     430
     431        /**
     432         * @ticket 39120
     433         */
     434        function test_get_and_set() {
     435
     436                $terms = new WP_Term_Query;
     437
     438                $this->assertNull( $terms->get( 'fields' ) );
     439                $this->assertNull( $terms->query_vars['fields'] );
     440
     441                $terms->set( 'fields', 'ids' );
     442                $this->assertSame( 'ids', $terms->get( 'fields' ) );
     443                $this->assertSame( 'ids', $terms->query_vars['fields'] );
     444
     445                $terms->set( 'fields', '' );
     446                $this->assertSame( '', $terms->get( 'fields' ) );
     447                $this->assertSame( '', $terms->query_vars['fields'] );
     448
     449                $this->assertNull( $terms->get( 'does-not-exist' ) );
     450                $this->assertSame( 'foo', $terms->get( 'does-not-exist', 'foo' ) );
     451        }
     452
     453
    430454}