WordPress.org

Make WordPress Core

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

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

Added tests

  • tests/phpunit/tests/comment/query.php

     
    30253025
    30263026                $this->assertEquals( $number_of_queries, $wpdb->num_queries );
    30273027        }
     3028
     3029        /**
     3030         * @ticket 39120
     3031         */
     3032        function test_get_and_set() {
     3033
     3034                $comments = new WP_Comment_Query;
     3035
     3036                $this->assertNull( $comments->get( 'fields' ) );
     3037                $this->assertNull( $comments->query_vars['fields'] );
     3038
     3039                $comments->set( 'fields', 'ids' );
     3040                $this->assertSame( 'ids', $comments->get( 'fields' ) );
     3041                $this->assertSame( 'ids', $comments->query_vars['fields'] );
     3042
     3043                $comments->set( 'fields', '' );
     3044                $this->assertSame( '', $comments->get( 'fields' ) );
     3045                $this->assertSame( '', $comments->query_vars['fields'] );
     3046
     3047                $this->assertNull( $comments->get( 'does-not-exist' ) );
     3048                $this->assertSame( 'foo', $comments->get( 'does-not-exist', 'foo' ) );
     3049        }
     3050
    30283051}