Make WordPress Core

Ticket #35075: 35075.test.2.patch

File 35075.test.2.patch, 3.1 KB (added by jason_the_adams, 9 years ago)
  • tests/phpunit/tests/comment/query.php

    diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php
    index 5d250ea..7a1ad40 100644
    a b class Tests_Comment_Query extends WP_UnitTestCase { 
    16591659
    16601660        /**
    16611661         * @ticket 22400
     1662         * @ticket 35075
    16621663         */
    1663         public function test_comment_cache_key_should_ignore_custom_params() {
     1664        public function test_comment_cache_key_should_not_ignore_custom_query_vars() {
    16641665                global $wpdb;
    16651666
    16661667                $p = self::factory()->post->create();
    16671668                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    16681669
     1670                $start_num = $wpdb->num_queries;
     1671
    16691672                $q1 = new WP_Comment_Query();
    16701673                $q1->query( array(
    16711674                        'post_id' => $p,
    16721675                        'fields' => 'ids',
    16731676                ) );
    16741677
    1675                 $num_queries = $wpdb->num_queries;
     1678                $pre_cache_num = $wpdb->num_queries;
    16761679
    16771680                $q2 = new WP_Comment_Query();
    16781681                $q2->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16811684                        'foo' => 'bar',
    16821685                ) );
    16831686
    1684                 $this->assertSame( $num_queries, $wpdb->num_queries );
     1687                $this->assertNotEquals( $start_num, $pre_cache_num );
     1688                $this->assertNotEquals( $pre_cache_num, $wpdb->num_queries );
    16851689        }
    16861690
    16871691        /**
  • tests/phpunit/tests/post/getPages.php

    diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php
    index 5391815..4d44545 100644
    a b class Tests_Post_getPages extends WP_UnitTestCase { 
    334334
    335335        }
    336336
     337        /**
     338         * @ticket 35075
     339         */
     340        public function test_comment_cache_key_should_not_ignore_custom_query_vars() {
     341                global $wpdb;
     342
     343                $page_id = self::factory()->post->create( array('post_type' => 'page') );
     344
     345                $start_num = $wpdb->num_queries;
     346
     347                $p1 = get_pages(array(
     348                        'include' => $page_id
     349                ));
     350
     351                $pre_cache_num = $wpdb->num_queries;
     352
     353                $p1 = get_pages(array(
     354                        'include' => $page_id,
     355                        'foo'     => 'bar'
     356                ));
     357
     358                $this->assertNotEquals( $start_num, $pre_cache_num );
     359                $this->assertNotEquals( $pre_cache_num, $wpdb->num_queries );
     360        }
     361
    337362        function test_wp_list_pages_classes() {
    338363                $type = 'taco';
    339364                register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) );
  • tests/phpunit/tests/term/getTerms.php

    diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php
    index bcd3485..7ef51e4 100644
    a b class Tests_Term_getTerms extends WP_UnitTestCase { 
    16651665
    16661666        }
    16671667
     1668        /**
     1669         * @ticket 35075
     1670         */
     1671        public function test_comment_cache_key_should_not_ignore_custom_query_vars() {
     1672                global $wpdb;
     1673
     1674                $term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
     1675
     1676                $start_num = $wpdb->num_queries;
     1677
     1678                $t1 = get_terms('category', array(
     1679                        'include' => $term_id,
     1680                        'fields'  => 'ids'
     1681                ));
     1682
     1683                $pre_cache_num = $wpdb->num_queries;
     1684
     1685                $t2 = get_terms('category', array(
     1686                        'include' => $term_id,
     1687                        'fields'  => 'ids',
     1688                        'foo'     => 'bar'
     1689                ));
     1690
     1691                $this->assertNotEquals( $start_num, $pre_cache_num );
     1692                $this->assertNotEquals( $pre_cache_num, $wpdb->num_queries );
     1693        }
     1694
    16681695        protected function create_hierarchical_terms_and_posts() {
    16691696                $terms = array();
    16701697