Changeset 42343 for trunk/tests/phpunit/tests/query/results.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/results.php
r42228 r42343 2 2 3 3 /** 4 *5 4 * Test various query vars and make sure the WP_Query class selects the correct posts. 6 5 * We're testing against a known data set, so we can check that specific posts are included in the output. … … 11 10 protected $q; 12 11 13 static $cat_ids = array();14 static $tag_ids = array();12 static $cat_ids = array(); 13 static $tag_ids = array(); 15 14 static $post_ids = array(); 16 15 … … 24 23 25 24 public static function wpSetUpBeforeClass( $factory ) { 26 self::$cat_ids[] = $cat_a = $factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-a' ) ); 27 self::$cat_ids[] = $cat_b = $factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-b' ) ); 28 self::$cat_ids[] = $cat_c = $factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-c' ) ); 29 30 self::$tag_ids[] = $tag_a = $factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'tag-a' ) ); 31 self::$tag_ids[] = $tag_b = $factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'tag-b' ) ); 32 self::$tag_ids[] = $tag_c = $factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'tag-c' ) ); 33 self::$tag_ids[] = $tag_nun = $factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'tag-נ' ) ); 34 35 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tag-נ', 'tags_input' => array( 'tag-נ' ), 'post_date' => '2008-11-01 00:00:00' ) ); 36 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cats-a-b-c', 'post_date' => '2008-12-01 00:00:00', 'post_category' => array( $cat_a, $cat_b, $cat_c ) ) ); 37 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cats-a-and-b', 'post_date' => '2009-01-01 00:00:00', 'post_category' => array( $cat_a, $cat_b ) ) ); 38 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cats-b-and-c', 'post_date' => '2009-02-01 00:00:00', 'post_category' => array( $cat_b, $cat_c ) ) ); 39 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cats-a-and-c', 'post_date' => '2009-03-01 00:00:00', 'post_category' => array( $cat_a, $cat_c ) ) ); 40 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cat-a', 'post_date' => '2009-04-01 00:00:00', 'post_category' => array( $cat_a ) ) ); 41 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cat-b', 'post_date' => '2009-05-01 00:00:00', 'post_category' => array( $cat_b ) ) ); 42 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'cat-c', 'post_date' => '2009-06-01 00:00:00', 'post_category' => array( $cat_c ) ) ); 43 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'lorem-ipsum', 'post_date' => '2009-07-01 00:00:00' ) ); 44 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'comment-test', 'post_date' => '2009-08-01 00:00:00' ) ); 45 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'one-trackback', 'post_date' => '2009-09-01 00:00:00' ) ); 46 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'many-trackbacks', 'post_date' => '2009-10-01 00:00:00' ) ); 47 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'no-comments', 'post_date' => '2009-10-01 00:00:00' ) ); 48 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'one-comment', 'post_date' => '2009-11-01 00:00:00' ) ); 49 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'contributor-post-approved', 'post_date' => '2009-12-01 00:00:00' ) ); 50 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'embedded-video', 'post_date' => '2010-01-01 00:00:00' ) ); 51 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'simple-markup-test', 'post_date' => '2010-02-01 00:00:00' ) ); 52 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'raw-html-code', 'post_date' => '2010-03-01 00:00:00' ) ); 53 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tags-a-b-c', 'tags_input' => array( 'tag-a', 'tag-b', 'tag-c' ), 'post_date' => '2010-04-01 00:00:00' ) ); 54 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tag-a', 'tags_input' => array( 'tag-a' ), 'post_date' => '2010-05-01 00:00:00' ) ); 55 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tag-b', 'tags_input' => array( 'tag-b' ), 'post_date' => '2010-06-01 00:00:00' ) ); 56 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tag-c', 'tags_input' => array( 'tag-c' ), 'post_date' => '2010-07-01 00:00:00' ) ); 57 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tags-a-and-b', 'tags_input' => array( 'tag-a', 'tag-b' ), 'post_date' => '2010-08-01 00:00:00' ) ); 58 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tags-b-and-c', 'tags_input' => array( 'tag-b', 'tag-c' ), 'post_date' => '2010-09-01 00:00:00' ) ); 59 self::$post_ids[] = $factory->post->create( array( 'post_title' => 'tags-a-and-c', 'tags_input' => array( 'tag-a', 'tag-c' ), 'post_date' => '2010-10-01 00:00:00' ) ); 60 61 self::$post_ids[] = self::$parent_one = $factory->post->create( array( 'post_title' => 'parent-one', 'post_date' => '2007-01-01 00:00:00' ) ); 62 self::$post_ids[] = self::$parent_two = $factory->post->create( array( 'post_title' => 'parent-two', 'post_date' => '2007-01-01 00:00:00' ) ); 63 self::$post_ids[] = self::$parent_three = $factory->post->create( array( 'post_title' => 'parent-three', 'post_date' => '2007-01-01 00:00:00' ) ); 64 self::$post_ids[] = self::$child_one = $factory->post->create( array( 'post_title' => 'child-one', 'post_parent' => self::$parent_one, 'post_date' => '2007-01-01 00:00:01' ) ); 65 self::$post_ids[] = self::$child_two = $factory->post->create( array( 'post_title' => 'child-two', 'post_parent' => self::$parent_one, 'post_date' => '2007-01-01 00:00:02' ) ); 66 self::$post_ids[] = self::$child_three = $factory->post->create( array( 'post_title' => 'child-three', 'post_parent' => self::$parent_two, 'post_date' => '2007-01-01 00:00:03' ) ); 67 self::$post_ids[] = self::$child_four = $factory->post->create( array( 'post_title' => 'child-four', 'post_parent' => self::$parent_two, 'post_date' => '2007-01-01 00:00:04' ) ); 25 self::$cat_ids[] = $cat_a = $factory->term->create( 26 array( 27 'taxonomy' => 'category', 28 'name' => 'cat-a', 29 ) 30 ); 31 self::$cat_ids[] = $cat_b = $factory->term->create( 32 array( 33 'taxonomy' => 'category', 34 'name' => 'cat-b', 35 ) 36 ); 37 self::$cat_ids[] = $cat_c = $factory->term->create( 38 array( 39 'taxonomy' => 'category', 40 'name' => 'cat-c', 41 ) 42 ); 43 44 self::$tag_ids[] = $tag_a = $factory->term->create( 45 array( 46 'taxonomy' => 'post_tag', 47 'name' => 'tag-a', 48 ) 49 ); 50 self::$tag_ids[] = $tag_b = $factory->term->create( 51 array( 52 'taxonomy' => 'post_tag', 53 'name' => 'tag-b', 54 ) 55 ); 56 self::$tag_ids[] = $tag_c = $factory->term->create( 57 array( 58 'taxonomy' => 'post_tag', 59 'name' => 'tag-c', 60 ) 61 ); 62 self::$tag_ids[] = $tag_nun = $factory->term->create( 63 array( 64 'taxonomy' => 'post_tag', 65 'name' => 'tag-נ', 66 ) 67 ); 68 69 self::$post_ids[] = $factory->post->create( 70 array( 71 'post_title' => 'tag-נ', 72 'tags_input' => array( 'tag-נ' ), 73 'post_date' => '2008-11-01 00:00:00', 74 ) 75 ); 76 self::$post_ids[] = $factory->post->create( 77 array( 78 'post_title' => 'cats-a-b-c', 79 'post_date' => '2008-12-01 00:00:00', 80 'post_category' => array( $cat_a, $cat_b, $cat_c ), 81 ) 82 ); 83 self::$post_ids[] = $factory->post->create( 84 array( 85 'post_title' => 'cats-a-and-b', 86 'post_date' => '2009-01-01 00:00:00', 87 'post_category' => array( $cat_a, $cat_b ), 88 ) 89 ); 90 self::$post_ids[] = $factory->post->create( 91 array( 92 'post_title' => 'cats-b-and-c', 93 'post_date' => '2009-02-01 00:00:00', 94 'post_category' => array( $cat_b, $cat_c ), 95 ) 96 ); 97 self::$post_ids[] = $factory->post->create( 98 array( 99 'post_title' => 'cats-a-and-c', 100 'post_date' => '2009-03-01 00:00:00', 101 'post_category' => array( $cat_a, $cat_c ), 102 ) 103 ); 104 self::$post_ids[] = $factory->post->create( 105 array( 106 'post_title' => 'cat-a', 107 'post_date' => '2009-04-01 00:00:00', 108 'post_category' => array( $cat_a ), 109 ) 110 ); 111 self::$post_ids[] = $factory->post->create( 112 array( 113 'post_title' => 'cat-b', 114 'post_date' => '2009-05-01 00:00:00', 115 'post_category' => array( $cat_b ), 116 ) 117 ); 118 self::$post_ids[] = $factory->post->create( 119 array( 120 'post_title' => 'cat-c', 121 'post_date' => '2009-06-01 00:00:00', 122 'post_category' => array( $cat_c ), 123 ) 124 ); 125 self::$post_ids[] = $factory->post->create( 126 array( 127 'post_title' => 'lorem-ipsum', 128 'post_date' => '2009-07-01 00:00:00', 129 ) 130 ); 131 self::$post_ids[] = $factory->post->create( 132 array( 133 'post_title' => 'comment-test', 134 'post_date' => '2009-08-01 00:00:00', 135 ) 136 ); 137 self::$post_ids[] = $factory->post->create( 138 array( 139 'post_title' => 'one-trackback', 140 'post_date' => '2009-09-01 00:00:00', 141 ) 142 ); 143 self::$post_ids[] = $factory->post->create( 144 array( 145 'post_title' => 'many-trackbacks', 146 'post_date' => '2009-10-01 00:00:00', 147 ) 148 ); 149 self::$post_ids[] = $factory->post->create( 150 array( 151 'post_title' => 'no-comments', 152 'post_date' => '2009-10-01 00:00:00', 153 ) 154 ); 155 self::$post_ids[] = $factory->post->create( 156 array( 157 'post_title' => 'one-comment', 158 'post_date' => '2009-11-01 00:00:00', 159 ) 160 ); 161 self::$post_ids[] = $factory->post->create( 162 array( 163 'post_title' => 'contributor-post-approved', 164 'post_date' => '2009-12-01 00:00:00', 165 ) 166 ); 167 self::$post_ids[] = $factory->post->create( 168 array( 169 'post_title' => 'embedded-video', 170 'post_date' => '2010-01-01 00:00:00', 171 ) 172 ); 173 self::$post_ids[] = $factory->post->create( 174 array( 175 'post_title' => 'simple-markup-test', 176 'post_date' => '2010-02-01 00:00:00', 177 ) 178 ); 179 self::$post_ids[] = $factory->post->create( 180 array( 181 'post_title' => 'raw-html-code', 182 'post_date' => '2010-03-01 00:00:00', 183 ) 184 ); 185 self::$post_ids[] = $factory->post->create( 186 array( 187 'post_title' => 'tags-a-b-c', 188 'tags_input' => array( 'tag-a', 'tag-b', 'tag-c' ), 189 'post_date' => '2010-04-01 00:00:00', 190 ) 191 ); 192 self::$post_ids[] = $factory->post->create( 193 array( 194 'post_title' => 'tag-a', 195 'tags_input' => array( 'tag-a' ), 196 'post_date' => '2010-05-01 00:00:00', 197 ) 198 ); 199 self::$post_ids[] = $factory->post->create( 200 array( 201 'post_title' => 'tag-b', 202 'tags_input' => array( 'tag-b' ), 203 'post_date' => '2010-06-01 00:00:00', 204 ) 205 ); 206 self::$post_ids[] = $factory->post->create( 207 array( 208 'post_title' => 'tag-c', 209 'tags_input' => array( 'tag-c' ), 210 'post_date' => '2010-07-01 00:00:00', 211 ) 212 ); 213 self::$post_ids[] = $factory->post->create( 214 array( 215 'post_title' => 'tags-a-and-b', 216 'tags_input' => array( 'tag-a', 'tag-b' ), 217 'post_date' => '2010-08-01 00:00:00', 218 ) 219 ); 220 self::$post_ids[] = $factory->post->create( 221 array( 222 'post_title' => 'tags-b-and-c', 223 'tags_input' => array( 'tag-b', 'tag-c' ), 224 'post_date' => '2010-09-01 00:00:00', 225 ) 226 ); 227 self::$post_ids[] = $factory->post->create( 228 array( 229 'post_title' => 'tags-a-and-c', 230 'tags_input' => array( 'tag-a', 'tag-c' ), 231 'post_date' => '2010-10-01 00:00:00', 232 ) 233 ); 234 235 self::$post_ids[] = self::$parent_one = $factory->post->create( 236 array( 237 'post_title' => 'parent-one', 238 'post_date' => '2007-01-01 00:00:00', 239 ) 240 ); 241 self::$post_ids[] = self::$parent_two = $factory->post->create( 242 array( 243 'post_title' => 'parent-two', 244 'post_date' => '2007-01-01 00:00:00', 245 ) 246 ); 247 self::$post_ids[] = self::$parent_three = $factory->post->create( 248 array( 249 'post_title' => 'parent-three', 250 'post_date' => '2007-01-01 00:00:00', 251 ) 252 ); 253 self::$post_ids[] = self::$child_one = $factory->post->create( 254 array( 255 'post_title' => 'child-one', 256 'post_parent' => self::$parent_one, 257 'post_date' => '2007-01-01 00:00:01', 258 ) 259 ); 260 self::$post_ids[] = self::$child_two = $factory->post->create( 261 array( 262 'post_title' => 'child-two', 263 'post_parent' => self::$parent_one, 264 'post_date' => '2007-01-01 00:00:02', 265 ) 266 ); 267 self::$post_ids[] = self::$child_three = $factory->post->create( 268 array( 269 'post_title' => 'child-three', 270 'post_parent' => self::$parent_two, 271 'post_date' => '2007-01-01 00:00:03', 272 ) 273 ); 274 self::$post_ids[] = self::$child_four = $factory->post->create( 275 array( 276 'post_title' => 'child-four', 277 'post_parent' => self::$parent_two, 278 'post_date' => '2007-01-01 00:00:04', 279 ) 280 ); 68 281 } 69 282 … … 76 289 77 290 function test_query_default() { 78 $posts = $this->q->query( '');291 $posts = $this->q->query( '' ); 79 292 80 293 // the output should be the most recent 10 posts as listed here … … 96 309 97 310 function test_query_tag_a() { 98 $posts = $this->q->query( 'tag=tag-a');311 $posts = $this->q->query( 'tag=tag-a' ); 99 312 100 313 // there are 4 posts with Tag A … … 107 320 108 321 function test_query_tag_b() { 109 $posts = $this->q->query( 'tag=tag-b');322 $posts = $this->q->query( 'tag=tag-b' ); 110 323 111 324 // there are 4 posts with Tag A … … 121 334 */ 122 335 function test_query_tag_nun() { 123 $posts = $this->q->query( 'tag=tag-נ');336 $posts = $this->q->query( 'tag=tag-נ' ); 124 337 125 338 // there is 1 post with Tag נ … … 129 342 130 343 function test_query_tag_id() { 131 $tag = tag_exists('tag-a');132 $posts = $this->q->query( "tag_id=". $tag['term_id'] );344 $tag = tag_exists( 'tag-a' ); 345 $posts = $this->q->query( 'tag_id=' . $tag['term_id'] ); 133 346 134 347 // there are 4 posts with Tag A … … 141 354 142 355 function test_query_tag_slug__in() { 143 $posts = $this->q->query( "tag_slug__in[]=tag-b&tag_slug__in[]=tag-c");356 $posts = $this->q->query( 'tag_slug__in[]=tag-b&tag_slug__in[]=tag-c' ); 144 357 145 358 // there are 4 posts with either Tag B or Tag C … … 155 368 156 369 function test_query_tag__in() { 157 $tag_a = tag_exists( 'tag-a');158 $tag_b = tag_exists( 'tag-b');159 $posts = $this->q->query( "tag__in[]=". $tag_a['term_id'] . "&tag__in[]=". $tag_b['term_id'] );370 $tag_a = tag_exists( 'tag-a' ); 371 $tag_b = tag_exists( 'tag-b' ); 372 $posts = $this->q->query( 'tag__in[]=' . $tag_a['term_id'] . '&tag__in[]=' . $tag_b['term_id'] ); 160 373 161 374 // there are 6 posts with either Tag A or Tag B … … 170 383 171 384 function test_query_tag__not_in() { 172 $tag_a = tag_exists( 'tag-a');173 $posts = $this->q->query( "tag__not_in[]=". $tag_a['term_id'] );385 $tag_a = tag_exists( 'tag-a' ); 386 $posts = $this->q->query( 'tag__not_in[]=' . $tag_a['term_id'] ); 174 387 175 388 // the most recent 10 posts with Tag A excluded 176 389 // (note the different between this and test_query_default) 177 $expected = array 390 $expected = array( 178 391 0 => 'tags-b-and-c', 179 392 1 => 'tag-c', … … 192 405 193 406 function test_query_tag__in_but__not_in() { 194 $tag_a = tag_exists( 'tag-a');195 $tag_b = tag_exists( 'tag-b');196 $posts = $this->q->query( "tag__in[]=" . $tag_a['term_id'] . "&tag__not_in[]=". $tag_b['term_id'] );407 $tag_a = tag_exists( 'tag-a' ); 408 $tag_b = tag_exists( 'tag-b' ); 409 $posts = $this->q->query( 'tag__in[]=' . $tag_a['term_id'] . '&tag__not_in[]=' . $tag_b['term_id'] ); 197 410 198 411 // there are 4 posts with Tag A, only 2 when we exclude Tag B … … 205 418 206 419 function test_query_category_name() { 207 $posts = $this->q->query( 'category_name=cat-a');420 $posts = $this->q->query( 'category_name=cat-a' ); 208 421 209 422 // there are 4 posts with Cat A, we'll check for them by name … … 216 429 217 430 function test_query_cat() { 218 $cat = category_exists('cat-b');219 $posts = $this->q->query( "cat=$cat");431 $cat = category_exists( 'cat-b' ); 432 $posts = $this->q->query( "cat=$cat" ); 220 433 221 434 // there are 4 posts with Cat B … … 228 441 229 442 function test_query_posts_per_page() { 230 $posts = $this->q->query( 'posts_per_page=5');231 232 $expected = array 443 $posts = $this->q->query( 'posts_per_page=5' ); 444 445 $expected = array( 233 446 0 => 'tags-a-and-c', 234 447 1 => 'tags-b-and-c', … … 243 456 244 457 function test_query_offset() { 245 $posts = $this->q->query( 'offset=2');246 247 $expected = array 458 $posts = $this->q->query( 'offset=2' ); 459 460 $expected = array( 248 461 0 => 'tags-a-and-b', 249 462 1 => 'tag-c', … … 263 476 264 477 function test_query_paged() { 265 $posts = $this->q->query( 'paged=2');266 267 $expected = array 478 $posts = $this->q->query( 'paged=2' ); 479 480 $expected = array( 268 481 0 => 'contributor-post-approved', 269 482 1 => 'one-comment', … … 284 497 285 498 function test_query_paged_and_posts_per_page() { 286 $posts = $this->q->query( 'paged=4&posts_per_page=4');287 288 $expected = array 499 $posts = $this->q->query( 'paged=4&posts_per_page=4' ); 500 501 $expected = array( 289 502 0 => 'no-comments', 290 503 1 => 'many-trackbacks', … … 303 516 function test_query_post_parent__in() { 304 517 // Query for first parent's children 305 $posts = $this->q->query( array( 306 'post_parent__in' => array( self::$parent_one ), 307 'orderby' => 'date', 308 'order' => 'asc', 309 ) ); 310 311 $this->assertEquals( array( 312 'child-one', 313 'child-two', 314 ), wp_list_pluck( $posts, 'post_title' ) ); 518 $posts = $this->q->query( 519 array( 520 'post_parent__in' => array( self::$parent_one ), 521 'orderby' => 'date', 522 'order' => 'asc', 523 ) 524 ); 525 526 $this->assertEquals( 527 array( 528 'child-one', 529 'child-two', 530 ), wp_list_pluck( $posts, 'post_title' ) 531 ); 315 532 316 533 // Second parent's children 317 $posts = $this->q->query( array( 318 'post_parent__in' => array( self::$parent_two ), 319 'orderby' => 'date', 320 'order' => 'asc', 321 ) ); 322 323 $this->assertEquals( array( 324 'child-three', 325 'child-four', 326 ), wp_list_pluck( $posts, 'post_title' ) ); 534 $posts = $this->q->query( 535 array( 536 'post_parent__in' => array( self::$parent_two ), 537 'orderby' => 'date', 538 'order' => 'asc', 539 ) 540 ); 541 542 $this->assertEquals( 543 array( 544 'child-three', 545 'child-four', 546 ), wp_list_pluck( $posts, 'post_title' ) 547 ); 327 548 328 549 // Both first and second parent's children 329 $posts = $this->q->query( array( 330 'post_parent__in' => array( self::$parent_one, self::$parent_two ), 331 'orderby' => 'date', 332 'order' => 'asc', 333 ) ); 334 335 $this->assertEquals( array( 336 'child-one', 337 'child-two', 338 'child-three', 339 'child-four', 340 ), wp_list_pluck( $posts, 'post_title' ) ); 550 $posts = $this->q->query( 551 array( 552 'post_parent__in' => array( self::$parent_one, self::$parent_two ), 553 'orderby' => 'date', 554 'order' => 'asc', 555 ) 556 ); 557 558 $this->assertEquals( 559 array( 560 'child-one', 561 'child-two', 562 'child-three', 563 'child-four', 564 ), wp_list_pluck( $posts, 'post_title' ) 565 ); 341 566 342 567 // Third parent's children 343 $posts = $this->q->query( array( 344 'post_parent__in' => array( self::$parent_three ), 345 ) ); 568 $posts = $this->q->query( 569 array( 570 'post_parent__in' => array( self::$parent_three ), 571 ) 572 ); 346 573 347 574 $this->assertEquals( array(), wp_list_pluck( $posts, 'post_title' ) ); … … 352 579 */ 353 580 function test_query_orderby_post_parent__in() { 354 $posts = $this->q->query( array( 355 'post_parent__in' => array( self::$parent_two, self::$parent_one ), 356 'orderby' => 'post_parent__in', 357 'order' => 'asc', 358 ) ); 359 360 $this->assertEquals( array( 361 'child-three', 362 'child-four', 363 'child-one', 364 'child-two', 365 ), wp_list_pluck( $posts, 'post_title' ) ); 581 $posts = $this->q->query( 582 array( 583 'post_parent__in' => array( self::$parent_two, self::$parent_one ), 584 'orderby' => 'post_parent__in', 585 'order' => 'asc', 586 ) 587 ); 588 589 $this->assertEquals( 590 array( 591 'child-three', 592 'child-four', 593 'child-one', 594 'child-two', 595 ), wp_list_pluck( $posts, 'post_title' ) 596 ); 366 597 } 367 598 … … 370 601 */ 371 602 function test_query_orderby_post_parent__in_with_order_desc() { 372 $post_parent__in_array = array( self::$parent_two, self::$parent_one );603 $post_parent__in_array = array( self::$parent_two, self::$parent_one ); 373 604 $expected_returned_array = array( 'child-three', 'child-four', 'child-one', 'child-two' ); 374 605 375 $posts = $this->q->query( array( 376 'post_parent__in' => $post_parent__in_array, 377 'orderby' => 'post_parent__in', 378 'order' => 'desc', 379 ) ); 606 $posts = $this->q->query( 607 array( 608 'post_parent__in' => $post_parent__in_array, 609 'orderby' => 'post_parent__in', 610 'order' => 'desc', 611 ) 612 ); 380 613 381 614 // order=desc does not influence the order of returned results (returns same order as order=asc) … … 387 620 */ 388 621 function test_query_orderby_post__in_with_no_order_specified() { 389 $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );622 $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); 390 623 $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); 391 624 392 $q = new WP_Query( array( 393 'post__in' => $post__in_array, 394 'orderby' => 'post__in', 395 'fields' => 'ids' 396 ) ); 625 $q = new WP_Query( 626 array( 627 'post__in' => $post__in_array, 628 'orderby' => 'post__in', 629 'fields' => 'ids', 630 ) 631 ); 397 632 398 633 // Expect post ids in the same order as post__in array when no 'order' param is passed in … … 404 639 */ 405 640 function test_query_orderby_post__in_with_order_asc() { 406 $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );641 $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); 407 642 $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); 408 643 409 $q = new WP_Query( array( 410 'post__in' => $post__in_array, 411 'orderby' => 'post__in', 412 'order' => 'asc', 413 'fields' => 'ids' 414 ) ); 644 $q = new WP_Query( 645 array( 646 'post__in' => $post__in_array, 647 'orderby' => 'post__in', 648 'order' => 'asc', 649 'fields' => 'ids', 650 ) 651 ); 415 652 416 653 // Expect post ids in the same order as post__in array when order=asc is passed in … … 422 659 */ 423 660 function test_query_orderby_post__in_with_order_desc() { 424 $post__in_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] );661 $post__in_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] ); 425 662 $expected_returned_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] ); 426 663 427 $q = new WP_Query( array( 428 'post__in' => $post__in_array, 429 'orderby' => 'post__in', 430 'order' => 'desc', 431 'fields' => 'ids' 432 ) ); 664 $q = new WP_Query( 665 array( 666 'post__in' => $post__in_array, 667 'orderby' => 'post__in', 668 'order' => 'desc', 669 'fields' => 'ids', 670 ) 671 ); 433 672 434 673 // Note that results are returned in the order specified in the post__in array … … 443 682 $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' ); 444 683 445 $q = new WP_Query( array( 446 'post_name__in' => $post_name__in_array, 447 'orderby' => 'post_name__in', 448 'order' => 'asc' 449 ) ); 684 $q = new WP_Query( 685 array( 686 'post_name__in' => $post_name__in_array, 687 'orderby' => 'post_name__in', 688 'order' => 'asc', 689 ) 690 ); 450 691 451 692 $this->assertSame( $post_name__in_array, array_unique( wp_list_pluck( $q->posts, 'post_title' ) ) ); … … 458 699 $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' ); 459 700 460 $q = new WP_Query( array( 461 'post_name__in' => $post_name__in_array, 462 'orderby' => 'post_name__in', 463 'order' => 'desc' 464 ) ); 701 $q = new WP_Query( 702 array( 703 'post_name__in' => $post_name__in_array, 704 'orderby' => 'post_name__in', 705 'order' => 'desc', 706 ) 707 ); 465 708 466 709 // order=desc does not influence the order of returned results (returns same order as order=asc) … … 476 719 $parents = array( 477 720 (int) self::$parent_one, 478 (int) self::$parent_two 479 ); 480 $posts1 = $this->q->query( array( 481 'post__in' => $parents, 482 'fields' => 'ids', 483 'orderby' => 'post__in', 484 ) ); 721 (int) self::$parent_two, 722 ); 723 $posts1 = $this->q->query( 724 array( 725 'post__in' => $parents, 726 'fields' => 'ids', 727 'orderby' => 'post__in', 728 ) 729 ); 485 730 486 731 $this->assertSame( $parents, $posts1 ); … … 489 734 $children = array( 490 735 (int) self::$child_one => (int) self::$parent_one, 491 (int) self::$child_two => (int) self::$parent_one 492 ); 493 494 $posts2 = $this->q->query( array( 495 'post__in' => array_keys( $children ), 496 'fields' => 'id=>parent', 497 'orderby' => 'post__in', 498 ) ); 736 (int) self::$child_two => (int) self::$parent_one, 737 ); 738 739 $posts2 = $this->q->query( 740 array( 741 'post__in' => array_keys( $children ), 742 'fields' => 'id=>parent', 743 'orderby' => 'post__in', 744 ) 745 ); 499 746 500 747 $this->assertSame( $children, $posts2 ); … … 524 771 function test_exclude_from_search_empty() { 525 772 global $wp_post_types; 526 foreach ( array_keys( $wp_post_types ) as $slug ) 527 $wp_post_types[$slug]->exclude_from_search = true; 773 foreach ( array_keys( $wp_post_types ) as $slug ) { 774 $wp_post_types[ $slug ]->exclude_from_search = true; 775 } 528 776 529 777 $posts = $this->q->query( array( 'post_type' => 'any' ) ); … … 532 780 $this->assertRegExp( '#AND 1=0#', $this->q->request ); 533 781 534 foreach ( array_keys( $wp_post_types ) as $slug ) 535 $wp_post_types[$slug]->exclude_from_search = false; 782 foreach ( array_keys( $wp_post_types ) as $slug ) { 783 $wp_post_types[ $slug ]->exclude_from_search = false; 784 } 536 785 537 786 $posts2 = $this->q->query( array( 'post_type' => 'any' ) ); … … 545 794 */ 546 795 function test_query_author_vars() { 547 $author_1 = self::factory()->user->create( array( 'user_login' => 'author1', 'role' => 'author' ) ); 548 $post_1 = self::factory()->post->create( array( 'post_title' => 'Post 1', 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); 549 550 $author_2 = self::factory()->user->create( array( 'user_login' => 'author2', 'role' => 'author' ) ); 551 $post_2 = self::factory()->post->create( array( 'post_title' => 'Post 2', 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); 552 553 $author_3 = self::factory()->user->create( array( 'user_login' => 'author3', 'role' => 'author' ) ); 554 $post_3 = self::factory()->post->create( array( 'post_title' => 'Post 3', 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); 555 556 $author_4 = self::factory()->user->create( array( 'user_login' => 'author4', 'role' => 'author' ) ); 557 $post_4 = self::factory()->post->create( array( 'post_title' => 'Post 4', 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); 558 559 $posts = $this->q->query( array( 560 'author' => '', 561 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 562 ) ); 796 $author_1 = self::factory()->user->create( 797 array( 798 'user_login' => 'author1', 799 'role' => 'author', 800 ) 801 ); 802 $post_1 = self::factory()->post->create( 803 array( 804 'post_title' => 'Post 1', 805 'post_author' => $author_1, 806 'post_date' => '2007-01-01 00:00:00', 807 ) 808 ); 809 810 $author_2 = self::factory()->user->create( 811 array( 812 'user_login' => 'author2', 813 'role' => 'author', 814 ) 815 ); 816 $post_2 = self::factory()->post->create( 817 array( 818 'post_title' => 'Post 2', 819 'post_author' => $author_2, 820 'post_date' => '2007-01-01 00:00:00', 821 ) 822 ); 823 824 $author_3 = self::factory()->user->create( 825 array( 826 'user_login' => 'author3', 827 'role' => 'author', 828 ) 829 ); 830 $post_3 = self::factory()->post->create( 831 array( 832 'post_title' => 'Post 3', 833 'post_author' => $author_3, 834 'post_date' => '2007-01-01 00:00:00', 835 ) 836 ); 837 838 $author_4 = self::factory()->user->create( 839 array( 840 'user_login' => 'author4', 841 'role' => 'author', 842 ) 843 ); 844 $post_4 = self::factory()->post->create( 845 array( 846 'post_title' => 'Post 4', 847 'post_author' => $author_4, 848 'post_date' => '2007-01-01 00:00:00', 849 ) 850 ); 851 852 $posts = $this->q->query( 853 array( 854 'author' => '', 855 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 856 ) 857 ); 563 858 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 564 859 $this->assertEqualSets( array( $author_1, $author_2, $author_3, $author_4 ), $author_ids ); 565 860 566 $posts = $this->q->query( array( 567 'author' => 0, 568 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 569 ) ); 861 $posts = $this->q->query( 862 array( 863 'author' => 0, 864 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 865 ) 866 ); 570 867 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 571 868 $this->assertEqualSets( array( $author_1, $author_2, $author_3, $author_4 ), $author_ids ); 572 869 573 $posts = $this->q->query( array( 574 'author' => '0', 575 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 576 ) ); 870 $posts = $this->q->query( 871 array( 872 'author' => '0', 873 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 874 ) 875 ); 577 876 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 578 877 $this->assertEqualSets( array( $author_1, $author_2, $author_3, $author_4 ), $author_ids ); 579 878 580 $posts = $this->q->query( array( 581 'author' => $author_1, 582 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 583 ) ); 879 $posts = $this->q->query( 880 array( 881 'author' => $author_1, 882 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 883 ) 884 ); 584 885 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 585 886 $this->assertEqualSets( array( $author_1 ), $author_ids ); 586 887 587 $posts = $this->q->query( array( 588 'author' => "$author_1", 589 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 590 ) ); 888 $posts = $this->q->query( 889 array( 890 'author' => "$author_1", 891 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 892 ) 893 ); 591 894 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 592 895 $this->assertEqualSets( array( $author_1 ), $author_ids ); 593 896 594 $posts = $this->q->query( array( 595 'author' => "{$author_1},{$author_2}", 596 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 597 ) ); 897 $posts = $this->q->query( 898 array( 899 'author' => "{$author_1},{$author_2}", 900 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 901 ) 902 ); 598 903 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 599 904 $this->assertEqualSets( array( $author_1, $author_2 ), $author_ids ); 600 905 601 $posts = $this->q->query( array( 602 'author' => "-{$author_1},{$author_2}", 603 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 604 ) ); 906 $posts = $this->q->query( 907 array( 908 'author' => "-{$author_1},{$author_2}", 909 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 910 ) 911 ); 605 912 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 606 913 $this->assertEqualSets( array( $author_2, $author_3, $author_4 ), $author_ids ); 607 914 608 $posts = $this->q->query( array( 609 'author' => "{$author_1},-{$author_2}", 610 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 611 ) ); 915 $posts = $this->q->query( 916 array( 917 'author' => "{$author_1},-{$author_2}", 918 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 919 ) 920 ); 612 921 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 613 922 $this->assertEqualSets( array( $author_1, $author_3, $author_4 ), $author_ids ); 614 923 615 $posts = $this->q->query( array( 616 'author' => "-{$author_1},-{$author_2}", 617 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 618 ) ); 924 $posts = $this->q->query( 925 array( 926 'author' => "-{$author_1},-{$author_2}", 927 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 928 ) 929 ); 619 930 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 620 931 $this->assertEqualSets( array( $author_3, $author_4 ), $author_ids ); 621 932 622 $posts = $this->q->query( array( 623 'author__in' => array( $author_1, $author_2 ), 624 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 625 ) ); 933 $posts = $this->q->query( 934 array( 935 'author__in' => array( $author_1, $author_2 ), 936 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 937 ) 938 ); 626 939 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 627 940 $this->assertEqualSets( array( $author_1, $author_2 ), $author_ids ); … … 630 943 $this->assertNotEmpty( $posts ); 631 944 632 $posts = $this->q->query( array( 633 'author__not_in' => array( $author_1, $author_2 ), 634 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 635 ) ); 945 $posts = $this->q->query( 946 array( 947 'author__not_in' => array( $author_1, $author_2 ), 948 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 949 ) 950 ); 636 951 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 637 952 $this->assertEqualSets( array( $author_3, $author_4 ), $author_ids ); 638 953 639 $posts = $this->q->query( array( 640 'author_name' => 'author1', 641 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 642 ) ); 954 $posts = $this->q->query( 955 array( 956 'author_name' => 'author1', 957 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ), 958 ) 959 ); 643 960 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); 644 961 $this->assertEqualSets( array( $author_1 ), $author_ids ); … … 649 966 */ 650 967 function test_query_is_date() { 651 $this->q->query( array( 652 'year' => '2007', 653 'monthnum' => '01', 654 'day' => '01', 655 ) ); 968 $this->q->query( 969 array( 970 'year' => '2007', 971 'monthnum' => '01', 972 'day' => '01', 973 ) 974 ); 656 975 657 976 $this->assertTrue( $this->q->is_date ); … … 660 979 $this->assertFalse( $this->q->is_year ); 661 980 662 $this->q->query( array( 663 'year' => '2007', 664 'monthnum' => '01', 665 ) ); 981 $this->q->query( 982 array( 983 'year' => '2007', 984 'monthnum' => '01', 985 ) 986 ); 666 987 667 988 $this->assertTrue( $this->q->is_date ); … … 670 991 $this->assertFalse( $this->q->is_year ); 671 992 672 $this->q->query( array( 673 'year' => '2007', 674 ) ); 993 $this->q->query( 994 array( 995 'year' => '2007', 996 ) 997 ); 675 998 676 999 $this->assertTrue( $this->q->is_date ); … … 685 1008 */ 686 1009 public function test_query_is_date_with_bad_date() { 687 $this->q->query( array( 688 'year' => '2007', 689 'monthnum' => '01', 690 'day' => '50', 691 ) ); 1010 $this->q->query( 1011 array( 1012 'year' => '2007', 1013 'monthnum' => '01', 1014 'day' => '50', 1015 ) 1016 ); 692 1017 693 1018 $this->assertTrue( $this->q->is_404 ); … … 700 1025 function test_perm_with_status_array() { 701 1026 global $wpdb; 702 $this->q->query( array( 'perm' => 'readable', 'post_status' => array( 'publish', 'private' ) ) ); 1027 $this->q->query( 1028 array( 1029 'perm' => 'readable', 1030 'post_status' => array( 'publish', 'private' ), 1031 ) 1032 ); 703 1033 $this->assertTrue( $this->q->have_posts() ); 704 $this->assertContains( "(({$wpdb->posts}.post_status = 'publish') OR ({$wpdb->posts}.post_author = 0 AND ({$wpdb->posts}.post_status = 'private')))", 1034 $this->assertContains( 1035 "(({$wpdb->posts}.post_status = 'publish') OR ({$wpdb->posts}.post_author = 0 AND ({$wpdb->posts}.post_status = 'private')))", 705 1036 $this->q->request 706 1037 ); … … 716 1047 $three = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) ); 717 1048 718 $args = array( 'post__in' => array( $one, $two, $three ), 'fields' => 'ids' ); 1049 $args = array( 1050 'post__in' => array( $one, $two, $three ), 1051 'fields' => 'ids', 1052 ); 719 1053 720 1054 $result1 = $this->q->query( array_merge( $args, array( 'has_password' => true ) ) ); … … 728 1062 729 1063 // If both arguments are passed, only post_password is considered. 730 $result4 = $this->q->query( array_merge( $args, array( 'has_password' => true, 'post_password' => '' ) ) ); 1064 $result4 = $this->q->query( 1065 array_merge( 1066 $args, array( 1067 'has_password' => true, 1068 'post_password' => '', 1069 ) 1070 ) 1071 ); 731 1072 $this->assertEquals( array( $one ), $result4 ); 732 $result5 = $this->q->query( array_merge( $args, array( 'has_password' => false, 'post_password' => '' ) ) ); 1073 $result5 = $this->q->query( 1074 array_merge( 1075 $args, array( 1076 'has_password' => false, 1077 'post_password' => '', 1078 ) 1079 ) 1080 ); 733 1081 $this->assertEquals( array( $one ), $result5 ); 734 $result6 = $this->q->query( array_merge( $args, array( 'has_password' => null, 'post_password' => '' ) ) ); 1082 $result6 = $this->q->query( 1083 array_merge( 1084 $args, array( 1085 'has_password' => null, 1086 'post_password' => '', 1087 ) 1088 ) 1089 ); 735 1090 $this->assertEquals( array( $one ), $result6 ); 736 1091 737 $result7 = $this->q->query( array_merge( $args, array( 'has_password' => true, 'post_password' => 'burrito' ) ) ); 1092 $result7 = $this->q->query( 1093 array_merge( 1094 $args, array( 1095 'has_password' => true, 1096 'post_password' => 'burrito', 1097 ) 1098 ) 1099 ); 738 1100 $this->assertEqualSets( array( $two, $three ), $result7 ); 739 $result8 = $this->q->query( array_merge( $args, array( 'has_password' => false, 'post_password' => 'burrito' ) ) ); 1101 $result8 = $this->q->query( 1102 array_merge( 1103 $args, array( 1104 'has_password' => false, 1105 'post_password' => 'burrito', 1106 ) 1107 ) 1108 ); 740 1109 $this->assertEqualSets( array( $two, $three ), $result8 ); 741 $result9 = $this->q->query( array_merge( $args, array( 'has_password' => null, 'post_password' => 'burrito' ) ) ); 1110 $result9 = $this->q->query( 1111 array_merge( 1112 $args, array( 1113 'has_password' => null, 1114 'post_password' => 'burrito', 1115 ) 1116 ) 1117 ); 742 1118 $this->assertEqualSets( array( $two, $three ), $result9 ); 743 1119 … … 754 1130 register_post_type( 'handbook', array( 'hierarchical' => true ) ); 755 1131 756 $post_1 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) ); 757 $post_2 = self::factory()->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); 758 $post_3 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) ); 759 760 $result = $this->q->query( array( 'handbook' => 'getting-started', 'post_type' => 'handbook' ) ); 1132 $post_1 = self::factory()->post->create( 1133 array( 1134 'post_title' => 'Getting Started', 1135 'post_type' => 'handbook', 1136 ) 1137 ); 1138 $post_2 = self::factory()->post->create( 1139 array( 1140 'post_title' => 'Contributing to the WordPress Codex', 1141 'post_type' => 'handbook', 1142 ) 1143 ); 1144 $post_3 = self::factory()->post->create( 1145 array( 1146 'post_title' => 'Getting Started', 1147 'post_parent' => $post_2, 1148 'post_type' => 'handbook', 1149 ) 1150 ); 1151 1152 $result = $this->q->query( 1153 array( 1154 'handbook' => 'getting-started', 1155 'post_type' => 'handbook', 1156 ) 1157 ); 761 1158 $this->assertCount( 1, $result ); 762 1159 } … … 768 1165 register_post_type( 'handbook', array( 'hierarchical' => true ) ); 769 1166 770 $post_1 = self::factory()->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); 771 $post_2 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) ); 1167 $post_1 = self::factory()->post->create( 1168 array( 1169 'post_title' => 'Contributing to the WordPress Codex', 1170 'post_type' => 'handbook', 1171 ) 1172 ); 1173 $post_2 = self::factory()->post->create( 1174 array( 1175 'post_title' => 'Getting Started', 1176 'post_parent' => $post_1, 1177 'post_type' => 'handbook', 1178 ) 1179 ); 772 1180 773 1181 $this->assertContains( 'contributing-to-the-wordpress-codex/getting-started', get_permalink( $post_2 ) ); 774 1182 775 $result = $this->q->query( array( 'handbook' => 'contributing-to-the-wordpress-codex/getting-started', 'post_type' => 'handbook' ) ); 1183 $result = $this->q->query( 1184 array( 1185 'handbook' => 'contributing-to-the-wordpress-codex/getting-started', 1186 'post_type' => 'handbook', 1187 ) 1188 ); 776 1189 $this->assertCount( 1, $result ); 777 1190 } 778 1191 779 1192 function test_title() { 780 $title = 'Tacos are Cool'; 781 $post_id = self::factory()->post->create( array( 782 'post_title' => $title, 783 'post_type' => 'post', 784 'post_status' => 'publish' 785 ) ); 786 787 $result1 = $this->q->query( array( 'title' => $title, 'fields' => 'ids' ) ); 1193 $title = 'Tacos are Cool'; 1194 $post_id = self::factory()->post->create( 1195 array( 1196 'post_title' => $title, 1197 'post_type' => 'post', 1198 'post_status' => 'publish', 1199 ) 1200 ); 1201 1202 $result1 = $this->q->query( 1203 array( 1204 'title' => $title, 1205 'fields' => 'ids', 1206 ) 1207 ); 788 1208 $this->assertCount( 1, $result1 ); 789 1209 $this->assertContains( $post_id, $result1 ); 790 1210 791 $result2 = $this->q->query( array( 'title' => 'Tacos', 'fields' => 'ids' ) ); 1211 $result2 = $this->q->query( 1212 array( 1213 'title' => 'Tacos', 1214 'fields' => 'ids', 1215 ) 1216 ); 792 1217 $this->assertCount( 0, $result2 ); 793 1218 } … … 798 1223 public function test_main_comments_feed_includes_attachment_comments() { 799 1224 $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); 800 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $attachment_id, 'comment_approved' => '1' ) ); 801 802 $this->q->query( array( 'withcomments' => 1, 'feed' => 'feed' ) ); 1225 $comment_id = self::factory()->comment->create( 1226 array( 1227 'comment_post_ID' => $attachment_id, 1228 'comment_approved' => '1', 1229 ) 1230 ); 1231 1232 $this->q->query( 1233 array( 1234 'withcomments' => 1, 1235 'feed' => 'feed', 1236 ) 1237 ); 803 1238 804 1239 $this->assertTrue( $this->q->have_comments() );
Note: See TracChangeset
for help on using the changeset viewer.