Make WordPress Core


Ignore:
Timestamp:
05/29/2014 08:41:53 PM (12 years ago)
Author:
wonderboymusic
Message:

If post_status is passed to WP_Query as an array containing 'any' and anything else, don't exclude the other values if they match when running any's exclusion logic.

Adds unit tests.

Fixes #28007.

File:
1 edited

Legend:

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

    r28621 r28622  
    742742                $this->assertEqualSets( $ordered, wp_list_pluck( $attached->posts, 'ID' ) );
    743743        }
     744
     745        function test_post_status() {
     746                $statuses1 = get_post_stati();
     747                $this->assertContains( 'auto-draft', $statuses1 );
     748
     749                $statuses2 = get_post_stati( array( 'exclude_from_search' => true ) );
     750                $this->assertContains( 'auto-draft', $statuses2 );
     751
     752                $statuses3 = get_post_stati( array( 'exclude_from_search' => false ) );
     753                $this->assertNotContains( 'auto-draft', $statuses3 );
     754
     755                $q1 = new WP_Query( array( 'post_status' => 'any' ) );
     756                $this->assertContains( "post_status <> 'auto-draft'", $q1->request );
     757
     758                $q2 = new WP_Query( array( 'post_status' => 'any, auto-draft' ) );
     759                $this->assertNotContains( "post_status <> 'auto-draft'", $q2->request );
     760
     761                $q3 = new WP_Query( array( 'post_status' => array( 'any', 'auto-draft' ) ) );
     762                $this->assertNotContains( "post_status <> 'auto-draft'", $q3->request );
     763        }
    744764}
Note: See TracChangeset for help on using the changeset viewer.