Make WordPress Core


Ignore:
Timestamp:
09/29/2015 07:36:16 PM (11 years ago)
Author:
boonebgorges
Message:

WP_Query should not ignore an offset of 0.

Props mazurstas.
Fixes #34060.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query.php

    r34073 r34697  
    460460                $post = get_queried_object();
    461461        }
     462
     463        /**
     464         * @ticket 34060
     465         */
     466        public function test_offset_0_should_override_page() {
     467                $q = new WP_Query( array(
     468                        'paged' => 2,
     469                        'posts_per_page' => 5,
     470                        'offset' => 0,
     471                ) );
     472
     473                $this->assertContains( 'LIMIT 0, 5', $q->request );
     474        }
     475
     476        /**
     477         * @ticket 34060
     478         */
     479        public function test_offset_should_be_ignored_when_not_set() {
     480                $q = new WP_Query( array(
     481                        'paged' => 2,
     482                        'posts_per_page' => 5,
     483                ) );
     484
     485                $this->assertContains( 'LIMIT 5, 5', $q->request );
     486        }
     487
     488        /**
     489         * @ticket 34060
     490         */
     491        public function test_offset_should_be_ignored_when_passed_a_non_numeric_value() {
     492                $q = new WP_Query( array(
     493                        'paged' => 2,
     494                        'posts_per_page' => 5,
     495                        'offset' => '',
     496                ) );
     497
     498                $this->assertContains( 'LIMIT 5, 5', $q->request );
     499        }
    462500}
Note: See TracChangeset for help on using the changeset viewer.