Changeset 33095
- Timestamp:
- 07/06/2015 08:36:18 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r32620 r33095 1868 1868 $term = $q[$t->query_var]; 1869 1869 1870 if ( is_array( $term ) ) { 1871 $term = implode( ',', $term ); 1872 } 1873 1870 1874 if ( strpos($term, '+') !== false ) { 1871 1875 $terms = preg_split( '/[+]+/', $term ); -
trunk/tests/phpunit/tests/query.php
r31662 r33095 134 134 $this->assertContains( "ORDER BY $wpdb->posts.post_title DESC, $wpdb->posts.post_date DESC", $q->request ); 135 135 } 136 137 public function test_custom_taxonomy_querystring_single_term() { 138 register_taxonomy( 'test_tax_cat', 'post' ); 139 140 wp_insert_term( 'test1', 'test_tax_cat' ); 141 wp_insert_term( 'test2', 'test_tax_cat' ); 142 wp_insert_term( 'test3', 'test_tax_cat' ); 143 144 $p1 = $this->factory->post->create(); 145 $p2 = $this->factory->post->create(); 146 $p3 = $this->factory->post->create(); 147 148 wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); 149 wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); 150 wp_set_object_terms( $p3, 'test2', 'test_tax_cat' ); 151 152 $url = add_query_arg( array( 153 'test_tax_cat' => 'test1', 154 ), '/' ); 155 156 $this->go_to( $url ); 157 158 $this->assertEquals( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) ); 159 } 160 161 public function test_custom_taxonomy_querystring_multiple_terms_comma_separated() { 162 register_taxonomy( 'test_tax_cat', 'post' ); 163 164 wp_insert_term( 'test1', 'test_tax_cat' ); 165 wp_insert_term( 'test2', 'test_tax_cat' ); 166 wp_insert_term( 'test3', 'test_tax_cat' ); 167 168 $p1 = $this->factory->post->create(); 169 $p2 = $this->factory->post->create(); 170 $p3 = $this->factory->post->create(); 171 $p4 = $this->factory->post->create(); 172 173 wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); 174 wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); 175 wp_set_object_terms( $p3, 'test2', 'test_tax_cat' ); 176 wp_set_object_terms( $p4, "test3", 'test_tax_cat' ); 177 178 $url = add_query_arg( array( 179 'test_tax_cat' => 'test1,test2', 180 ), '/' ); 181 182 $this->go_to( $url ); 183 184 $this->assertEquals( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) ); 185 } 186 187 /** 188 * @ticket 32454 189 */ 190 public function test_custom_taxonomy_querystring_multiple_terms_formatted_as_array() { 191 register_taxonomy( 'test_tax_cat', 'post' ); 192 193 wp_insert_term( 'test1', 'test_tax_cat' ); 194 wp_insert_term( 'test2', 'test_tax_cat' ); 195 wp_insert_term( 'test3', 'test_tax_cat' ); 196 197 $p1 = $this->factory->post->create(); 198 $p2 = $this->factory->post->create(); 199 $p3 = $this->factory->post->create(); 200 $p4 = $this->factory->post->create(); 201 202 wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); 203 wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); 204 wp_set_object_terms( $p3, 'test2', 'test_tax_cat' ); 205 wp_set_object_terms( $p4, "test3", 'test_tax_cat' ); 206 207 $url = add_query_arg( array( 208 'test_tax_cat' => array( 'test1', 'test2' ), 209 ), '/' ); 210 211 $this->go_to( $url ); 212 213 $this->assertEquals( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) ); 214 } 136 215 }
Note: See TracChangeset
for help on using the changeset viewer.