Changeset 30771 for trunk/tests/phpunit/tests/query/taxQuery.php
- Timestamp:
- 12/07/2014 02:57:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/taxQuery.php
r28966 r30771 181 181 ) ); 182 182 } 183 184 /** 185 * @group 30623 186 */ 187 public function test_get_queried_object_with_custom_taxonomy_tax_query_and_field_term_id_should_return_term_object() { 188 // Don't override the args provided below. 189 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); 190 191 $args = array( 192 'tax_query' => array( 193 'relation' => 'AND', 194 array( 195 'taxonomy' => 'testtax', 196 'field' => 'term_id', 197 'terms' => array( 198 $this->tax_id, 199 ), 200 ), 201 ) 202 ); 203 204 $q = new WP_Query( $args ); 205 $object = $q->get_queried_object(); 206 207 $expected = get_term( $this->tax_id, 'testtax' ); 208 209 $this->assertEquals( $expected, $object ); 210 } 211 212 /** 213 * @group 30623 214 */ 215 public function test_get_queried_object_with_custom_taxonomy_tax_query_and_field_slug_should_return_term_object() { 216 // Don't override the args provided below. 217 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); 218 219 $args = array( 220 'tax_query' => array( 221 'relation' => 'AND', 222 array( 223 'taxonomy' => 'testtax', 224 'field' => 'slug', 225 'terms' => array( 226 'tax-slug', 227 ), 228 ), 229 ) 230 ); 231 232 $q = new WP_Query( $args ); 233 $object = $q->get_queried_object(); 234 235 $expected = get_term( $this->tax_id, 'testtax' ); 236 237 // Only compare term_id because object_id may or may not be part of either value. 238 $this->assertEquals( $expected->term_id, $object->term_id ); 239 } 240 241 /** 242 * @group 30623 243 */ 244 public function test_get_queried_object_with_custom_taxonomy_tax_query_with_multiple_clauses_should_return_term_object_corresponding_to_the_first_queried_tax() { 245 // Don't override the args provided below. 246 remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); 247 248 register_taxonomy( 'testtax2', 'post' ); 249 $testtax2_term_id = $this->factory->term->create( array( 250 'taxonomy' => 'testtax2', 251 'slug' => 'testtax2-slug', 252 ) ); 253 254 $args = array( 255 'tax_query' => array( 256 'relation' => 'AND', 257 array( 258 'taxonomy' => 'testtax', 259 'field' => 'slug', 260 'terms' => array( 261 'tax-slug', 262 ), 263 ), 264 array( 265 'taxonomy' => 'testtax2', 266 'field' => 'slug', 267 'terms' => array( 268 'testtax2-slug', 269 ), 270 ), 271 ) 272 ); 273 274 $q = new WP_Query( $args ); 275 $object = $q->get_queried_object(); 276 277 $expected = get_term( $this->tax_id, 'testtax' ); 278 279 // Only compare term_id because object_id may or may not be part of either value. 280 $this->assertEquals( $expected->term_id, $object->term_id ); 281 } 183 282 }
Note: See TracChangeset
for help on using the changeset viewer.