Make WordPress Core

Changeset 1066 in tests


Ignore:
Timestamp:
10/02/2012 04:43:07 PM (14 years ago)
Author:
ryan
Message:

Test for empty tax queries returning all posts instead of none. see #WP20604

File:
1 edited

Legend:

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

    r1065 r1066  
    5050    }
    5151
     52    /**
     53     * @ticket 18158
     54     */
    5255    function test_meta_key_not_exists() {
    5356        $post_id = $this->factory->post->create();
    … …  
    110113        $this->assertEquals( 0, count( $posts ) );
    111114    }
     115
     116    /**
     117     * @ticket 20604
     118     */
     119    function test_taxonomy_empty_or() {
     120        // An empty tax query should return an empty array, not all posts.
     121
     122        $this->factory->post->create_many( 10 );
     123
     124        $query = new WP_Query( array(
     125            'fields'    => 'ids',
     126            'tax_query' => array(
     127                'relation' => 'OR',
     128                array(
     129                        'taxonomy' => 'post_tag',
     130                        'field' => 'id',
     131                        'terms' => false,
     132                        'operator' => 'IN'
     133                ),
     134                array(
     135                        'taxonomy' => 'category',
     136                        'field' => 'id',
     137                        'terms' => false,
     138                        'operator' => 'IN'
     139                )
     140            )   
     141        ) );
     142
     143        $posts = $query->get_posts();
     144        $this->assertEquals( 0 , count( $posts ) );
     145    }
    112146}
Note: See TracChangeset for help on using the changeset viewer.