Changeset 42343 for trunk/tests/phpunit/tests/comment/query.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/query.php
r42056 r42343 19 19 20 20 public function test_query() { 21 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 22 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 23 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 24 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 25 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 26 27 $q = new WP_Comment_Query(); 28 $found = $q->query( array( 29 'fields' => 'ids', 30 ) ); 21 $c1 = self::factory()->comment->create( 22 array( 23 'comment_post_ID' => self::$post_id, 24 'comment_approved' => '1', 25 ) 26 ); 27 $c2 = self::factory()->comment->create( 28 array( 29 'comment_post_ID' => self::$post_id, 30 'comment_approved' => '1', 31 'comment_type' => 'pingback', 32 ) 33 ); 34 $c3 = self::factory()->comment->create( 35 array( 36 'comment_post_ID' => self::$post_id, 37 'comment_approved' => '1', 38 'comment_type' => 'trackback', 39 ) 40 ); 41 $c4 = self::factory()->comment->create( 42 array( 43 'comment_post_ID' => self::$post_id, 44 'comment_approved' => '1', 45 'comment_type' => 'mario', 46 ) 47 ); 48 $c5 = self::factory()->comment->create( 49 array( 50 'comment_post_ID' => self::$post_id, 51 'comment_approved' => '1', 52 'comment_type' => 'luigi', 53 ) 54 ); 55 56 $q = new WP_Comment_Query(); 57 $found = $q->query( 58 array( 59 'fields' => 'ids', 60 ) 61 ); 31 62 32 63 $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c5 ), $found ); … … 34 65 35 66 public function test_query_post_id_0() { 36 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 37 38 $q = new WP_Comment_Query(); 39 $found = $q->query( array( 40 'post_id' => 0, 41 'fields' => 'ids', 42 ) ); 67 $c1 = self::factory()->comment->create( 68 array( 69 'comment_post_ID' => self::$post_id, 70 'comment_approved' => '1', 71 ) 72 ); 73 74 $q = new WP_Comment_Query(); 75 $found = $q->query( 76 array( 77 'post_id' => 0, 78 'fields' => 'ids', 79 ) 80 ); 43 81 44 82 $this->assertEqualSets( array( $c1 ), $found ); … … 49 87 */ 50 88 public function test_query_type_empty_string() { 51 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 52 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 53 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 54 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 55 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 56 57 $q = new WP_Comment_Query(); 58 $found = $q->query( array( 59 'type' => '', 60 'fields' => 'ids', 61 ) ); 89 $c1 = self::factory()->comment->create( 90 array( 91 'comment_post_ID' => self::$post_id, 92 'comment_approved' => '1', 93 ) 94 ); 95 $c2 = self::factory()->comment->create( 96 array( 97 'comment_post_ID' => self::$post_id, 98 'comment_approved' => '1', 99 'comment_type' => 'pingback', 100 ) 101 ); 102 $c3 = self::factory()->comment->create( 103 array( 104 'comment_post_ID' => self::$post_id, 105 'comment_approved' => '1', 106 'comment_type' => 'trackback', 107 ) 108 ); 109 $c4 = self::factory()->comment->create( 110 array( 111 'comment_post_ID' => self::$post_id, 112 'comment_approved' => '1', 113 'comment_type' => 'mario', 114 ) 115 ); 116 $c5 = self::factory()->comment->create( 117 array( 118 'comment_post_ID' => self::$post_id, 119 'comment_approved' => '1', 120 'comment_type' => 'luigi', 121 ) 122 ); 123 124 $q = new WP_Comment_Query(); 125 $found = $q->query( 126 array( 127 'type' => '', 128 'fields' => 'ids', 129 ) 130 ); 62 131 63 132 $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c5 ), $found ); … … 68 137 */ 69 138 public function test_query_type_comment() { 70 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 71 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 72 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 73 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 74 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 75 76 $q = new WP_Comment_Query(); 77 $found = $q->query( array( 78 'type' => 'comment', 79 'fields' => 'ids', 80 ) ); 139 $c1 = self::factory()->comment->create( 140 array( 141 'comment_post_ID' => self::$post_id, 142 'comment_approved' => '1', 143 ) 144 ); 145 $c2 = self::factory()->comment->create( 146 array( 147 'comment_post_ID' => self::$post_id, 148 'comment_approved' => '1', 149 'comment_type' => 'pingback', 150 ) 151 ); 152 $c3 = self::factory()->comment->create( 153 array( 154 'comment_post_ID' => self::$post_id, 155 'comment_approved' => '1', 156 'comment_type' => 'trackback', 157 ) 158 ); 159 $c4 = self::factory()->comment->create( 160 array( 161 'comment_post_ID' => self::$post_id, 162 'comment_approved' => '1', 163 'comment_type' => 'mario', 164 ) 165 ); 166 $c5 = self::factory()->comment->create( 167 array( 168 'comment_post_ID' => self::$post_id, 169 'comment_approved' => '1', 170 'comment_type' => 'luigi', 171 ) 172 ); 173 174 $q = new WP_Comment_Query(); 175 $found = $q->query( 176 array( 177 'type' => 'comment', 178 'fields' => 'ids', 179 ) 180 ); 81 181 82 182 $this->assertEqualSets( array( $c1 ), $found ); … … 84 184 85 185 public function test_query_type_pingback() { 86 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 87 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 88 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 89 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 90 91 $q = new WP_Comment_Query(); 92 $found = $q->query( array( 93 'type' => 'pingback', 94 'fields' => 'ids', 95 ) ); 186 $c1 = self::factory()->comment->create( 187 array( 188 'comment_post_ID' => self::$post_id, 189 'comment_approved' => '1', 190 ) 191 ); 192 $c2 = self::factory()->comment->create( 193 array( 194 'comment_post_ID' => self::$post_id, 195 'comment_approved' => '1', 196 'comment_type' => 'pingback', 197 ) 198 ); 199 $c3 = self::factory()->comment->create( 200 array( 201 'comment_post_ID' => self::$post_id, 202 'comment_approved' => '1', 203 'comment_type' => 'pingback', 204 ) 205 ); 206 $c4 = self::factory()->comment->create( 207 array( 208 'comment_post_ID' => self::$post_id, 209 'comment_approved' => '1', 210 'comment_type' => 'trackback', 211 ) 212 ); 213 214 $q = new WP_Comment_Query(); 215 $found = $q->query( 216 array( 217 'type' => 'pingback', 218 'fields' => 'ids', 219 ) 220 ); 96 221 97 222 $this->assertEqualSets( array( $c2, $c3 ), $found ); … … 100 225 101 226 public function test_query_type_trackback() { 102 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 103 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 104 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 105 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 106 107 $q = new WP_Comment_Query(); 108 $found = $q->query( array( 109 'type' => 'trackback', 110 'fields' => 'ids', 111 ) ); 227 $c1 = self::factory()->comment->create( 228 array( 229 'comment_post_ID' => self::$post_id, 230 'comment_approved' => '1', 231 ) 232 ); 233 $c2 = self::factory()->comment->create( 234 array( 235 'comment_post_ID' => self::$post_id, 236 'comment_approved' => '1', 237 'comment_type' => 'trackback', 238 ) 239 ); 240 $c3 = self::factory()->comment->create( 241 array( 242 'comment_post_ID' => self::$post_id, 243 'comment_approved' => '1', 244 'comment_type' => 'trackback', 245 ) 246 ); 247 $c4 = self::factory()->comment->create( 248 array( 249 'comment_post_ID' => self::$post_id, 250 'comment_approved' => '1', 251 'comment_type' => 'pingback', 252 ) 253 ); 254 255 $q = new WP_Comment_Query(); 256 $found = $q->query( 257 array( 258 'type' => 'trackback', 259 'fields' => 'ids', 260 ) 261 ); 112 262 113 263 $this->assertEqualSets( array( $c2, $c3 ), $found ); … … 119 269 */ 120 270 public function test_query_type_pings() { 121 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 122 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 123 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 124 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 125 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 126 127 $q = new WP_Comment_Query(); 128 $found = $q->query( array( 129 'type' => 'pings', 130 'fields' => 'ids', 131 ) ); 271 $c1 = self::factory()->comment->create( 272 array( 273 'comment_post_ID' => self::$post_id, 274 'comment_approved' => '1', 275 ) 276 ); 277 $c2 = self::factory()->comment->create( 278 array( 279 'comment_post_ID' => self::$post_id, 280 'comment_approved' => '1', 281 'comment_type' => 'pingback', 282 ) 283 ); 284 $c3 = self::factory()->comment->create( 285 array( 286 'comment_post_ID' => self::$post_id, 287 'comment_approved' => '1', 288 'comment_type' => 'trackback', 289 ) 290 ); 291 $c4 = self::factory()->comment->create( 292 array( 293 'comment_post_ID' => self::$post_id, 294 'comment_approved' => '1', 295 'comment_type' => 'mario', 296 ) 297 ); 298 $c5 = self::factory()->comment->create( 299 array( 300 'comment_post_ID' => self::$post_id, 301 'comment_approved' => '1', 302 'comment_type' => 'luigi', 303 ) 304 ); 305 306 $q = new WP_Comment_Query(); 307 $found = $q->query( 308 array( 309 'type' => 'pings', 310 'fields' => 'ids', 311 ) 312 ); 132 313 133 314 $this->assertEqualSets( array( $c2, $c3 ), $found ); … … 136 317 /** 137 318 * Comments and custom 319 * 138 320 * @ticket 12668 139 321 */ 140 322 public function test_type_array_comments_and_custom() { 141 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 142 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 143 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 144 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 145 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 146 $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 147 148 $q = new WP_Comment_Query(); 149 $found = $q->query( array( 150 'type' => array( 'comments', 'mario' ), 151 'fields' => 'ids', 152 ) ); 323 $c1 = self::factory()->comment->create( 324 array( 325 'comment_post_ID' => self::$post_id, 326 'comment_approved' => '1', 327 ) 328 ); 329 $c2 = self::factory()->comment->create( 330 array( 331 'comment_post_ID' => self::$post_id, 332 'comment_approved' => '1', 333 'comment_type' => 'pingback', 334 ) 335 ); 336 $c3 = self::factory()->comment->create( 337 array( 338 'comment_post_ID' => self::$post_id, 339 'comment_approved' => '1', 340 'comment_type' => 'trackback', 341 ) 342 ); 343 $c4 = self::factory()->comment->create( 344 array( 345 'comment_post_ID' => self::$post_id, 346 'comment_approved' => '1', 347 'comment_type' => 'mario', 348 ) 349 ); 350 $c5 = self::factory()->comment->create( 351 array( 352 'comment_post_ID' => self::$post_id, 353 'comment_approved' => '1', 354 'comment_type' => 'luigi', 355 ) 356 ); 357 $c6 = self::factory()->comment->create( 358 array( 359 'comment_post_ID' => self::$post_id, 360 'comment_approved' => '1', 361 'comment_type' => 'mario', 362 ) 363 ); 364 365 $q = new WP_Comment_Query(); 366 $found = $q->query( 367 array( 368 'type' => array( 'comments', 'mario' ), 369 'fields' => 'ids', 370 ) 371 ); 153 372 154 373 $this->assertEqualSets( array( $c1, $c4, $c6 ), $found ); … … 159 378 */ 160 379 public function test_type_not__in_array_custom() { 161 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 162 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 163 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 164 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 165 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 166 $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 167 168 $q = new WP_Comment_Query(); 169 $found = $q->query( array( 170 'type__not_in' => array( 'luigi' ), 171 'fields' => 'ids', 172 ) ); 380 $c1 = self::factory()->comment->create( 381 array( 382 'comment_post_ID' => self::$post_id, 383 'comment_approved' => '1', 384 ) 385 ); 386 $c2 = self::factory()->comment->create( 387 array( 388 'comment_post_ID' => self::$post_id, 389 'comment_approved' => '1', 390 'comment_type' => 'pingback', 391 ) 392 ); 393 $c3 = self::factory()->comment->create( 394 array( 395 'comment_post_ID' => self::$post_id, 396 'comment_approved' => '1', 397 'comment_type' => 'trackback', 398 ) 399 ); 400 $c4 = self::factory()->comment->create( 401 array( 402 'comment_post_ID' => self::$post_id, 403 'comment_approved' => '1', 404 'comment_type' => 'mario', 405 ) 406 ); 407 $c5 = self::factory()->comment->create( 408 array( 409 'comment_post_ID' => self::$post_id, 410 'comment_approved' => '1', 411 'comment_type' => 'luigi', 412 ) 413 ); 414 $c6 = self::factory()->comment->create( 415 array( 416 'comment_post_ID' => self::$post_id, 417 'comment_approved' => '1', 418 'comment_type' => 'mario', 419 ) 420 ); 421 422 $q = new WP_Comment_Query(); 423 $found = $q->query( 424 array( 425 'type__not_in' => array( 'luigi' ), 426 'fields' => 'ids', 427 ) 428 ); 173 429 174 430 $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c6 ), $found ); … … 179 435 */ 180 436 public function test_type__in_array_and_not_type_array_custom() { 181 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 182 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 183 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 184 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 185 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 186 $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 187 188 $q = new WP_Comment_Query(); 189 $found = $q->query( array( 190 'type__in' => array( 'comments' ), 191 'type__not_in' => array( 'luigi' ), 192 'fields' => 'ids', 193 ) ); 437 $c1 = self::factory()->comment->create( 438 array( 439 'comment_post_ID' => self::$post_id, 440 'comment_approved' => '1', 441 ) 442 ); 443 $c2 = self::factory()->comment->create( 444 array( 445 'comment_post_ID' => self::$post_id, 446 'comment_approved' => '1', 447 'comment_type' => 'pingback', 448 ) 449 ); 450 $c3 = self::factory()->comment->create( 451 array( 452 'comment_post_ID' => self::$post_id, 453 'comment_approved' => '1', 454 'comment_type' => 'trackback', 455 ) 456 ); 457 $c4 = self::factory()->comment->create( 458 array( 459 'comment_post_ID' => self::$post_id, 460 'comment_approved' => '1', 461 'comment_type' => 'mario', 462 ) 463 ); 464 $c5 = self::factory()->comment->create( 465 array( 466 'comment_post_ID' => self::$post_id, 467 'comment_approved' => '1', 468 'comment_type' => 'luigi', 469 ) 470 ); 471 $c6 = self::factory()->comment->create( 472 array( 473 'comment_post_ID' => self::$post_id, 474 'comment_approved' => '1', 475 'comment_type' => 'mario', 476 ) 477 ); 478 479 $q = new WP_Comment_Query(); 480 $found = $q->query( 481 array( 482 'type__in' => array( 'comments' ), 483 'type__not_in' => array( 'luigi' ), 484 'fields' => 'ids', 485 ) 486 ); 194 487 195 488 $this->assertEqualSets( array( $c1 ), $found ); … … 200 493 */ 201 494 public function test_type_array_and_type__not_in_array_custom() { 202 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 203 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 204 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 205 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 206 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 207 $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 208 209 $q = new WP_Comment_Query(); 210 $found = $q->query( array( 211 'type' => array( 'pings' ), 212 'type__not_in' => array( 'mario' ), 213 'fields' => 'ids', 214 ) ); 495 $c1 = self::factory()->comment->create( 496 array( 497 'comment_post_ID' => self::$post_id, 498 'comment_approved' => '1', 499 ) 500 ); 501 $c2 = self::factory()->comment->create( 502 array( 503 'comment_post_ID' => self::$post_id, 504 'comment_approved' => '1', 505 'comment_type' => 'pingback', 506 ) 507 ); 508 $c3 = self::factory()->comment->create( 509 array( 510 'comment_post_ID' => self::$post_id, 511 'comment_approved' => '1', 512 'comment_type' => 'trackback', 513 ) 514 ); 515 $c4 = self::factory()->comment->create( 516 array( 517 'comment_post_ID' => self::$post_id, 518 'comment_approved' => '1', 519 'comment_type' => 'mario', 520 ) 521 ); 522 $c5 = self::factory()->comment->create( 523 array( 524 'comment_post_ID' => self::$post_id, 525 'comment_approved' => '1', 526 'comment_type' => 'luigi', 527 ) 528 ); 529 $c6 = self::factory()->comment->create( 530 array( 531 'comment_post_ID' => self::$post_id, 532 'comment_approved' => '1', 533 'comment_type' => 'mario', 534 ) 535 ); 536 537 $q = new WP_Comment_Query(); 538 $found = $q->query( 539 array( 540 'type' => array( 'pings' ), 541 'type__not_in' => array( 'mario' ), 542 'fields' => 'ids', 543 ) 544 ); 215 545 216 546 $this->assertEqualSets( array( $c2, $c3 ), $found ); … … 221 551 */ 222 552 public function test_type__not_in_custom() { 223 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 224 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 225 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 226 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 227 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 228 $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 229 230 $q = new WP_Comment_Query(); 231 $found = $q->query( array( 232 'type__not_in' => 'luigi', 233 'fields' => 'ids', 234 ) ); 553 $c1 = self::factory()->comment->create( 554 array( 555 'comment_post_ID' => self::$post_id, 556 'comment_approved' => '1', 557 ) 558 ); 559 $c2 = self::factory()->comment->create( 560 array( 561 'comment_post_ID' => self::$post_id, 562 'comment_approved' => '1', 563 'comment_type' => 'pingback', 564 ) 565 ); 566 $c3 = self::factory()->comment->create( 567 array( 568 'comment_post_ID' => self::$post_id, 569 'comment_approved' => '1', 570 'comment_type' => 'trackback', 571 ) 572 ); 573 $c4 = self::factory()->comment->create( 574 array( 575 'comment_post_ID' => self::$post_id, 576 'comment_approved' => '1', 577 'comment_type' => 'mario', 578 ) 579 ); 580 $c5 = self::factory()->comment->create( 581 array( 582 'comment_post_ID' => self::$post_id, 583 'comment_approved' => '1', 584 'comment_type' => 'luigi', 585 ) 586 ); 587 $c6 = self::factory()->comment->create( 588 array( 589 'comment_post_ID' => self::$post_id, 590 'comment_approved' => '1', 591 'comment_type' => 'mario', 592 ) 593 ); 594 595 $q = new WP_Comment_Query(); 596 $found = $q->query( 597 array( 598 'type__not_in' => 'luigi', 599 'fields' => 'ids', 600 ) 601 ); 235 602 236 603 $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c6 ), $found ); … … 241 608 */ 242 609 public function test_type_array_comments_and_pings() { 243 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 244 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 245 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 246 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); 247 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); 248 249 $q = new WP_Comment_Query(); 250 $found = $q->query( array( 251 'type' => array( 'comments', 'pings' ), 252 'fields' => 'ids', 253 ) ); 610 $c1 = self::factory()->comment->create( 611 array( 612 'comment_post_ID' => self::$post_id, 613 'comment_approved' => '1', 614 ) 615 ); 616 $c2 = self::factory()->comment->create( 617 array( 618 'comment_post_ID' => self::$post_id, 619 'comment_approved' => '1', 620 'comment_type' => 'pingback', 621 ) 622 ); 623 $c3 = self::factory()->comment->create( 624 array( 625 'comment_post_ID' => self::$post_id, 626 'comment_approved' => '1', 627 'comment_type' => 'trackback', 628 ) 629 ); 630 $c4 = self::factory()->comment->create( 631 array( 632 'comment_post_ID' => self::$post_id, 633 'comment_approved' => '1', 634 'comment_type' => 'mario', 635 ) 636 ); 637 $c5 = self::factory()->comment->create( 638 array( 639 'comment_post_ID' => self::$post_id, 640 'comment_approved' => '1', 641 'comment_type' => 'luigi', 642 ) 643 ); 644 645 $q = new WP_Comment_Query(); 646 $found = $q->query( 647 array( 648 'type' => array( 'comments', 'pings' ), 649 'fields' => 'ids', 650 ) 651 ); 254 652 255 653 $this->assertEqualSets( array( $c1, $c2, $c3 ), $found ); … … 260 658 */ 261 659 public function test_type_array_comment_pings() { 262 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 263 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 264 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 265 266 $q = new WP_Comment_Query(); 267 $found = $q->query( array( 268 'type' => array( 'comment', 'pings' ), 269 'fields' => 'ids', 270 ) ); 660 $c1 = self::factory()->comment->create( 661 array( 662 'comment_post_ID' => self::$post_id, 663 'comment_approved' => '1', 664 ) 665 ); 666 $c2 = self::factory()->comment->create( 667 array( 668 'comment_post_ID' => self::$post_id, 669 'comment_approved' => '1', 670 'comment_type' => 'pingback', 671 ) 672 ); 673 $c3 = self::factory()->comment->create( 674 array( 675 'comment_post_ID' => self::$post_id, 676 'comment_approved' => '1', 677 'comment_type' => 'trackback', 678 ) 679 ); 680 681 $q = new WP_Comment_Query(); 682 $found = $q->query( 683 array( 684 'type' => array( 'comment', 'pings' ), 685 'fields' => 'ids', 686 ) 687 ); 271 688 272 689 $this->assertEqualSets( array( $c1, $c2, $c3 ), $found ); … … 277 694 */ 278 695 public function test_type_array_pingback() { 279 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 280 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 281 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 282 283 $q = new WP_Comment_Query(); 284 $found = $q->query( array( 285 'type' => array( 'pingback' ), 286 'fields' => 'ids', 287 ) ); 696 $c1 = self::factory()->comment->create( 697 array( 698 'comment_post_ID' => self::$post_id, 699 'comment_approved' => '1', 700 ) 701 ); 702 $c2 = self::factory()->comment->create( 703 array( 704 'comment_post_ID' => self::$post_id, 705 'comment_approved' => '1', 706 'comment_type' => 'pingback', 707 ) 708 ); 709 $c3 = self::factory()->comment->create( 710 array( 711 'comment_post_ID' => self::$post_id, 712 'comment_approved' => '1', 713 'comment_type' => 'trackback', 714 ) 715 ); 716 717 $q = new WP_Comment_Query(); 718 $found = $q->query( 719 array( 720 'type' => array( 'pingback' ), 721 'fields' => 'ids', 722 ) 723 ); 288 724 289 725 $this->assertEquals( array( $c2 ), $found ); … … 294 730 */ 295 731 public function test_type_array_custom_pingpack() { 296 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 297 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 298 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 299 300 $q = new WP_Comment_Query(); 301 $found = $q->query( array( 302 'type' => array( 'peach', 'pingback' ), 303 'fields' => 'ids', 304 ) ); 732 $c1 = self::factory()->comment->create( 733 array( 734 'comment_post_ID' => self::$post_id, 735 'comment_approved' => '1', 736 ) 737 ); 738 $c2 = self::factory()->comment->create( 739 array( 740 'comment_post_ID' => self::$post_id, 741 'comment_approved' => '1', 742 'comment_type' => 'pingback', 743 ) 744 ); 745 $c3 = self::factory()->comment->create( 746 array( 747 'comment_post_ID' => self::$post_id, 748 'comment_approved' => '1', 749 'comment_type' => 'trackback', 750 ) 751 ); 752 753 $q = new WP_Comment_Query(); 754 $found = $q->query( 755 array( 756 'type' => array( 'peach', 'pingback' ), 757 'fields' => 'ids', 758 ) 759 ); 305 760 306 761 $this->assertEquals( array( $c2 ), $found ); … … 311 766 */ 312 767 public function test_type_array_pings() { 313 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 314 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 315 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 316 317 $q = new WP_Comment_Query(); 318 $found = $q->query( array( 319 'type' => array( 'pings' ), 320 'fields' => 'ids', 321 ) ); 768 $c1 = self::factory()->comment->create( 769 array( 770 'comment_post_ID' => self::$post_id, 771 'comment_approved' => '1', 772 ) 773 ); 774 $c2 = self::factory()->comment->create( 775 array( 776 'comment_post_ID' => self::$post_id, 777 'comment_approved' => '1', 778 'comment_type' => 'pingback', 779 ) 780 ); 781 $c3 = self::factory()->comment->create( 782 array( 783 'comment_post_ID' => self::$post_id, 784 'comment_approved' => '1', 785 'comment_type' => 'pingback', 786 ) 787 ); 788 789 $q = new WP_Comment_Query(); 790 $found = $q->query( 791 array( 792 'type' => array( 'pings' ), 793 'fields' => 'ids', 794 ) 795 ); 322 796 323 797 $this->assertEqualSets( array( $c2, $c3 ), $found ); … … 328 802 */ 329 803 public function test_type_status_approved_array_comment_pings() { 330 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 331 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 332 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 333 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); 334 335 $q = new WP_Comment_Query(); 336 $found = $q->query( array( 337 'status' => 'approve', 338 'type' => array( 'pings' ), 339 'fields' => 'ids', 340 ) ); 804 $c1 = self::factory()->comment->create( 805 array( 806 'comment_post_ID' => self::$post_id, 807 'comment_approved' => '1', 808 ) 809 ); 810 $c2 = self::factory()->comment->create( 811 array( 812 'comment_post_ID' => self::$post_id, 813 'comment_approved' => '1', 814 'comment_type' => 'pingback', 815 ) 816 ); 817 $c3 = self::factory()->comment->create( 818 array( 819 'comment_post_ID' => self::$post_id, 820 'comment_approved' => '1', 821 'comment_type' => 'pingback', 822 ) 823 ); 824 $c4 = self::factory()->comment->create( 825 array( 826 'comment_post_ID' => self::$post_id, 827 'comment_approved' => '0', 828 'comment_type' => 'pingback', 829 ) 830 ); 831 832 $q = new WP_Comment_Query(); 833 $found = $q->query( 834 array( 835 'status' => 'approve', 836 'type' => array( 'pings' ), 837 'fields' => 'ids', 838 ) 839 ); 341 840 342 841 $this->assertEqualSets( array( $c3, $c2 ), $found ); … … 347 846 */ 348 847 public function test_type_array_trackback() { 349 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 350 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 351 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 352 353 $q = new WP_Comment_Query(); 354 $found = $q->query( array( 355 'type' => array( 'trackback' ), 356 'fields' => 'ids', 357 ) ); 848 $c1 = self::factory()->comment->create( 849 array( 850 'comment_post_ID' => self::$post_id, 851 'comment_approved' => '1', 852 ) 853 ); 854 $c2 = self::factory()->comment->create( 855 array( 856 'comment_post_ID' => self::$post_id, 857 'comment_approved' => '1', 858 'comment_type' => 'trackback', 859 ) 860 ); 861 $c3 = self::factory()->comment->create( 862 array( 863 'comment_post_ID' => self::$post_id, 864 'comment_approved' => '1', 865 'comment_type' => 'pingback', 866 ) 867 ); 868 869 $q = new WP_Comment_Query(); 870 $found = $q->query( 871 array( 872 'type' => array( 'trackback' ), 873 'fields' => 'ids', 874 ) 875 ); 358 876 359 877 $this->assertEquals( array( $c2 ), $found ); … … 364 882 */ 365 883 public function test_type_array_custom_trackback() { 366 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 367 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 368 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); 369 370 $q = new WP_Comment_Query(); 371 $found = $q->query( array( 372 'type' => array( 'toad', 'trackback' ), 373 'fields' => 'ids', 374 ) ); 884 $c1 = self::factory()->comment->create( 885 array( 886 'comment_post_ID' => self::$post_id, 887 'comment_approved' => '1', 888 ) 889 ); 890 $c2 = self::factory()->comment->create( 891 array( 892 'comment_post_ID' => self::$post_id, 893 'comment_approved' => '1', 894 'comment_type' => 'trackback', 895 ) 896 ); 897 $c3 = self::factory()->comment->create( 898 array( 899 'comment_post_ID' => self::$post_id, 900 'comment_approved' => '1', 901 'comment_type' => 'pingback', 902 ) 903 ); 904 905 $q = new WP_Comment_Query(); 906 $found = $q->query( 907 array( 908 'type' => array( 'toad', 'trackback' ), 909 'fields' => 'ids', 910 ) 911 ); 375 912 376 913 $this->assertEquals( array( $c2 ), $found ); … … 381 918 */ 382 919 public function test_type_array_pings_approved() { 383 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 384 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 385 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); 386 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); 387 388 $q = new WP_Comment_Query(); 389 $found = $q->query( array( 390 'status' => 'approve', 391 'type' => array( 'pings' ), 392 'fields' => 'ids', 393 ) ); 920 $c1 = self::factory()->comment->create( 921 array( 922 'comment_post_ID' => self::$post_id, 923 'comment_approved' => '1', 924 ) 925 ); 926 $c2 = self::factory()->comment->create( 927 array( 928 'comment_post_ID' => self::$post_id, 929 'comment_approved' => '1', 930 'comment_type' => 'trackback', 931 ) 932 ); 933 $c3 = self::factory()->comment->create( 934 array( 935 'comment_post_ID' => self::$post_id, 936 'comment_approved' => '1', 937 'comment_type' => 'trackback', 938 ) 939 ); 940 $c4 = self::factory()->comment->create( 941 array( 942 'comment_post_ID' => self::$post_id, 943 'comment_approved' => '0', 944 'comment_type' => 'trackback', 945 ) 946 ); 947 948 $q = new WP_Comment_Query(); 949 $found = $q->query( 950 array( 951 'status' => 'approve', 952 'type' => array( 'pings' ), 953 'fields' => 'ids', 954 ) 955 ); 394 956 395 957 $this->assertEqualSets( array( $c3, $c2 ), $found ); … … 400 962 */ 401 963 public function test_status_empty_string() { 402 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 403 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 404 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'spam' ) ); 405 406 $q = new WP_Comment_Query(); 407 $found = $q->query( array( 408 'status' => '', 409 'fields' => 'ids', 410 ) ); 964 $c1 = self::factory()->comment->create( 965 array( 966 'comment_post_ID' => self::$post_id, 967 'comment_approved' => '1', 968 ) 969 ); 970 $c2 = self::factory()->comment->create( 971 array( 972 'comment_post_ID' => self::$post_id, 973 'comment_approved' => '0', 974 ) 975 ); 976 $c3 = self::factory()->comment->create( 977 array( 978 'comment_post_ID' => self::$post_id, 979 'comment_approved' => 'spam', 980 ) 981 ); 982 983 $q = new WP_Comment_Query(); 984 $found = $q->query( 985 array( 986 'status' => '', 987 'fields' => 'ids', 988 ) 989 ); 411 990 412 991 $this->assertEqualSets( array( $c1, $c2 ), $found ); … … 417 996 */ 418 997 public function test_status_hold() { 419 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 420 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 421 422 $q = new WP_Comment_Query(); 423 $found = $q->query( array( 424 'status' => 'hold', 425 'fields' => 'ids', 426 ) ); 998 $c1 = self::factory()->comment->create( 999 array( 1000 'comment_post_ID' => self::$post_id, 1001 'comment_approved' => '1', 1002 ) 1003 ); 1004 $c2 = self::factory()->comment->create( 1005 array( 1006 'comment_post_ID' => self::$post_id, 1007 'comment_approved' => '0', 1008 ) 1009 ); 1010 1011 $q = new WP_Comment_Query(); 1012 $found = $q->query( 1013 array( 1014 'status' => 'hold', 1015 'fields' => 'ids', 1016 ) 1017 ); 427 1018 428 1019 $this->assertEquals( array( $c2 ), $found ); … … 433 1024 */ 434 1025 public function test_status_approve() { 435 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 436 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 437 438 $q = new WP_Comment_Query(); 439 $found = $q->query( array( 440 'status' => 'approve', 441 'fields' => 'ids', 442 ) ); 1026 $c1 = self::factory()->comment->create( 1027 array( 1028 'comment_post_ID' => self::$post_id, 1029 'comment_approved' => '1', 1030 ) 1031 ); 1032 $c2 = self::factory()->comment->create( 1033 array( 1034 'comment_post_ID' => self::$post_id, 1035 'comment_approved' => '0', 1036 ) 1037 ); 1038 1039 $q = new WP_Comment_Query(); 1040 $found = $q->query( 1041 array( 1042 'status' => 'approve', 1043 'fields' => 'ids', 1044 ) 1045 ); 443 1046 444 1047 $this->assertEquals( array( $c1 ), $found ); … … 446 1049 447 1050 public function test_status_custom() { 448 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 449 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); 450 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo1' ) ); 451 452 $q = new WP_Comment_Query(); 453 $found = $q->query( array( 454 'status' => 'foo', 455 'fields' => 'ids', 456 ) ); 1051 $c1 = self::factory()->comment->create( 1052 array( 1053 'comment_post_ID' => self::$post_id, 1054 'comment_approved' => '1', 1055 ) 1056 ); 1057 $c2 = self::factory()->comment->create( 1058 array( 1059 'comment_post_ID' => self::$post_id, 1060 'comment_approved' => 'foo', 1061 ) 1062 ); 1063 $c3 = self::factory()->comment->create( 1064 array( 1065 'comment_post_ID' => self::$post_id, 1066 'comment_approved' => 'foo1', 1067 ) 1068 ); 1069 1070 $q = new WP_Comment_Query(); 1071 $found = $q->query( 1072 array( 1073 'status' => 'foo', 1074 'fields' => 'ids', 1075 ) 1076 ); 457 1077 458 1078 $this->assertEquals( array( $c2 ), $found ); … … 460 1080 461 1081 public function test_status_all() { 462 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 463 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); 464 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 465 466 $q = new WP_Comment_Query(); 467 $found = $q->query( array( 468 'status' => 'all', 469 'fields' => 'ids', 470 ) ); 1082 $c1 = self::factory()->comment->create( 1083 array( 1084 'comment_post_ID' => self::$post_id, 1085 'comment_approved' => '1', 1086 ) 1087 ); 1088 $c2 = self::factory()->comment->create( 1089 array( 1090 'comment_post_ID' => self::$post_id, 1091 'comment_approved' => 'foo', 1092 ) 1093 ); 1094 $c3 = self::factory()->comment->create( 1095 array( 1096 'comment_post_ID' => self::$post_id, 1097 'comment_approved' => '0', 1098 ) 1099 ); 1100 1101 $q = new WP_Comment_Query(); 1102 $found = $q->query( 1103 array( 1104 'status' => 'all', 1105 'fields' => 'ids', 1106 ) 1107 ); 471 1108 472 1109 $this->assertEqualSets( array( $c1, $c3 ), $found ); … … 474 1111 475 1112 public function test_status_default_to_all() { 476 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 477 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); 478 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 479 480 $q = new WP_Comment_Query(); 481 $found = $q->query( array( 482 'fields' => 'ids', 483 ) ); 1113 $c1 = self::factory()->comment->create( 1114 array( 1115 'comment_post_ID' => self::$post_id, 1116 'comment_approved' => '1', 1117 ) 1118 ); 1119 $c2 = self::factory()->comment->create( 1120 array( 1121 'comment_post_ID' => self::$post_id, 1122 'comment_approved' => 'foo', 1123 ) 1124 ); 1125 $c3 = self::factory()->comment->create( 1126 array( 1127 'comment_post_ID' => self::$post_id, 1128 'comment_approved' => '0', 1129 ) 1130 ); 1131 1132 $q = new WP_Comment_Query(); 1133 $found = $q->query( 1134 array( 1135 'fields' => 'ids', 1136 ) 1137 ); 484 1138 485 1139 $this->assertEqualSets( array( $c1, $c3 ), $found ); … … 490 1144 */ 491 1145 public function test_status_comma_any() { 492 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 493 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); 494 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 495 496 $q = new WP_Comment_Query(); 497 $found = $q->query( array( 498 'status' => 'any', 499 'fields' => 'ids', 500 ) ); 1146 $c1 = self::factory()->comment->create( 1147 array( 1148 'comment_post_ID' => self::$post_id, 1149 'comment_approved' => '1', 1150 ) 1151 ); 1152 $c2 = self::factory()->comment->create( 1153 array( 1154 'comment_post_ID' => self::$post_id, 1155 'comment_approved' => 'foo', 1156 ) 1157 ); 1158 $c3 = self::factory()->comment->create( 1159 array( 1160 'comment_post_ID' => self::$post_id, 1161 'comment_approved' => '0', 1162 ) 1163 ); 1164 1165 $q = new WP_Comment_Query(); 1166 $found = $q->query( 1167 array( 1168 'status' => 'any', 1169 'fields' => 'ids', 1170 ) 1171 ); 501 1172 502 1173 $this->assertEqualSets( array( $c1, $c2, $c3 ), $found ); … … 507 1178 */ 508 1179 public function test_status_comma_separated() { 509 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 510 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); 511 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 512 513 $q = new WP_Comment_Query(); 514 $found = $q->query( array( 515 'status' => 'approve,foo,bar', 516 'fields' => 'ids', 517 ) ); 1180 $c1 = self::factory()->comment->create( 1181 array( 1182 'comment_post_ID' => self::$post_id, 1183 'comment_approved' => '1', 1184 ) 1185 ); 1186 $c2 = self::factory()->comment->create( 1187 array( 1188 'comment_post_ID' => self::$post_id, 1189 'comment_approved' => 'foo', 1190 ) 1191 ); 1192 $c3 = self::factory()->comment->create( 1193 array( 1194 'comment_post_ID' => self::$post_id, 1195 'comment_approved' => '0', 1196 ) 1197 ); 1198 1199 $q = new WP_Comment_Query(); 1200 $found = $q->query( 1201 array( 1202 'status' => 'approve,foo,bar', 1203 'fields' => 'ids', 1204 ) 1205 ); 518 1206 519 1207 $this->assertEqualSets( array( $c1, $c2 ), $found ); … … 524 1212 */ 525 1213 public function test_status_array() { 526 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 527 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); 528 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); 529 530 $q = new WP_Comment_Query(); 531 $found = $q->query( array( 532 'status' => array( 'approve', 'foo', 'bar', ), 533 'fields' => 'ids', 534 ) ); 1214 $c1 = self::factory()->comment->create( 1215 array( 1216 'comment_post_ID' => self::$post_id, 1217 'comment_approved' => '1', 1218 ) 1219 ); 1220 $c2 = self::factory()->comment->create( 1221 array( 1222 'comment_post_ID' => self::$post_id, 1223 'comment_approved' => 'foo', 1224 ) 1225 ); 1226 $c3 = self::factory()->comment->create( 1227 array( 1228 'comment_post_ID' => self::$post_id, 1229 'comment_approved' => '0', 1230 ) 1231 ); 1232 1233 $q = new WP_Comment_Query(); 1234 $found = $q->query( 1235 array( 1236 'status' => array( 'approve', 'foo', 'bar' ), 1237 'fields' => 'ids', 1238 ) 1239 ); 535 1240 536 1241 $this->assertEqualSets( array( $c1, $c2 ), $found ); … … 543 1248 $posts = array(); 544 1249 545 $posts[] = self::factory()->post->create( array( 546 'post_status' => 'publish', 547 'post_author' => 3, 548 ) ); 549 550 $posts[] = self::factory()->post->create( array( 551 'post_status' => 'draft', 552 'post_author' => 4, 553 ) ); 554 555 $posts[] = self::factory()->post->create( array( 556 'post_status' => 'draft', 557 'post_author' => 3, 558 ) ); 1250 $posts[] = self::factory()->post->create( 1251 array( 1252 'post_status' => 'publish', 1253 'post_author' => 3, 1254 ) 1255 ); 1256 1257 $posts[] = self::factory()->post->create( 1258 array( 1259 'post_status' => 'draft', 1260 'post_author' => 4, 1261 ) 1262 ); 1263 1264 $posts[] = self::factory()->post->create( 1265 array( 1266 'post_status' => 'draft', 1267 'post_author' => 3, 1268 ) 1269 ); 559 1270 560 1271 $comments = array(); 561 1272 foreach ( $posts as $post ) { 562 $comments[] = self::factory()->comment->create( array( 563 'comment_post_ID' => $post, 564 ) ); 1273 $comments[] = self::factory()->comment->create( 1274 array( 1275 'comment_post_ID' => $post, 1276 ) 1277 ); 565 1278 } 566 1279 567 $q = new WP_Comment_Query( array( 568 'post_status' => 'draft', 569 'post_author' => 3, 570 'fields' => 'ids', 571 ) ); 1280 $q = new WP_Comment_Query( 1281 array( 1282 'post_status' => 'draft', 1283 'post_author' => 3, 1284 'fields' => 'ids', 1285 ) 1286 ); 572 1287 573 1288 $this->assertSame( array( $comments[2] ), $q->comments ); … … 601 1316 } 602 1317 603 $comments = get_comments( array( 'post_id' => $post_id3, 'status' => 'hold' ) ); 1318 $comments = get_comments( 1319 array( 1320 'post_id' => $post_id3, 1321 'status' => 'hold', 1322 ) 1323 ); 604 1324 $this->assertEquals( $limit, count( $comments ) ); 605 1325 foreach ( $comments as $comment ) { … … 607 1327 } 608 1328 609 $comments = get_comments( array( 'post_id' => $post_id3, 'status' => 'approve' ) ); 1329 $comments = get_comments( 1330 array( 1331 'post_id' => $post_id3, 1332 'status' => 'approve', 1333 ) 1334 ); 610 1335 $this->assertEquals( 0, count( $comments ) ); 611 1336 … … 622 1347 */ 623 1348 function test_orderby_meta() { 624 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );1349 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); 625 1350 $comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); 626 1351 $comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 633 1358 add_comment_meta( $comment_id3, 'key3', 'value3', true ); 634 1359 635 $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'key' ) ) ); 1360 $comments = get_comments( 1361 array( 1362 'meta_key' => 'key', 1363 'orderby' => array( 'key' ), 1364 ) 1365 ); 636 1366 $this->assertEquals( 2, count( $comments ) ); 637 1367 $this->assertEquals( $comment_id2, $comments[0]->comment_ID ); 638 1368 $this->assertEquals( $comment_id, $comments[1]->comment_ID ); 639 1369 640 $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'meta_value' ) ) ); 1370 $comments = get_comments( 1371 array( 1372 'meta_key' => 'key', 1373 'orderby' => array( 'meta_value' ), 1374 ) 1375 ); 641 1376 $this->assertEquals( 2, count( $comments ) ); 642 1377 $this->assertEquals( $comment_id2, $comments[0]->comment_ID ); 643 1378 $this->assertEquals( $comment_id, $comments[1]->comment_ID ); 644 1379 645 $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'key' ), 'order' => 'ASC' ) ); 1380 $comments = get_comments( 1381 array( 1382 'meta_key' => 'key', 1383 'orderby' => array( 'key' ), 1384 'order' => 'ASC', 1385 ) 1386 ); 646 1387 $this->assertEquals( 2, count( $comments ) ); 647 1388 $this->assertEquals( $comment_id, $comments[0]->comment_ID ); 648 1389 $this->assertEquals( $comment_id2, $comments[1]->comment_ID ); 649 1390 650 $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'meta_value' ), 'order' => 'ASC' ) ); 1391 $comments = get_comments( 1392 array( 1393 'meta_key' => 'key', 1394 'orderby' => array( 'meta_value' ), 1395 'order' => 'ASC', 1396 ) 1397 ); 651 1398 $this->assertEquals( 2, count( $comments ) ); 652 1399 $this->assertEquals( $comment_id, $comments[0]->comment_ID ); 653 1400 $this->assertEquals( $comment_id2, $comments[1]->comment_ID ); 654 1401 655 $comments = get_comments( array( 'meta_value' => 'value3', 'orderby' => array( 'key' ) ) ); 1402 $comments = get_comments( 1403 array( 1404 'meta_value' => 'value3', 1405 'orderby' => array( 'key' ), 1406 ) 1407 ); 656 1408 $this->assertEquals( array( $comment_id3, $comment_id ), wp_list_pluck( $comments, 'comment_ID' ) ); 657 1409 658 $comments = get_comments( array( 'meta_value' => 'value3', 'orderby' => array( 'meta_value' ) ) ); 1410 $comments = get_comments( 1411 array( 1412 'meta_value' => 'value3', 1413 'orderby' => array( 'meta_value' ), 1414 ) 1415 ); 659 1416 $this->assertEquals( array( $comment_id3, $comment_id ), wp_list_pluck( $comments, 'comment_ID' ) ); 660 1417 661 1418 // value1 is present on two different keys for $comment_id yet we should get only one instance 662 1419 // of that comment in the results 663 $comments = get_comments( array( 'meta_value' => 'value1', 'orderby' => array( 'key' ) ) ); 1420 $comments = get_comments( 1421 array( 1422 'meta_value' => 'value1', 1423 'orderby' => array( 'key' ), 1424 ) 1425 ); 664 1426 $this->assertEquals( 1, count( $comments ) ); 665 1427 666 $comments = get_comments( array( 'meta_value' => 'value1', 'orderby' => array( 'meta_value' ) ) ); 1428 $comments = get_comments( 1429 array( 1430 'meta_value' => 'value1', 1431 'orderby' => array( 'meta_value' ), 1432 ) 1433 ); 667 1434 $this->assertEquals( 1, count( $comments ) ); 668 1435 } … … 677 1444 add_comment_meta( $comments[2], 'foo', 'jjj' ); 678 1445 679 $q = new WP_Comment_Query(); 680 $found = $q->query( array( 681 'fields' => 'ids', 682 'meta_query' => array( 683 'foo_key' => array( 684 'key' => 'foo', 685 'compare' => 'EXISTS', 1446 $q = new WP_Comment_Query(); 1447 $found = $q->query( 1448 array( 1449 'fields' => 'ids', 1450 'meta_query' => array( 1451 'foo_key' => array( 1452 'key' => 'foo', 1453 'compare' => 'EXISTS', 1454 ), 686 1455 ), 687 ),688 'orderby' => 'foo_key',689 'order' => 'DESC',690 ) );1456 'orderby' => 'foo_key', 1457 'order' => 'DESC', 1458 ) 1459 ); 691 1460 692 1461 $this->assertEquals( array( $comments[1], $comments[2], $comments[0] ), $found ); … … 697 1466 */ 698 1467 public function test_orderby_clause_key_as_secondary_sort() { 699 $c1 = self::factory()->comment->create( array( 700 'comment_date' => '2015-01-28 03:00:00', 701 ) ); 702 $c2 = self::factory()->comment->create( array( 703 'comment_date' => '2015-01-28 05:00:00', 704 ) ); 705 $c3 = self::factory()->comment->create( array( 706 'comment_date' => '2015-01-28 03:00:00', 707 ) ); 1468 $c1 = self::factory()->comment->create( 1469 array( 1470 'comment_date' => '2015-01-28 03:00:00', 1471 ) 1472 ); 1473 $c2 = self::factory()->comment->create( 1474 array( 1475 'comment_date' => '2015-01-28 05:00:00', 1476 ) 1477 ); 1478 $c3 = self::factory()->comment->create( 1479 array( 1480 'comment_date' => '2015-01-28 03:00:00', 1481 ) 1482 ); 708 1483 709 1484 add_comment_meta( $c1, 'foo', 'jjj' ); … … 711 1486 add_comment_meta( $c3, 'foo', 'aaa' ); 712 1487 713 $q = new WP_Comment_Query(); 714 $found = $q->query( array( 715 'fields' => 'ids', 716 'meta_query' => array( 717 'foo_key' => array( 718 'key' => 'foo', 719 'compare' => 'EXISTS', 1488 $q = new WP_Comment_Query(); 1489 $found = $q->query( 1490 array( 1491 'fields' => 'ids', 1492 'meta_query' => array( 1493 'foo_key' => array( 1494 'key' => 'foo', 1495 'compare' => 'EXISTS', 1496 ), 720 1497 ), 721 ),722 'orderby' => array(723 'comment_date'=> 'asc',724 'foo_key' => 'asc',725 ) ,726 ) );1498 'orderby' => array( 1499 'comment_date' => 'asc', 1500 'foo_key' => 'asc', 1501 ), 1502 ) 1503 ); 727 1504 728 1505 $this->assertEquals( array( $c3, $c1, $c2 ), $found ); … … 742 1519 add_comment_meta( $comments[2], 'bar', 'bbb' ); 743 1520 744 $q = new WP_Comment_Query(); 745 $found = $q->query( array( 746 'fields' => 'ids', 747 'meta_query' => array( 748 'foo_key' => array( 749 'key' => 'foo', 750 'compare' => 'EXISTS', 1521 $q = new WP_Comment_Query(); 1522 $found = $q->query( 1523 array( 1524 'fields' => 'ids', 1525 'meta_query' => array( 1526 'foo_key' => array( 1527 'key' => 'foo', 1528 'compare' => 'EXISTS', 1529 ), 1530 'bar_key' => array( 1531 'key' => 'bar', 1532 'compare' => 'EXISTS', 1533 ), 751 1534 ), 752 ' bar_key'=> array(753 ' key' => 'bar',754 ' compare' => 'EXISTS',1535 'orderby' => array( 1536 'foo_key' => 'asc', 1537 'bar_key' => 'desc', 755 1538 ), 756 ), 757 'orderby' => array( 758 'foo_key' => 'asc', 759 'bar_key' => 'desc', 760 ), 761 ) ); 1539 ) 1540 ); 762 1541 763 1542 $this->assertEquals( array( $comments[2], $comments[0], $comments[1] ), $found ); … … 774 1553 add_comment_meta( $comments[2], 'foo', 'jjj' ); 775 1554 776 $q = new WP_Comment_Query( array( 777 'comment__in' => array( $comments[1], $comments[2] ), 778 'meta_query' => array( 779 array( 780 'key' => 'foo', 781 'value' => 'jjj', 1555 $q = new WP_Comment_Query( 1556 array( 1557 'comment__in' => array( $comments[1], $comments[2] ), 1558 'meta_query' => array( 1559 array( 1560 'key' => 'foo', 1561 'value' => 'jjj', 1562 ), 782 1563 ), 783 ),784 'fields' => 'ids',785 ) );1564 'fields' => 'ids', 1565 ) 1566 ); 786 1567 787 1568 $this->assertEquals( array( $comments[2] ), $q->get_comments() ); … … 798 1579 add_comment_meta( $comments[2], 'foo', 'jjj' ); 799 1580 800 $q = new WP_Comment_Query( array( 801 'comment__not_in' => array( $comments[1], $comments[2] ), 802 'meta_query' => array( 803 array( 804 'key' => 'foo', 805 'value' => 'jjj', 1581 $q = new WP_Comment_Query( 1582 array( 1583 'comment__not_in' => array( $comments[1], $comments[2] ), 1584 'meta_query' => array( 1585 array( 1586 'key' => 'foo', 1587 'value' => 'jjj', 1588 ), 806 1589 ), 807 ),808 'fields' => 'ids',809 ) );1590 'fields' => 'ids', 1591 ) 1592 ); 810 1593 811 1594 $this->assertEquals( array( $comments[0] ), $q->get_comments() ); … … 817 1600 function test_get_comments_by_user() { 818 1601 $users = self::factory()->user->create_many( 2 ); 819 self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 820 self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 821 self::factory()->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 822 823 $comments = get_comments( array( 824 'user_id' => $users[0], 825 'orderby' => 'comment_ID', 826 'order' => 'ASC', 827 ) ); 1602 self::factory()->comment->create( 1603 array( 1604 'user_id' => $users[0], 1605 'comment_post_ID' => self::$post_id, 1606 'comment_approved' => '1', 1607 ) 1608 ); 1609 self::factory()->comment->create( 1610 array( 1611 'user_id' => $users[0], 1612 'comment_post_ID' => self::$post_id, 1613 'comment_approved' => '1', 1614 ) 1615 ); 1616 self::factory()->comment->create( 1617 array( 1618 'user_id' => $users[1], 1619 'comment_post_ID' => self::$post_id, 1620 'comment_approved' => '1', 1621 ) 1622 ); 1623 1624 $comments = get_comments( 1625 array( 1626 'user_id' => $users[0], 1627 'orderby' => 'comment_ID', 1628 'order' => 'ASC', 1629 ) 1630 ); 828 1631 829 1632 $this->assertCount( 2, $comments ); … … 831 1634 $this->assertEquals( $users[0], $comments[1]->user_id ); 832 1635 833 $comments = get_comments( array( 834 'user_id' => $users, 835 'orderby' => 'comment_ID', 836 'order' => 'ASC', 837 ) ); 1636 $comments = get_comments( 1637 array( 1638 'user_id' => $users, 1639 'orderby' => 'comment_ID', 1640 'order' => 'ASC', 1641 ) 1642 ); 838 1643 839 1644 $this->assertCount( 3, $comments ); … … 848 1653 */ 849 1654 public function test_get_comments_by_author_url() { 850 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); 851 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); 852 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar/baz' ) ); 853 854 $comments = get_comments( array( 855 'author_url' => 'http://foo.bar', 856 'fields' => 'ids', 857 ) ); 1655 $c1 = self::factory()->comment->create( 1656 array( 1657 'comment_post_ID' => self::$post_id, 1658 'comment_author' => 'bar', 1659 'comment_author_email' => 'bar@example.com', 1660 'comment_author_url' => 'http://foo.bar', 1661 ) 1662 ); 1663 $c2 = self::factory()->comment->create( 1664 array( 1665 'comment_post_ID' => self::$post_id, 1666 'comment_author' => 'bar', 1667 'comment_author_email' => 'bar@example.com', 1668 'comment_author_url' => 'http://foo.bar', 1669 ) 1670 ); 1671 $c3 = self::factory()->comment->create( 1672 array( 1673 'comment_post_ID' => self::$post_id, 1674 'comment_author' => 'bar', 1675 'comment_author_email' => 'bar@example.com', 1676 'comment_author_url' => 'http://foo.bar/baz', 1677 ) 1678 ); 1679 1680 $comments = get_comments( 1681 array( 1682 'author_url' => 'http://foo.bar', 1683 'fields' => 'ids', 1684 ) 1685 ); 858 1686 859 1687 $this->assertEqualSets( array( $c1, $c2 ), $comments ); … … 864 1692 */ 865 1693 function test_fields_ids_query() { 866 $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 867 $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 868 $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 1694 $comment_1 = self::factory()->comment->create( 1695 array( 1696 'comment_post_ID' => self::$post_id, 1697 'user_id' => 7, 1698 'comment_approved' => '1', 1699 ) 1700 ); 1701 $comment_2 = self::factory()->comment->create( 1702 array( 1703 'comment_post_ID' => self::$post_id, 1704 'user_id' => 1, 1705 'comment_approved' => '1', 1706 ) 1707 ); 1708 $comment_3 = self::factory()->comment->create( 1709 array( 1710 'comment_post_ID' => self::$post_id, 1711 'user_id' => 1, 1712 'comment_approved' => '1', 1713 ) 1714 ); 869 1715 870 1716 // Ensure we are dealing with integers, and not objects. … … 882 1728 */ 883 1729 function test_fields_comment__in() { 884 $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 885 $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 886 $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 887 888 $comment_ids = get_comments( array( 889 'fields' => 'ids', 890 'comment__in' => array( $comment_1, $comment_3 ), 891 ) ); 1730 $comment_1 = self::factory()->comment->create( 1731 array( 1732 'comment_post_ID' => self::$post_id, 1733 'user_id' => 7, 1734 'comment_approved' => '1', 1735 ) 1736 ); 1737 $comment_2 = self::factory()->comment->create( 1738 array( 1739 'comment_post_ID' => self::$post_id, 1740 'user_id' => 1, 1741 'comment_approved' => '1', 1742 ) 1743 ); 1744 $comment_3 = self::factory()->comment->create( 1745 array( 1746 'comment_post_ID' => self::$post_id, 1747 'user_id' => 1, 1748 'comment_approved' => '1', 1749 ) 1750 ); 1751 1752 $comment_ids = get_comments( 1753 array( 1754 'fields' => 'ids', 1755 'comment__in' => array( $comment_1, $comment_3 ), 1756 ) 1757 ); 892 1758 893 1759 $this->assertEqualSets( array( $comment_1, $comment_3 ), $comment_ids ); … … 898 1764 */ 899 1765 function test_fields_comment__not_in() { 900 $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 901 $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 902 $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 903 904 $comment_ids = get_comments( array( 905 'fields' => 'ids', 906 'comment__not_in' => array( $comment_2, $comment_3 ), 907 ) ); 1766 $comment_1 = self::factory()->comment->create( 1767 array( 1768 'comment_post_ID' => self::$post_id, 1769 'user_id' => 7, 1770 'comment_approved' => '1', 1771 ) 1772 ); 1773 $comment_2 = self::factory()->comment->create( 1774 array( 1775 'comment_post_ID' => self::$post_id, 1776 'user_id' => 1, 1777 'comment_approved' => '1', 1778 ) 1779 ); 1780 $comment_3 = self::factory()->comment->create( 1781 array( 1782 'comment_post_ID' => self::$post_id, 1783 'user_id' => 1, 1784 'comment_approved' => '1', 1785 ) 1786 ); 1787 1788 $comment_ids = get_comments( 1789 array( 1790 'fields' => 'ids', 1791 'comment__not_in' => array( $comment_2, $comment_3 ), 1792 ) 1793 ); 908 1794 909 1795 $this->assertEqualSets( array( $comment_1 ), $comment_ids ); … … 918 1804 $p3 = self::factory()->post->create(); 919 1805 920 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); 921 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); 922 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); 923 924 $comment_ids = get_comments( array( 925 'fields' => 'ids', 926 'post__in' => array( $p1, $p2 ), 927 ) ); 1806 $c1 = self::factory()->comment->create( 1807 array( 1808 'comment_post_ID' => $p1, 1809 'user_id' => 7, 1810 'comment_approved' => '1', 1811 ) 1812 ); 1813 $c2 = self::factory()->comment->create( 1814 array( 1815 'comment_post_ID' => $p2, 1816 'user_id' => 1, 1817 'comment_approved' => '1', 1818 ) 1819 ); 1820 $c3 = self::factory()->comment->create( 1821 array( 1822 'comment_post_ID' => $p3, 1823 'user_id' => 1, 1824 'comment_approved' => '1', 1825 ) 1826 ); 1827 1828 $comment_ids = get_comments( 1829 array( 1830 'fields' => 'ids', 1831 'post__in' => array( $p1, $p2 ), 1832 ) 1833 ); 928 1834 929 1835 $this->assertEqualSets( array( $c1, $c2 ), $comment_ids ); … … 938 1844 $p3 = self::factory()->post->create(); 939 1845 940 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); 941 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); 942 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); 943 944 $comment_ids = get_comments( array( 945 'fields' => 'ids', 946 'post__not_in' => array( $p1, $p2 ), 947 ) ); 1846 $c1 = self::factory()->comment->create( 1847 array( 1848 'comment_post_ID' => $p1, 1849 'user_id' => 7, 1850 'comment_approved' => '1', 1851 ) 1852 ); 1853 $c2 = self::factory()->comment->create( 1854 array( 1855 'comment_post_ID' => $p2, 1856 'user_id' => 1, 1857 'comment_approved' => '1', 1858 ) 1859 ); 1860 $c3 = self::factory()->comment->create( 1861 array( 1862 'comment_post_ID' => $p3, 1863 'user_id' => 1, 1864 'comment_approved' => '1', 1865 ) 1866 ); 1867 1868 $comment_ids = get_comments( 1869 array( 1870 'fields' => 'ids', 1871 'post__not_in' => array( $p1, $p2 ), 1872 ) 1873 ); 948 1874 949 1875 $this->assertEqualSets( array( $c3 ), $comment_ids ); … … 957 1883 $author_id2 = 106; 958 1884 959 $p1 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 960 $p2 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 961 $p3 = self::factory()->post->create( array( 'post_author' => $author_id2 ) ); 962 963 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); 964 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); 965 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); 966 967 $comment_ids = get_comments( array( 968 'fields' => 'ids', 969 'post_author__in' => array( $author_id1 ), 970 ) ); 1885 $p1 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 1886 $p2 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 1887 $p3 = self::factory()->post->create( array( 'post_author' => $author_id2 ) ); 1888 1889 $c1 = self::factory()->comment->create( 1890 array( 1891 'comment_post_ID' => $p1, 1892 'user_id' => 1, 1893 'comment_approved' => '1', 1894 ) 1895 ); 1896 $c2 = self::factory()->comment->create( 1897 array( 1898 'comment_post_ID' => $p2, 1899 'user_id' => 1, 1900 'comment_approved' => '1', 1901 ) 1902 ); 1903 $c3 = self::factory()->comment->create( 1904 array( 1905 'comment_post_ID' => $p3, 1906 'user_id' => 1, 1907 'comment_approved' => '1', 1908 ) 1909 ); 1910 1911 $comment_ids = get_comments( 1912 array( 1913 'fields' => 'ids', 1914 'post_author__in' => array( $author_id1 ), 1915 ) 1916 ); 971 1917 972 1918 $this->assertEqualSets( array( $c1, $c2 ), $comment_ids ); … … 980 1926 $author_id2 = 112; 981 1927 982 $p1 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 983 $p2 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 984 $p3 = self::factory()->post->create( array( 'post_author' => $author_id2 ) ); 985 986 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); 987 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); 988 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); 989 990 $comment_ids = get_comments( array( 991 'fields' => 'ids', 992 'post_author__not_in' => array( $author_id1 ), 993 ) ); 1928 $p1 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 1929 $p2 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); 1930 $p3 = self::factory()->post->create( array( 'post_author' => $author_id2 ) ); 1931 1932 $c1 = self::factory()->comment->create( 1933 array( 1934 'comment_post_ID' => $p1, 1935 'user_id' => 1, 1936 'comment_approved' => '1', 1937 ) 1938 ); 1939 $c2 = self::factory()->comment->create( 1940 array( 1941 'comment_post_ID' => $p2, 1942 'user_id' => 1, 1943 'comment_approved' => '1', 1944 ) 1945 ); 1946 $c3 = self::factory()->comment->create( 1947 array( 1948 'comment_post_ID' => $p3, 1949 'user_id' => 1, 1950 'comment_approved' => '1', 1951 ) 1952 ); 1953 1954 $comment_ids = get_comments( 1955 array( 1956 'fields' => 'ids', 1957 'post_author__not_in' => array( $author_id1 ), 1958 ) 1959 ); 994 1960 995 1961 $this->assertEqualSets( array( $c3 ), $comment_ids ); 996 1962 } 997 1963 998 999 1000 1964 /** 1965 * @ticket 29885 1966 */ 1001 1967 function test_fields_author__in() { 1002 1968 $p1 = self::factory()->post->create(); … … 1005 1971 $p4 = self::factory()->post->create(); 1006 1972 1007 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); 1008 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); 1009 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); 1010 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); 1011 1012 $comment_ids = get_comments( array( 1013 'fields' => 'ids', 1014 'author__in' => array( 1, 3 ), 1015 ) ); 1973 $c1 = self::factory()->comment->create( 1974 array( 1975 'comment_post_ID' => $p1, 1976 'user_id' => 1, 1977 'comment_approved' => '1', 1978 ) 1979 ); 1980 $c2 = self::factory()->comment->create( 1981 array( 1982 'comment_post_ID' => $p1, 1983 'user_id' => 2, 1984 'comment_approved' => '1', 1985 ) 1986 ); 1987 $c3 = self::factory()->comment->create( 1988 array( 1989 'comment_post_ID' => $p2, 1990 'user_id' => 3, 1991 'comment_approved' => '1', 1992 ) 1993 ); 1994 $c4 = self::factory()->comment->create( 1995 array( 1996 'comment_post_ID' => $p4, 1997 'user_id' => 4, 1998 'comment_approved' => '1', 1999 ) 2000 ); 2001 2002 $comment_ids = get_comments( 2003 array( 2004 'fields' => 'ids', 2005 'author__in' => array( 1, 3 ), 2006 ) 2007 ); 1016 2008 1017 2009 $this->assertEqualSets( array( $c1, $c3 ), $comment_ids ); 1018 2010 } 1019 2011 1020 1021 1022 2012 /** 2013 * @ticket 29885 2014 */ 1023 2015 function test_fields_author__not_in() { 1024 2016 $p1 = self::factory()->post->create(); … … 1027 2019 $p4 = self::factory()->post->create(); 1028 2020 1029 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); 1030 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); 1031 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); 1032 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); 1033 1034 $comment_ids = get_comments( array( 1035 'fields' => 'ids', 1036 'author__not_in' => array( 1, 2 ), 1037 ) ); 2021 $c1 = self::factory()->comment->create( 2022 array( 2023 'comment_post_ID' => $p1, 2024 'user_id' => 1, 2025 'comment_approved' => '1', 2026 ) 2027 ); 2028 $c2 = self::factory()->comment->create( 2029 array( 2030 'comment_post_ID' => $p1, 2031 'user_id' => 2, 2032 'comment_approved' => '1', 2033 ) 2034 ); 2035 $c3 = self::factory()->comment->create( 2036 array( 2037 'comment_post_ID' => $p2, 2038 'user_id' => 3, 2039 'comment_approved' => '1', 2040 ) 2041 ); 2042 $c4 = self::factory()->comment->create( 2043 array( 2044 'comment_post_ID' => $p4, 2045 'user_id' => 4, 2046 'comment_approved' => '1', 2047 ) 2048 ); 2049 2050 $comment_ids = get_comments( 2051 array( 2052 'fields' => 'ids', 2053 'author__not_in' => array( 1, 2 ), 2054 ) 2055 ); 1038 2056 1039 2057 $this->assertEqualSets( array( $c3, $c4 ), $comment_ids ); … … 1044 2062 */ 1045 2063 public function test_get_comments_with_status_all() { 1046 $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1047 $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 1048 $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); 2064 $comment_1 = self::factory()->comment->create( 2065 array( 2066 'comment_post_ID' => self::$post_id, 2067 'user_id' => 7, 2068 'comment_approved' => '1', 2069 ) 2070 ); 2071 $comment_2 = self::factory()->comment->create( 2072 array( 2073 'comment_post_ID' => self::$post_id, 2074 'user_id' => 1, 2075 'comment_approved' => '1', 2076 ) 2077 ); 2078 $comment_3 = self::factory()->comment->create( 2079 array( 2080 'comment_post_ID' => self::$post_id, 2081 'user_id' => 1, 2082 'comment_approved' => '0', 2083 ) 2084 ); 1049 2085 $comments_approved_1 = get_comments( array( 'status' => 'all' ) ); 1050 2086 … … 1057 2093 */ 1058 2094 public function test_get_comments_with_include_unapproved_user_id() { 1059 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1060 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 1061 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); 1062 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); 1063 1064 $found = get_comments( array( 1065 'fields' => 'ids', 1066 'include_unapproved' => 1, 1067 'status' => 'approve', 1068 ) ); 2095 $c1 = self::factory()->comment->create( 2096 array( 2097 'comment_post_ID' => self::$post_id, 2098 'user_id' => 7, 2099 'comment_approved' => '1', 2100 ) 2101 ); 2102 $c2 = self::factory()->comment->create( 2103 array( 2104 'comment_post_ID' => self::$post_id, 2105 'user_id' => 1, 2106 'comment_approved' => '1', 2107 ) 2108 ); 2109 $c3 = self::factory()->comment->create( 2110 array( 2111 'comment_post_ID' => self::$post_id, 2112 'user_id' => 1, 2113 'comment_approved' => '0', 2114 ) 2115 ); 2116 $c4 = self::factory()->comment->create( 2117 array( 2118 'comment_post_ID' => self::$post_id, 2119 'user_id' => 6, 2120 'comment_approved' => '0', 2121 ) 2122 ); 2123 2124 $found = get_comments( 2125 array( 2126 'fields' => 'ids', 2127 'include_unapproved' => 1, 2128 'status' => 'approve', 2129 ) 2130 ); 1069 2131 1070 2132 $this->assertEqualSets( array( $c1, $c2, $c3 ), $found ); … … 1075 2137 */ 1076 2138 public function test_get_comments_with_include_unapproved_user_id_array() { 1077 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1078 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 1079 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); 1080 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); 1081 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); 1082 1083 $found = get_comments( array( 1084 'fields' => 'ids', 1085 'include_unapproved' => array( 1, 8 ), 1086 'status' => 'approve', 1087 ) ); 2139 $c1 = self::factory()->comment->create( 2140 array( 2141 'comment_post_ID' => self::$post_id, 2142 'user_id' => 7, 2143 'comment_approved' => '1', 2144 ) 2145 ); 2146 $c2 = self::factory()->comment->create( 2147 array( 2148 'comment_post_ID' => self::$post_id, 2149 'user_id' => 1, 2150 'comment_approved' => '1', 2151 ) 2152 ); 2153 $c3 = self::factory()->comment->create( 2154 array( 2155 'comment_post_ID' => self::$post_id, 2156 'user_id' => 1, 2157 'comment_approved' => '0', 2158 ) 2159 ); 2160 $c4 = self::factory()->comment->create( 2161 array( 2162 'comment_post_ID' => self::$post_id, 2163 'user_id' => 6, 2164 'comment_approved' => '0', 2165 ) 2166 ); 2167 $c5 = self::factory()->comment->create( 2168 array( 2169 'comment_post_ID' => self::$post_id, 2170 'user_id' => 8, 2171 'comment_approved' => '0', 2172 ) 2173 ); 2174 2175 $found = get_comments( 2176 array( 2177 'fields' => 'ids', 2178 'include_unapproved' => array( 1, 8 ), 2179 'status' => 'approve', 2180 ) 2181 ); 1088 2182 1089 2183 $this->assertEqualSets( array( $c1, $c2, $c3, $c5 ), $found ); … … 1094 2188 */ 1095 2189 public function test_get_comments_with_include_unapproved_user_id_comma_separated() { 1096 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1097 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); 1098 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); 1099 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); 1100 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); 1101 1102 $found = get_comments( array( 1103 'fields' => 'ids', 1104 'include_unapproved' => '1,8', 1105 'status' => 'approve', 1106 ) ); 2190 $c1 = self::factory()->comment->create( 2191 array( 2192 'comment_post_ID' => self::$post_id, 2193 'user_id' => 7, 2194 'comment_approved' => '1', 2195 ) 2196 ); 2197 $c2 = self::factory()->comment->create( 2198 array( 2199 'comment_post_ID' => self::$post_id, 2200 'user_id' => 1, 2201 'comment_approved' => '1', 2202 ) 2203 ); 2204 $c3 = self::factory()->comment->create( 2205 array( 2206 'comment_post_ID' => self::$post_id, 2207 'user_id' => 1, 2208 'comment_approved' => '0', 2209 ) 2210 ); 2211 $c4 = self::factory()->comment->create( 2212 array( 2213 'comment_post_ID' => self::$post_id, 2214 'user_id' => 6, 2215 'comment_approved' => '0', 2216 ) 2217 ); 2218 $c5 = self::factory()->comment->create( 2219 array( 2220 'comment_post_ID' => self::$post_id, 2221 'user_id' => 8, 2222 'comment_approved' => '0', 2223 ) 2224 ); 2225 2226 $found = get_comments( 2227 array( 2228 'fields' => 'ids', 2229 'include_unapproved' => '1,8', 2230 'status' => 'approve', 2231 ) 2232 ); 1107 2233 1108 2234 $this->assertEqualSets( array( $c1, $c2, $c3, $c5 ), $found ); … … 1113 2239 */ 1114 2240 public function test_get_comments_with_include_unapproved_author_email() { 1115 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1116 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); 1117 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); 1118 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); 1119 1120 $found = get_comments( array( 1121 'fields' => 'ids', 1122 'include_unapproved' => 'foo@example.com', 1123 'status' => 'approve', 1124 ) ); 2241 $c1 = self::factory()->comment->create( 2242 array( 2243 'comment_post_ID' => self::$post_id, 2244 'user_id' => 7, 2245 'comment_approved' => '1', 2246 ) 2247 ); 2248 $c2 = self::factory()->comment->create( 2249 array( 2250 'comment_post_ID' => self::$post_id, 2251 'user_id' => 0, 2252 'comment_approved' => '1', 2253 'comment_author' => 'foo', 2254 'comment_author_email' => 'foo@example.com', 2255 ) 2256 ); 2257 $c3 = self::factory()->comment->create( 2258 array( 2259 'comment_post_ID' => self::$post_id, 2260 'user_id' => 0, 2261 'comment_approved' => '0', 2262 'comment_author' => 'foo', 2263 'comment_author_email' => 'foo@example.com', 2264 ) 2265 ); 2266 $c4 = self::factory()->comment->create( 2267 array( 2268 'comment_post_ID' => self::$post_id, 2269 'user_id' => 0, 2270 'comment_approved' => '0', 2271 'comment_author' => 'foo', 2272 'comment_author_email' => 'bar@example.com', 2273 ) 2274 ); 2275 2276 $found = get_comments( 2277 array( 2278 'fields' => 'ids', 2279 'include_unapproved' => 'foo@example.com', 2280 'status' => 'approve', 2281 ) 2282 ); 1125 2283 1126 2284 $this->assertEqualSets( array( $c1, $c2, $c3 ), $found ); … … 1131 2289 */ 1132 2290 public function test_get_comments_with_include_unapproved_mixed_array() { 1133 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1134 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); 1135 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); 1136 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); 1137 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); 1138 1139 $found = get_comments( array( 1140 'fields' => 'ids', 1141 'include_unapproved' => array( 'foo@example.com', 4 ), 1142 'status' => 'approve', 1143 ) ); 2291 $c1 = self::factory()->comment->create( 2292 array( 2293 'comment_post_ID' => self::$post_id, 2294 'user_id' => 7, 2295 'comment_approved' => '1', 2296 ) 2297 ); 2298 $c2 = self::factory()->comment->create( 2299 array( 2300 'comment_post_ID' => self::$post_id, 2301 'user_id' => 0, 2302 'comment_approved' => '1', 2303 'comment_author' => 'foo', 2304 'comment_author_email' => 'foo@example.com', 2305 ) 2306 ); 2307 $c3 = self::factory()->comment->create( 2308 array( 2309 'comment_post_ID' => self::$post_id, 2310 'user_id' => 0, 2311 'comment_approved' => '0', 2312 'comment_author' => 'foo', 2313 'comment_author_email' => 'foo@example.com', 2314 ) 2315 ); 2316 $c4 = self::factory()->comment->create( 2317 array( 2318 'comment_post_ID' => self::$post_id, 2319 'user_id' => 0, 2320 'comment_approved' => '0', 2321 'comment_author' => 'foo', 2322 'comment_author_email' => 'bar@example.com', 2323 ) 2324 ); 2325 $c5 = self::factory()->comment->create( 2326 array( 2327 'comment_post_ID' => self::$post_id, 2328 'user_id' => 4, 2329 'comment_approved' => '0', 2330 'comment_author' => 'foo', 2331 'comment_author_email' => 'bar@example.com', 2332 ) 2333 ); 2334 2335 $found = get_comments( 2336 array( 2337 'fields' => 'ids', 2338 'include_unapproved' => array( 'foo@example.com', 4 ), 2339 'status' => 'approve', 2340 ) 2341 ); 1144 2342 1145 2343 $this->assertEqualSets( array( $c1, $c2, $c3, $c5 ), $found ); … … 1150 2348 */ 1151 2349 public function test_get_comments_with_include_unapproved_mixed_comma_separated() { 1152 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); 1153 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); 1154 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); 1155 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); 1156 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); 1157 1158 $found = get_comments( array( 1159 'fields' => 'ids', 1160 'include_unapproved' => 'foo@example.com, 4', 1161 'status' => 'approve', 1162 ) ); 2350 $c1 = self::factory()->comment->create( 2351 array( 2352 'comment_post_ID' => self::$post_id, 2353 'user_id' => 7, 2354 'comment_approved' => '1', 2355 ) 2356 ); 2357 $c2 = self::factory()->comment->create( 2358 array( 2359 'comment_post_ID' => self::$post_id, 2360 'user_id' => 0, 2361 'comment_approved' => '1', 2362 'comment_author' => 'foo', 2363 'comment_author_email' => 'foo@example.com', 2364 ) 2365 ); 2366 $c3 = self::factory()->comment->create( 2367 array( 2368 'comment_post_ID' => self::$post_id, 2369 'user_id' => 0, 2370 'comment_approved' => '0', 2371 'comment_author' => 'foo', 2372 'comment_author_email' => 'foo@example.com', 2373 ) 2374 ); 2375 $c4 = self::factory()->comment->create( 2376 array( 2377 'comment_post_ID' => self::$post_id, 2378 'user_id' => 0, 2379 'comment_approved' => '0', 2380 'comment_author' => 'foo', 2381 'comment_author_email' => 'bar@example.com', 2382 ) 2383 ); 2384 $c5 = self::factory()->comment->create( 2385 array( 2386 'comment_post_ID' => self::$post_id, 2387 'user_id' => 4, 2388 'comment_approved' => '0', 2389 'comment_author' => 'foo', 2390 'comment_author_email' => 'bar@example.com', 2391 ) 2392 ); 2393 2394 $found = get_comments( 2395 array( 2396 'fields' => 'ids', 2397 'include_unapproved' => 'foo@example.com, 4', 2398 'status' => 'approve', 2399 ) 2400 ); 1163 2401 1164 2402 $this->assertEqualSets( array( $c1, $c2, $c3, $c5 ), $found ); … … 1166 2404 1167 2405 public function test_search() { 1168 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); 1169 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); 1170 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); 1171 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); 1172 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); 1173 $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); 1174 1175 $q = new WP_Comment_Query(); 1176 $found = $q->query( array( 1177 'search' => 'foo', 1178 'fields' => 'ids', 1179 ) ); 2406 $c1 = self::factory()->comment->create( 2407 array( 2408 'comment_post_ID' => self::$post_id, 2409 'user_id' => 4, 2410 'comment_approved' => '0', 2411 'comment_author' => 'foo', 2412 'comment_author_email' => 'bar@example.com', 2413 ) 2414 ); 2415 $c2 = self::factory()->comment->create( 2416 array( 2417 'comment_post_ID' => self::$post_id, 2418 'user_id' => 4, 2419 'comment_approved' => '0', 2420 'comment_author' => 'bar', 2421 'comment_author_email' => 'foo@example.com', 2422 ) 2423 ); 2424 $c3 = self::factory()->comment->create( 2425 array( 2426 'comment_post_ID' => self::$post_id, 2427 'user_id' => 4, 2428 'comment_approved' => '0', 2429 'comment_author' => 'bar', 2430 'comment_author_email' => 'bar@example.com', 2431 'comment_author_url' => 'http://foo.bar', 2432 ) 2433 ); 2434 $c4 = self::factory()->comment->create( 2435 array( 2436 'comment_post_ID' => self::$post_id, 2437 'user_id' => 4, 2438 'comment_approved' => '0', 2439 'comment_author' => 'bar', 2440 'comment_author_email' => 'bar@example.com', 2441 'comment_author_url' => 'http://example.com', 2442 'comment_author_IP' => 'foo.bar', 2443 ) 2444 ); 2445 $c5 = self::factory()->comment->create( 2446 array( 2447 'comment_post_ID' => self::$post_id, 2448 'user_id' => 4, 2449 'comment_approved' => '0', 2450 'comment_author' => 'bar', 2451 'comment_author_email' => 'bar@example.com', 2452 'comment_author_url' => 'http://example.com', 2453 'comment_content' => 'Nice foo comment', 2454 ) 2455 ); 2456 $c6 = self::factory()->comment->create( 2457 array( 2458 'comment_post_ID' => self::$post_id, 2459 'user_id' => 4, 2460 'comment_approved' => '0', 2461 'comment_author' => 'bar', 2462 'comment_author_email' => 'bar@example.com', 2463 'comment_author_url' => 'http://example.com', 2464 ) 2465 ); 2466 2467 $q = new WP_Comment_Query(); 2468 $found = $q->query( 2469 array( 2470 'search' => 'foo', 2471 'fields' => 'ids', 2472 ) 2473 ); 1180 2474 1181 2475 $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c5 ), $found ); … … 1187 2481 public function test_search_false_should_be_ignored() { 1188 2482 $q = new WP_Comment_Query(); 1189 $q->query( array( 1190 'search' => false, 1191 ) ); 1192 $this->assertNotContains( "comment_author LIKE", $q->request ); 2483 $q->query( 2484 array( 2485 'search' => false, 2486 ) 2487 ); 2488 $this->assertNotContains( 'comment_author LIKE', $q->request ); 1193 2489 } 1194 2490 … … 1198 2494 public function test_search_null_should_be_ignored() { 1199 2495 $q = new WP_Comment_Query(); 1200 $q->query( array( 1201 'search' => null, 1202 ) ); 1203 $this->assertNotContains( "comment_author LIKE", $q->request ); 2496 $q->query( 2497 array( 2498 'search' => null, 2499 ) 2500 ); 2501 $this->assertNotContains( 'comment_author LIKE', $q->request ); 1204 2502 } 1205 2503 … … 1209 2507 public function test_search_empty_string_should_be_ignored() { 1210 2508 $q = new WP_Comment_Query(); 1211 $q->query( array( 1212 'search' => false, 1213 ) ); 1214 $this->assertNotContains( "comment_author LIKE", $q->request ); 2509 $q->query( 2510 array( 2511 'search' => false, 2512 ) 2513 ); 2514 $this->assertNotContains( 'comment_author LIKE', $q->request ); 1215 2515 } 1216 2516 … … 1221 2521 global $wpdb; 1222 2522 $q = new WP_Comment_Query(); 1223 $q->query( array( 1224 'search' => 0, 1225 ) ); 2523 $q->query( 2524 array( 2525 'search' => 0, 2526 ) 2527 ); 1226 2528 $this->assertContains( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) ); 1227 2529 } … … 1233 2535 global $wpdb; 1234 2536 $q = new WP_Comment_Query(); 1235 $q->query( array( 1236 'search' => '0', 1237 ) ); 2537 $q->query( 2538 array( 2539 'search' => '0', 2540 ) 2541 ); 1238 2542 $this->assertContains( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) ); 1239 2543 } … … 1252 2556 1253 2557 $q = new WP_Comment_Query(); 1254 $q->query( array( 1255 'orderby' => 'comment_agent', 1256 ) ); 2558 $q->query( 2559 array( 2560 'orderby' => 'comment_agent', 2561 ) 2562 ); 1257 2563 1258 2564 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent", $q->request ); … … 1263 2569 1264 2570 $q = new WP_Comment_Query(); 1265 $q->query( array( 1266 'orderby' => 'foo', 1267 ) ); 2571 $q->query( 2572 array( 2573 'orderby' => 'foo', 2574 ) 2575 ); 1268 2576 1269 2577 $this->assertContains( "ORDER BY $wpdb->comments.comment_date_gmt", $q->request ); … … 1274 2582 1275 2583 $q = new WP_Comment_Query(); 1276 $q->query( array( 1277 'orderby' => 'comment_agent comment_approved', 1278 ) ); 2584 $q->query( 2585 array( 2586 'orderby' => 'comment_agent comment_approved', 2587 ) 2588 ); 1279 2589 1280 2590 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); … … 1285 2595 1286 2596 $q = new WP_Comment_Query(); 1287 $q->query( array( 1288 'orderby' => 'comment_agent, comment_approved', 1289 ) ); 2597 $q->query( 2598 array( 2599 'orderby' => 'comment_agent, comment_approved', 2600 ) 2601 ); 1290 2602 1291 2603 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); … … 1296 2608 1297 2609 $q = new WP_Comment_Query(); 1298 $q->query( array( 1299 'orderby' => array( 'comment_agent', 'comment_approved' ), 1300 ) ); 2610 $q->query( 2611 array( 2612 'orderby' => array( 'comment_agent', 'comment_approved' ), 2613 ) 2614 ); 1301 2615 1302 2616 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); … … 1307 2621 1308 2622 $q = new WP_Comment_Query(); 1309 $q->query( array( 1310 'orderby' => array( 'comment_agent', 'foo', 'comment_approved' ), 1311 ) ); 2623 $q->query( 2624 array( 2625 'orderby' => array( 'comment_agent', 'foo', 'comment_approved' ), 2626 ) 2627 ); 1312 2628 1313 2629 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request ); … … 1318 2634 1319 2635 $q = new WP_Comment_Query(); 1320 $q->query( array( 1321 'orderby' => array( 'foo', 'bar', 'baz' ), 1322 ) ); 2636 $q->query( 2637 array( 2638 'orderby' => array( 'foo', 'bar', 'baz' ), 2639 ) 2640 ); 1323 2641 1324 2642 $this->assertContains( "ORDER BY $wpdb->comments.comment_date_gmt", $q->request ); … … 1330 2648 public function test_orderby_none() { 1331 2649 $q = new WP_Comment_Query(); 1332 $q->query( array( 1333 'orderby' => 'none', 1334 ) ); 2650 $q->query( 2651 array( 2652 'orderby' => 'none', 2653 ) 2654 ); 1335 2655 1336 2656 $this->assertNotContains( 'ORDER BY', $q->request ); … … 1342 2662 public function test_orderby_empty_array() { 1343 2663 $q = new WP_Comment_Query(); 1344 $q->query( array( 1345 'orderby' => array(), 1346 ) ); 2664 $q->query( 2665 array( 2666 'orderby' => array(), 2667 ) 2668 ); 1347 2669 1348 2670 $this->assertNotContains( 'ORDER BY', $q->request ); … … 1354 2676 public function test_orderby_false() { 1355 2677 $q = new WP_Comment_Query(); 1356 $q->query( array( 1357 'orderby' => false, 1358 ) ); 2678 $q->query( 2679 array( 2680 'orderby' => false, 2681 ) 2682 ); 1359 2683 1360 2684 $this->assertNotContains( 'ORDER BY', $q->request ); … … 1367 2691 global $wpdb; 1368 2692 1369 $q = new WP_Comment_Query(); 1370 $found = $q->query( array( 1371 'fields' => 'ids', 1372 'orderby' => array( 1373 'comment_agent' => 'DESC', 1374 'comment_date_gmt' => 'ASC', 1375 'comment_ID' => 'DESC', 1376 ), 1377 ) ); 2693 $q = new WP_Comment_Query(); 2694 $found = $q->query( 2695 array( 2696 'fields' => 'ids', 2697 'orderby' => array( 2698 'comment_agent' => 'DESC', 2699 'comment_date_gmt' => 'ASC', 2700 'comment_ID' => 'DESC', 2701 ), 2702 ) 2703 ); 1378 2704 1379 2705 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date_gmt ASC, $wpdb->comments.comment_ID DESC", $q->request ); … … 1386 2712 global $wpdb; 1387 2713 1388 $q = new WP_Comment_Query(); 1389 $found = $q->query( array( 1390 'fields' => 'ids', 1391 'orderby' => array( 1392 'comment_agent' => 'DESC', 1393 'foo' => 'ASC', 1394 'comment_ID' => 'DESC', 1395 ), 1396 ) ); 2714 $q = new WP_Comment_Query(); 2715 $found = $q->query( 2716 array( 2717 'fields' => 'ids', 2718 'orderby' => array( 2719 'comment_agent' => 'DESC', 2720 'foo' => 'ASC', 2721 'comment_ID' => 'DESC', 2722 ), 2723 ) 2724 ); 1397 2725 1398 2726 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_ID DESC", $q->request ); … … 1405 2733 global $wpdb; 1406 2734 1407 $q = new WP_Comment_Query(); 1408 $found = $q->query( array( 1409 'fields' => 'ids', 1410 'orderby' => array( 1411 'comment_agent' => 'DESC', 1412 'comment_date_gmt' => 'foo', 1413 'comment_ID' => 'DESC', 1414 ), 1415 ) ); 2735 $q = new WP_Comment_Query(); 2736 $found = $q->query( 2737 array( 2738 'fields' => 'ids', 2739 'orderby' => array( 2740 'comment_agent' => 'DESC', 2741 'comment_date_gmt' => 'foo', 2742 'comment_ID' => 'DESC', 2743 ), 2744 ) 2745 ); 1416 2746 1417 2747 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date_gmt DESC, $wpdb->comments.comment_ID DESC", $q->request ); … … 1424 2754 global $wpdb; 1425 2755 1426 $q = new WP_Comment_Query(); 1427 $found = $q->query( array( 1428 'fields' => 'ids', 1429 'orderby' => array( 1430 'comment_agent' => 'DESC', 1431 'comment_date_gmt' => 'ASC', 1432 ), 1433 ) ); 2756 $q = new WP_Comment_Query(); 2757 $found = $q->query( 2758 array( 2759 'fields' => 'ids', 2760 'orderby' => array( 2761 'comment_agent' => 'DESC', 2762 'comment_date_gmt' => 'ASC', 2763 ), 2764 ) 2765 ); 1434 2766 1435 2767 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date_gmt ASC, $wpdb->comments.comment_ID ASC", $q->request ); … … 1442 2774 global $wpdb; 1443 2775 1444 $q = new WP_Comment_Query(); 1445 $found = $q->query( array( 1446 'fields' => 'ids', 1447 'orderby' => array( 1448 'comment_agent' => 'DESC', 1449 'comment_date' => 'ASC', 1450 ), 1451 ) ); 2776 $q = new WP_Comment_Query(); 2777 $found = $q->query( 2778 array( 2779 'fields' => 'ids', 2780 'orderby' => array( 2781 'comment_agent' => 'DESC', 2782 'comment_date' => 'ASC', 2783 ), 2784 ) 2785 ); 1452 2786 1453 2787 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date ASC, $wpdb->comments.comment_ID ASC", $q->request ); … … 1460 2794 global $wpdb; 1461 2795 1462 $q = new WP_Comment_Query(); 1463 $found = $q->query( array( 1464 'fields' => 'ids', 1465 'orderby' => array( 1466 'comment_agent' => 'ASC', 1467 ), 1468 ) ); 2796 $q = new WP_Comment_Query(); 2797 $found = $q->query( 2798 array( 2799 'fields' => 'ids', 2800 'orderby' => array( 2801 'comment_agent' => 'ASC', 2802 ), 2803 ) 2804 ); 1469 2805 1470 2806 $this->assertContains( "ORDER BY $wpdb->comments.comment_agent ASC, $wpdb->comments.comment_ID DESC", $q->request ); … … 1475 2811 */ 1476 2812 public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() { 1477 $now = current_time( 'mysql', 1 ); 1478 $comments = self::factory()->comment->create_many( 5, array( 1479 'comment_post_ID' => self::$post_id, 1480 'comment_date_gmt' => $now, 1481 ) ); 1482 1483 $q = new WP_Comment_Query(); 1484 $found = $q->query( array( 1485 'orderby' => 'comment_date_gmt', 1486 'order' => 'ASC', 1487 ) ); 2813 $now = current_time( 'mysql', 1 ); 2814 $comments = self::factory()->comment->create_many( 2815 5, array( 2816 'comment_post_ID' => self::$post_id, 2817 'comment_date_gmt' => $now, 2818 ) 2819 ); 2820 2821 $q = new WP_Comment_Query(); 2822 $found = $q->query( 2823 array( 2824 'orderby' => 'comment_date_gmt', 2825 'order' => 'ASC', 2826 ) 2827 ); 1488 2828 1489 2829 // $comments is ASC by default. … … 1495 2835 */ 1496 2836 public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() { 1497 $now = current_time( 'mysql', 1 ); 1498 $comments = self::factory()->comment->create_many( 5, array( 1499 'comment_post_ID' => self::$post_id, 1500 'comment_date_gmt' => $now, 1501 ) ); 1502 1503 $q = new WP_Comment_Query(); 1504 $found = $q->query( array( 1505 'orderby' => 'comment_date_gmt', 1506 'order' => 'DESC', 1507 ) ); 2837 $now = current_time( 'mysql', 1 ); 2838 $comments = self::factory()->comment->create_many( 2839 5, array( 2840 'comment_post_ID' => self::$post_id, 2841 'comment_date_gmt' => $now, 2842 ) 2843 ); 2844 2845 $q = new WP_Comment_Query(); 2846 $found = $q->query( 2847 array( 2848 'orderby' => 'comment_date_gmt', 2849 'order' => 'DESC', 2850 ) 2851 ); 1508 2852 1509 2853 // $comments is ASC by default. … … 1515 2859 public function test_meta_vars_should_be_converted_to_meta_query() { 1516 2860 $q = new WP_Comment_Query(); 1517 $q->query( array( 1518 'meta_key' => 'foo', 1519 'meta_value' => '5', 1520 'meta_compare' => '>', 1521 'meta_type' => 'SIGNED', 1522 ) ); 2861 $q->query( 2862 array( 2863 'meta_key' => 'foo', 2864 'meta_value' => '5', 2865 'meta_compare' => '>', 2866 'meta_type' => 'SIGNED', 2867 ) 2868 ); 1523 2869 1524 2870 $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] ); … … 1529 2875 1530 2876 public function test_count() { 1531 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); 1532 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); 1533 1534 $q = new WP_Comment_Query(); 1535 $found = $q->query( array( 1536 'count' => true, 1537 ) ); 2877 $c1 = self::factory()->comment->create( 2878 array( 2879 'comment_post_ID' => self::$post_id, 2880 'user_id' => 7, 2881 ) 2882 ); 2883 $c2 = self::factory()->comment->create( 2884 array( 2885 'comment_post_ID' => self::$post_id, 2886 'user_id' => 7, 2887 ) 2888 ); 2889 2890 $q = new WP_Comment_Query(); 2891 $found = $q->query( 2892 array( 2893 'count' => true, 2894 ) 2895 ); 1538 2896 1539 2897 $this->assertEquals( 2, $found ); … … 1544 2902 */ 1545 2903 public function test_count_with_meta_query() { 1546 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); 1547 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); 1548 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); 2904 $c1 = self::factory()->comment->create( 2905 array( 2906 'comment_post_ID' => self::$post_id, 2907 'user_id' => 7, 2908 ) 2909 ); 2910 $c2 = self::factory()->comment->create( 2911 array( 2912 'comment_post_ID' => self::$post_id, 2913 'user_id' => 7, 2914 ) 2915 ); 2916 $c3 = self::factory()->comment->create( 2917 array( 2918 'comment_post_ID' => self::$post_id, 2919 'user_id' => 7, 2920 ) 2921 ); 1549 2922 add_comment_meta( $c1, 'foo', 'bar' ); 1550 2923 add_comment_meta( $c3, 'foo', 'bar' ); 1551 2924 1552 $q = new WP_Comment_Query(); 1553 $found = $q->query( array( 1554 'count' => true, 1555 'meta_query' => array( 1556 array( 1557 'key' => 'foo', 1558 'value' => 'bar', 2925 $q = new WP_Comment_Query(); 2926 $found = $q->query( 2927 array( 2928 'count' => true, 2929 'meta_query' => array( 2930 array( 2931 'key' => 'foo', 2932 'value' => 'bar', 2933 ), 1559 2934 ), 1560 ) ,1561 ) );2935 ) 2936 ); 1562 2937 1563 2938 $this->assertEquals( 2, $found ); … … 1570 2945 $now = time(); 1571 2946 1572 $c1 = self::factory()->comment->create( array( 1573 'comment_post_ID' => self::$post_id, 1574 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ), 1575 ) ); 1576 $c2 = self::factory()->comment->create( array( 1577 'comment_post_ID' => self::$post_id, 1578 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ), 1579 ) ); 1580 $c3 = self::factory()->comment->create( array( 1581 'comment_post_ID' => self::$post_id, 1582 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ), 1583 ) ); 1584 $c4 = self::factory()->comment->create( array( 1585 'comment_post_ID' => self::$post_id, 1586 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ), 1587 ) ); 2947 $c1 = self::factory()->comment->create( 2948 array( 2949 'comment_post_ID' => self::$post_id, 2950 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ), 2951 ) 2952 ); 2953 $c2 = self::factory()->comment->create( 2954 array( 2955 'comment_post_ID' => self::$post_id, 2956 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ), 2957 ) 2958 ); 2959 $c3 = self::factory()->comment->create( 2960 array( 2961 'comment_post_ID' => self::$post_id, 2962 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ), 2963 ) 2964 ); 2965 $c4 = self::factory()->comment->create( 2966 array( 2967 'comment_post_ID' => self::$post_id, 2968 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ), 2969 ) 2970 ); 1588 2971 1589 2972 $query = new WP_Comment_Query(); 1590 $found = $query->query( array( 1591 'paged' => 2, 1592 'number' => 2, 1593 'orderby' => 'comment_date_gmt', 1594 'order' => 'DESC', 1595 'fields' => 'ids', 1596 ) ); 2973 $found = $query->query( 2974 array( 2975 'paged' => 2, 2976 'number' => 2, 2977 'orderby' => 'comment_date_gmt', 2978 'order' => 'DESC', 2979 'fields' => 'ids', 2980 ) 2981 ); 1597 2982 1598 2983 $expected = array( $c2, $c1 ); … … 1606 2991 $now = time(); 1607 2992 1608 $c1 = self::factory()->comment->create( array( 1609 'comment_post_ID' => self::$post_id, 1610 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ), 1611 ) ); 1612 $c2 = self::factory()->comment->create( array( 1613 'comment_post_ID' => self::$post_id, 1614 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ), 1615 ) ); 1616 $c3 = self::factory()->comment->create( array( 1617 'comment_post_ID' => self::$post_id, 1618 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ), 1619 ) ); 1620 $c4 = self::factory()->comment->create( array( 1621 'comment_post_ID' => self::$post_id, 1622 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ), 1623 ) ); 2993 $c1 = self::factory()->comment->create( 2994 array( 2995 'comment_post_ID' => self::$post_id, 2996 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ), 2997 ) 2998 ); 2999 $c2 = self::factory()->comment->create( 3000 array( 3001 'comment_post_ID' => self::$post_id, 3002 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ), 3003 ) 3004 ); 3005 $c3 = self::factory()->comment->create( 3006 array( 3007 'comment_post_ID' => self::$post_id, 3008 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ), 3009 ) 3010 ); 3011 $c4 = self::factory()->comment->create( 3012 array( 3013 'comment_post_ID' => self::$post_id, 3014 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ), 3015 ) 3016 ); 1624 3017 1625 3018 $query = new WP_Comment_Query(); 1626 $found = $query->query( array( 1627 'paged' => 2, 1628 'offset' => 1, 1629 'number' => 2, 1630 'orderby' => 'comment_date_gmt', 1631 'order' => 'DESC', 1632 'fields' => 'ids', 1633 ) ); 3019 $found = $query->query( 3020 array( 3021 'paged' => 2, 3022 'offset' => 1, 3023 'number' => 2, 3024 'orderby' => 'comment_date_gmt', 3025 'order' => 'DESC', 3026 'fields' => 'ids', 3027 ) 3028 ); 1634 3029 1635 3030 $expected = array( $c3, $c2 ); … … 1648 3043 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1649 3044 1650 $q = new WP_Comment_Query(); 1651 $found = $q->query( array( 1652 'fields' => 'ids', 1653 'post_type' => 'post-type-2', 1654 ) ); 3045 $q = new WP_Comment_Query(); 3046 $found = $q->query( 3047 array( 3048 'fields' => 'ids', 3049 'post_type' => 'post-type-2', 3050 ) 3051 ); 1655 3052 1656 3053 $this->assertEqualSets( $c2, $found ); … … 1673 3070 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1674 3071 1675 $q = new WP_Comment_Query(); 1676 $found = $q->query( array( 1677 'fields' => 'ids', 1678 'post_type' => array( 'post-type-2' ), 1679 ) ); 3072 $q = new WP_Comment_Query(); 3073 $found = $q->query( 3074 array( 3075 'fields' => 'ids', 3076 'post_type' => array( 'post-type-2' ), 3077 ) 3078 ); 1680 3079 1681 3080 $this->assertEqualSets( $c2, $found ); … … 1701 3100 $c3 = self::factory()->comment->create_post_comments( $p3, 1 ); 1702 3101 1703 $q = new WP_Comment_Query(); 1704 $found = $q->query( array( 1705 'fields' => 'ids', 1706 'post_type' => array( 'post-type-1', 'post-type-3' ), 1707 ) ); 3102 $q = new WP_Comment_Query(); 3103 $found = $q->query( 3104 array( 3105 'fields' => 'ids', 3106 'post_type' => array( 'post-type-1', 'post-type-3' ), 3107 ) 3108 ); 1708 3109 1709 3110 $this->assertEqualSets( array_merge( $c1, $c3 ), $found ); … … 1717 3118 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1718 3119 1719 $q = new WP_Comment_Query(); 1720 $found = $q->query( array( 1721 'fields' => 'ids', 1722 'post_name' => 'bar', 1723 ) ); 3120 $q = new WP_Comment_Query(); 3121 $found = $q->query( 3122 array( 3123 'fields' => 'ids', 3124 'post_name' => 'bar', 3125 ) 3126 ); 1724 3127 1725 3128 $this->assertEqualSets( $c2, $found ); … … 1736 3139 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1737 3140 1738 $q = new WP_Comment_Query(); 1739 $found = $q->query( array( 1740 'fields' => 'ids', 1741 'post_name' => array( 'bar' ), 1742 ) ); 3141 $q = new WP_Comment_Query(); 3142 $found = $q->query( 3143 array( 3144 'fields' => 'ids', 3145 'post_name' => array( 'bar' ), 3146 ) 3147 ); 1743 3148 1744 3149 $this->assertEqualSets( $c2, $found ); … … 1757 3162 $c3 = self::factory()->comment->create_post_comments( $p3, 1 ); 1758 3163 1759 $q = new WP_Comment_Query(); 1760 $found = $q->query( array( 1761 'fields' => 'ids', 1762 'post_name' => array( 'foo', 'baz' ), 1763 ) ); 3164 $q = new WP_Comment_Query(); 3165 $found = $q->query( 3166 array( 3167 'fields' => 'ids', 3168 'post_name' => array( 'foo', 'baz' ), 3169 ) 3170 ); 1764 3171 1765 3172 $this->assertEqualSets( array_merge( $c1, $c3 ), $found ); … … 1773 3180 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1774 3181 1775 $q = new WP_Comment_Query(); 1776 $found = $q->query( array( 1777 'fields' => 'ids', 1778 'post_status' => 'draft', 1779 ) ); 3182 $q = new WP_Comment_Query(); 3183 $found = $q->query( 3184 array( 3185 'fields' => 'ids', 3186 'post_status' => 'draft', 3187 ) 3188 ); 1780 3189 1781 3190 $this->assertEqualSets( $c2, $found ); … … 1792 3201 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1793 3202 1794 $q = new WP_Comment_Query(); 1795 $found = $q->query( array( 1796 'fields' => 'ids', 1797 'post_status' => array( 'draft' ), 1798 ) ); 3203 $q = new WP_Comment_Query(); 3204 $found = $q->query( 3205 array( 3206 'fields' => 'ids', 3207 'post_status' => array( 'draft' ), 3208 ) 3209 ); 1799 3210 1800 3211 $this->assertEqualSets( $c2, $found ); … … 1813 3224 $c3 = self::factory()->comment->create_post_comments( $p3, 1 ); 1814 3225 1815 $q = new WP_Comment_Query(); 1816 $found = $q->query( array( 1817 'fields' => 'ids', 1818 'post_status' => array( 'publish', 'future' ), 1819 ) ); 3226 $q = new WP_Comment_Query(); 3227 $found = $q->query( 3228 array( 3229 'fields' => 'ids', 3230 'post_status' => array( 'publish', 'future' ), 3231 ) 3232 ); 1820 3233 1821 3234 $this->assertEqualSets( array_merge( $c1, $c3 ), $found ); … … 1835 3248 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1836 3249 1837 $q = new WP_Comment_Query(); 1838 $found = $q->query( array( 1839 'fields' => 'ids', 1840 'post_type' => array( 'any', 'post-type-1' ), 1841 ) ); 3250 $q = new WP_Comment_Query(); 3251 $found = $q->query( 3252 array( 3253 'fields' => 'ids', 3254 'post_type' => array( 'any', 'post-type-1' ), 3255 ) 3256 ); 1842 3257 $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); 1843 3258 } … … 1856 3271 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1857 3272 1858 $q = new WP_Comment_Query(); 1859 $found = $q->query( array( 1860 'fields' => 'ids', 1861 'post_type' => array( 'any' ), 1862 ) ); 3273 $q = new WP_Comment_Query(); 3274 $found = $q->query( 3275 array( 3276 'fields' => 'ids', 3277 'post_type' => array( 'any' ), 3278 ) 3279 ); 1863 3280 $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); 1864 3281 } … … 1874 3291 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1875 3292 1876 $q = new WP_Comment_Query(); 1877 $found = $q->query( array( 1878 'fields' => 'ids', 1879 'post_status' => array( 'any', 'draft' ), 1880 ) ); 3293 $q = new WP_Comment_Query(); 3294 $found = $q->query( 3295 array( 3296 'fields' => 'ids', 3297 'post_status' => array( 'any', 'draft' ), 3298 ) 3299 ); 1881 3300 $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); 1882 3301 } … … 1892 3311 $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); 1893 3312 1894 $q = new WP_Comment_Query(); 1895 $found = $q->query( array( 1896 'fields' => 'ids', 1897 'post_status' => array( 'any' ), 1898 ) ); 3313 $q = new WP_Comment_Query(); 3314 $found = $q->query( 3315 array( 3316 'fields' => 'ids', 3317 'post_status' => array( 'any' ), 3318 ) 3319 ); 1899 3320 $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); 1900 3321 } … … 1930 3351 1931 3352 $q1 = new WP_Comment_Query(); 1932 $q1->query( array( 1933 'post_id' => $p, 1934 'fields' => 'ids', 1935 ) ); 3353 $q1->query( 3354 array( 3355 'post_id' => $p, 3356 'fields' => 'ids', 3357 ) 3358 ); 1936 3359 1937 3360 $num_queries = $wpdb->num_queries; 1938 3361 1939 3362 $q2 = new WP_Comment_Query(); 1940 $q2->query( array( 1941 'post_id' => $p, 1942 'fields' => 'ids', 1943 'foo' => 'bar', 1944 ) ); 3363 $q2->query( 3364 array( 3365 'post_id' => $p, 3366 'fields' => 'ids', 3367 'foo' => 'bar', 3368 ) 3369 ); 1945 3370 1946 3371 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 1953 3378 global $wpdb; 1954 3379 1955 $q1 = new WP_Comment_Query( array( 1956 'parent__in' => array( 1, 2, 3 ), 1957 ) ); 3380 $q1 = new WP_Comment_Query( 3381 array( 3382 'parent__in' => array( 1, 2, 3 ), 3383 ) 3384 ); 1958 3385 1959 3386 $num_queries = $wpdb->num_queries; 1960 3387 1961 $q2 = new WP_Comment_Query( array( 1962 'parent__in' => array( 4, 5, 6 ), 1963 ) ); 3388 $q2 = new WP_Comment_Query( 3389 array( 3390 'parent__in' => array( 4, 5, 6 ), 3391 ) 3392 ); 1964 3393 1965 3394 $this->assertNotEquals( $num_queries, $wpdb->num_queries ); … … 1972 3401 global $wpdb; 1973 3402 1974 $q1 = new WP_Comment_Query( array( 1975 'parent__not_in' => array( 1, 2, 3 ), 1976 ) ); 3403 $q1 = new WP_Comment_Query( 3404 array( 3405 'parent__not_in' => array( 1, 2, 3 ), 3406 ) 3407 ); 1977 3408 1978 3409 $num_queries = $wpdb->num_queries; 1979 3410 1980 $q2 = new WP_Comment_Query( array( 1981 'parent__not_in' => array( 4, 5, 6 ), 1982 ) ); 3411 $q2 = new WP_Comment_Query( 3412 array( 3413 'parent__not_in' => array( 4, 5, 6 ), 3414 ) 3415 ); 1983 3416 1984 3417 $this->assertNotEquals( $num_queries, $wpdb->num_queries ); … … 1989 3422 */ 1990 3423 public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() { 1991 $comments = self::factory()->comment->create_many( 2, array( 1992 'comment_post_ID' => self::$post_id, 1993 ) ); 3424 $comments = self::factory()->comment->create_many( 3425 2, array( 3426 'comment_post_ID' => self::$post_id, 3427 ) 3428 ); 1994 3429 1995 3430 add_comment_meta( $comments[1], 'foo', 'bar' ); … … 1997 3432 add_action( 'pre_get_comments', array( $this, 'modify_meta_query' ) ); 1998 3433 1999 $q = new WP_Comment_Query( array( 2000 'comment_post_ID' => self::$post_id, 2001 'fields' => 'ids', 2002 ) ); 3434 $q = new WP_Comment_Query( 3435 array( 3436 'comment_post_ID' => self::$post_id, 3437 'fields' => 'ids', 3438 ) 3439 ); 2003 3440 2004 3441 remove_action( 'pre_get_comments', array( $this, 'modify_meta_query' ) ); … … 2008 3445 2009 3446 public function modify_meta_query( $q ) { 2010 $q->meta_query = new WP_Meta_Query( array( 2011 array( 2012 'key' => 'foo', 2013 'value' => 'bar', 2014 ), 2015 ) ); 3447 $q->meta_query = new WP_Meta_Query( 3448 array( 3449 array( 3450 'key' => 'foo', 3451 'value' => 'bar', 3452 ), 3453 ) 3454 ); 2016 3455 } 2017 3456 … … 2020 3459 */ 2021 3460 public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() { 2022 $comments = self::factory()->comment->create_many( 2, array( 2023 'comment_post_ID' => self::$post_id, 2024 ) ); 3461 $comments = self::factory()->comment->create_many( 3462 2, array( 3463 'comment_post_ID' => self::$post_id, 3464 ) 3465 ); 2025 3466 2026 3467 add_comment_meta( $comments[1], 'foo', 'bar' ); … … 2028 3469 add_action( 'pre_get_comments', array( $this, 'modify_meta_params' ) ); 2029 3470 2030 $q = new WP_Comment_Query( array( 2031 'comment_post_ID' => self::$post_id, 2032 'fields' => 'ids', 2033 ) ); 3471 $q = new WP_Comment_Query( 3472 array( 3473 'comment_post_ID' => self::$post_id, 3474 'fields' => 'ids', 3475 ) 3476 ); 2034 3477 2035 3478 remove_action( 'pre_get_comments', array( $this, 'modify_meta_params' ) ); … … 2039 3482 2040 3483 public function modify_meta_params( $q ) { 2041 $q->query_vars['meta_key'] = 'foo';3484 $q->query_vars['meta_key'] = 'foo'; 2042 3485 $q->query_vars['meta_value'] = 'bar'; 2043 3486 } … … 2047 3490 */ 2048 3491 public function test_parent__in() { 2049 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2050 $c2 = self::factory()->comment->create( array( 2051 'comment_post_ID' => self::$post_id, 2052 'comment_approved' => '1', 2053 'comment_parent' => $c1, 2054 ) ); 2055 2056 $ids = new WP_Comment_Query( array( 2057 'comment_post_ID' => self::$post_id, 2058 'fields' => 'ids', 2059 'parent__in' => array( $c1 ) 2060 ) ); 3492 $c1 = self::factory()->comment->create( 3493 array( 3494 'comment_post_ID' => self::$post_id, 3495 'comment_approved' => '1', 3496 ) 3497 ); 3498 $c2 = self::factory()->comment->create( 3499 array( 3500 'comment_post_ID' => self::$post_id, 3501 'comment_approved' => '1', 3502 'comment_parent' => $c1, 3503 ) 3504 ); 3505 3506 $ids = new WP_Comment_Query( 3507 array( 3508 'comment_post_ID' => self::$post_id, 3509 'fields' => 'ids', 3510 'parent__in' => array( $c1 ), 3511 ) 3512 ); 2061 3513 2062 3514 $this->assertEqualSets( array( $c2 ), $ids->comments ); … … 2067 3519 */ 2068 3520 public function test_parent__in_commas() { 2069 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2070 $c2 = self::factory()->comment->create( array( 2071 'comment_post_ID' => self::$post_id, 2072 'comment_approved' => '1' 2073 ) ); 2074 $c3 = self::factory()->comment->create( array( 2075 'comment_post_ID' => self::$post_id, 2076 'comment_approved' => '1', 2077 'comment_parent' => $c1, 2078 ) ); 2079 $c4 = self::factory()->comment->create( array( 2080 'comment_post_ID' => self::$post_id, 2081 'comment_approved' => '1', 2082 'comment_parent' => $c2, 2083 ) ); 2084 2085 $ids = new WP_Comment_Query( array( 2086 'comment_post_ID' => self::$post_id, 2087 'fields' => 'ids', 2088 'parent__in' => "$c1,$c2" 2089 ) ); 3521 $c1 = self::factory()->comment->create( 3522 array( 3523 'comment_post_ID' => self::$post_id, 3524 'comment_approved' => '1', 3525 ) 3526 ); 3527 $c2 = self::factory()->comment->create( 3528 array( 3529 'comment_post_ID' => self::$post_id, 3530 'comment_approved' => '1', 3531 ) 3532 ); 3533 $c3 = self::factory()->comment->create( 3534 array( 3535 'comment_post_ID' => self::$post_id, 3536 'comment_approved' => '1', 3537 'comment_parent' => $c1, 3538 ) 3539 ); 3540 $c4 = self::factory()->comment->create( 3541 array( 3542 'comment_post_ID' => self::$post_id, 3543 'comment_approved' => '1', 3544 'comment_parent' => $c2, 3545 ) 3546 ); 3547 3548 $ids = new WP_Comment_Query( 3549 array( 3550 'comment_post_ID' => self::$post_id, 3551 'fields' => 'ids', 3552 'parent__in' => "$c1,$c2", 3553 ) 3554 ); 2090 3555 2091 3556 $this->assertEqualSets( array( $c3, $c4 ), $ids->comments ); … … 2096 3561 */ 2097 3562 public function test_parent__not_in() { 2098 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2099 2100 self::factory()->comment->create( array( 2101 'comment_post_ID' => self::$post_id, 2102 'comment_approved' => '1', 2103 'comment_parent' => $c1, 2104 ) ); 2105 2106 $ids = new WP_Comment_Query( array( 2107 'comment_post_ID' => self::$post_id, 2108 'fields' => 'ids', 2109 'parent__not_in' => array( $c1 ) 2110 ) ); 3563 $c1 = self::factory()->comment->create( 3564 array( 3565 'comment_post_ID' => self::$post_id, 3566 'comment_approved' => '1', 3567 ) 3568 ); 3569 3570 self::factory()->comment->create( 3571 array( 3572 'comment_post_ID' => self::$post_id, 3573 'comment_approved' => '1', 3574 'comment_parent' => $c1, 3575 ) 3576 ); 3577 3578 $ids = new WP_Comment_Query( 3579 array( 3580 'comment_post_ID' => self::$post_id, 3581 'fields' => 'ids', 3582 'parent__not_in' => array( $c1 ), 3583 ) 3584 ); 2111 3585 2112 3586 $this->assertEqualSets( array( $c1 ), $ids->comments ); … … 2117 3591 */ 2118 3592 public function test_parent__not_in_commas() { 2119 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2120 $c2 = self::factory()->comment->create( array( 2121 'comment_post_ID' => self::$post_id, 2122 'comment_approved' => '1' 2123 ) ); 2124 2125 self::factory()->comment->create( array( 2126 'comment_post_ID' => self::$post_id, 2127 'comment_approved' => '1', 2128 'comment_parent' => $c1, 2129 ) ); 2130 self::factory()->comment->create( array( 2131 'comment_post_ID' => self::$post_id, 2132 'comment_approved' => '1', 2133 'comment_parent' => $c2, 2134 ) ); 2135 2136 $ids = new WP_Comment_Query( array( 2137 'comment_post_ID' => self::$post_id, 2138 'fields' => 'ids', 2139 'parent__not_in' => "$c1,$c2" 2140 ) ); 3593 $c1 = self::factory()->comment->create( 3594 array( 3595 'comment_post_ID' => self::$post_id, 3596 'comment_approved' => '1', 3597 ) 3598 ); 3599 $c2 = self::factory()->comment->create( 3600 array( 3601 'comment_post_ID' => self::$post_id, 3602 'comment_approved' => '1', 3603 ) 3604 ); 3605 3606 self::factory()->comment->create( 3607 array( 3608 'comment_post_ID' => self::$post_id, 3609 'comment_approved' => '1', 3610 'comment_parent' => $c1, 3611 ) 3612 ); 3613 self::factory()->comment->create( 3614 array( 3615 'comment_post_ID' => self::$post_id, 3616 'comment_approved' => '1', 3617 'comment_parent' => $c2, 3618 ) 3619 ); 3620 3621 $ids = new WP_Comment_Query( 3622 array( 3623 'comment_post_ID' => self::$post_id, 3624 'fields' => 'ids', 3625 'parent__not_in' => "$c1,$c2", 3626 ) 3627 ); 2141 3628 2142 3629 $this->assertEqualSets( array( $c1, $c2 ), $ids->comments ); … … 2147 3634 */ 2148 3635 public function test_orderby_comment__in() { 2149 self::factory()->comment->create( array( 2150 'comment_post_ID' => self::$post_id, 2151 'comment_approved' => '1' 2152 ) ); 2153 2154 $c2 = self::factory()->comment->create( array( 2155 'comment_post_ID' => self::$post_id, 2156 'comment_approved' => '1' 2157 ) ); 2158 $c3 = self::factory()->comment->create( array( 2159 'comment_post_ID' => self::$post_id, 2160 'comment_approved' => '1' 2161 ) ); 2162 2163 self::factory()->comment->create( array( 2164 'comment_post_ID' => self::$post_id, 2165 'comment_approved' => '1' 2166 ) ); 2167 2168 2169 $ids = new WP_Comment_Query( array( 2170 'fields' => 'ids', 2171 'comment__in' => array( $c2, $c3 ), 2172 'orderby' => 'comment__in' 2173 ) ); 3636 self::factory()->comment->create( 3637 array( 3638 'comment_post_ID' => self::$post_id, 3639 'comment_approved' => '1', 3640 ) 3641 ); 3642 3643 $c2 = self::factory()->comment->create( 3644 array( 3645 'comment_post_ID' => self::$post_id, 3646 'comment_approved' => '1', 3647 ) 3648 ); 3649 $c3 = self::factory()->comment->create( 3650 array( 3651 'comment_post_ID' => self::$post_id, 3652 'comment_approved' => '1', 3653 ) 3654 ); 3655 3656 self::factory()->comment->create( 3657 array( 3658 'comment_post_ID' => self::$post_id, 3659 'comment_approved' => '1', 3660 ) 3661 ); 3662 3663 $ids = new WP_Comment_Query( 3664 array( 3665 'fields' => 'ids', 3666 'comment__in' => array( $c2, $c3 ), 3667 'orderby' => 'comment__in', 3668 ) 3669 ); 2174 3670 2175 3671 $this->assertEquals( array( $c2, $c3 ), $ids->comments ); … … 2183 3679 $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); 2184 3680 2185 $q = new WP_Comment_Query( array( 2186 'post_id' => self::$post_id, 2187 'number' => 2, 2188 ) ); 3681 $q = new WP_Comment_Query( 3682 array( 3683 'post_id' => self::$post_id, 3684 'number' => 2, 3685 ) 3686 ); 2189 3687 2190 3688 $this->assertEquals( 0, $q->found_comments ); … … 2198 3696 $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); 2199 3697 2200 $q = new WP_Comment_Query( array( 2201 'post_id' => self::$post_id, 2202 'number' => 2, 2203 'no_found_rows' => true, 2204 ) ); 3698 $q = new WP_Comment_Query( 3699 array( 3700 'post_id' => self::$post_id, 3701 'number' => 2, 3702 'no_found_rows' => true, 3703 ) 3704 ); 2205 3705 2206 3706 $this->assertEquals( 0, $q->found_comments ); … … 2214 3714 $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); 2215 3715 2216 $q = new WP_Comment_Query( array( 2217 'post_id' => self::$post_id, 2218 'number' => 2, 2219 'no_found_rows' => false, 2220 ) ); 3716 $q = new WP_Comment_Query( 3717 array( 3718 'post_id' => self::$post_id, 3719 'number' => 2, 3720 'no_found_rows' => false, 3721 ) 3722 ); 2221 3723 2222 3724 $this->assertEquals( 3, $q->found_comments ); … … 2231 3733 2232 3734 // Prime cache. 2233 new WP_Comment_Query( array( 2234 'post_id' => self::$post_id, 2235 'number' => 2, 2236 'no_found_rows' => false, 2237 ) ); 2238 2239 $q = new WP_Comment_Query( array( 2240 'post_id' => self::$post_id, 2241 'number' => 2, 2242 'no_found_rows' => false, 2243 ) ); 3735 new WP_Comment_Query( 3736 array( 3737 'post_id' => self::$post_id, 3738 'number' => 2, 3739 'no_found_rows' => false, 3740 ) 3741 ); 3742 3743 $q = new WP_Comment_Query( 3744 array( 3745 'post_id' => self::$post_id, 3746 'number' => 2, 3747 'no_found_rows' => false, 3748 ) 3749 ); 2244 3750 2245 3751 $this->assertEquals( 3, $q->found_comments ); … … 2251 3757 */ 2252 3758 public function test_hierarchical_should_skip_child_comments_in_offset() { 2253 $top_level_0 = self::factory()->comment->create( array( 2254 'comment_post_ID' => self::$post_id, 2255 'comment_approved' => '1', 2256 ) ); 2257 2258 $child_of_0 = self::factory()->comment->create( array( 2259 'comment_post_ID' => self::$post_id, 2260 'comment_approved' => '1', 2261 'comment_parent' => $top_level_0, 2262 ) ); 2263 2264 $top_level_comments = self::factory()->comment->create_many( 3, array( 2265 'comment_post_ID' => self::$post_id, 2266 'comment_approved' => '1', 2267 ) ); 2268 2269 $q = new WP_Comment_Query( array( 2270 'post_id' => self::$post_id, 2271 'hierarchical' => 'flat', 2272 'number' => 2, 2273 'offset' => 1, 2274 'orderby' => 'comment_ID', 2275 'order' => 'ASC', 2276 'fields' => 'ids', 2277 ) ); 3759 $top_level_0 = self::factory()->comment->create( 3760 array( 3761 'comment_post_ID' => self::$post_id, 3762 'comment_approved' => '1', 3763 ) 3764 ); 3765 3766 $child_of_0 = self::factory()->comment->create( 3767 array( 3768 'comment_post_ID' => self::$post_id, 3769 'comment_approved' => '1', 3770 'comment_parent' => $top_level_0, 3771 ) 3772 ); 3773 3774 $top_level_comments = self::factory()->comment->create_many( 3775 3, array( 3776 'comment_post_ID' => self::$post_id, 3777 'comment_approved' => '1', 3778 ) 3779 ); 3780 3781 $q = new WP_Comment_Query( 3782 array( 3783 'post_id' => self::$post_id, 3784 'hierarchical' => 'flat', 3785 'number' => 2, 3786 'offset' => 1, 3787 'orderby' => 'comment_ID', 3788 'order' => 'ASC', 3789 'fields' => 'ids', 3790 ) 3791 ); 2278 3792 2279 3793 $this->assertEquals( array( $top_level_comments[0], $top_level_comments[1] ), $q->comments ); … … 2284 3798 */ 2285 3799 public function test_hierarchical_should_not_include_child_comments_in_number() { 2286 $top_level_0 = self::factory()->comment->create( array( 2287 'comment_post_ID' => self::$post_id, 2288 'comment_approved' => '1', 2289 ) ); 2290 2291 $child_of_0 = self::factory()->comment->create( array( 2292 'comment_post_ID' => self::$post_id, 2293 'comment_approved' => '1', 2294 'comment_parent' => $top_level_0, 2295 ) ); 2296 2297 $top_level_comments = self::factory()->comment->create_many( 3, array( 2298 'comment_post_ID' => self::$post_id, 2299 'comment_approved' => '1', 2300 ) ); 2301 2302 $q = new WP_Comment_Query( array( 2303 'post_id' => self::$post_id, 2304 'hierarchical' => 'flat', 2305 'number' => 2, 2306 'orderby' => 'comment_ID', 2307 'order' => 'ASC', 2308 ) ); 3800 $top_level_0 = self::factory()->comment->create( 3801 array( 3802 'comment_post_ID' => self::$post_id, 3803 'comment_approved' => '1', 3804 ) 3805 ); 3806 3807 $child_of_0 = self::factory()->comment->create( 3808 array( 3809 'comment_post_ID' => self::$post_id, 3810 'comment_approved' => '1', 3811 'comment_parent' => $top_level_0, 3812 ) 3813 ); 3814 3815 $top_level_comments = self::factory()->comment->create_many( 3816 3, array( 3817 'comment_post_ID' => self::$post_id, 3818 'comment_approved' => '1', 3819 ) 3820 ); 3821 3822 $q = new WP_Comment_Query( 3823 array( 3824 'post_id' => self::$post_id, 3825 'hierarchical' => 'flat', 3826 'number' => 2, 3827 'orderby' => 'comment_ID', 3828 'order' => 'ASC', 3829 ) 3830 ); 2309 3831 2310 3832 $this->assertEqualSets( array( $top_level_0, $child_of_0, $top_level_comments[0] ), wp_list_pluck( $q->comments, 'comment_ID' ) ); … … 2315 3837 */ 2316 3838 public function test_hierarchical_threaded() { 2317 $c1 = self::factory()->comment->create( array( 2318 'comment_post_ID' => self::$post_id, 2319 'comment_approved' => '1', 2320 ) ); 2321 2322 $c2 = self::factory()->comment->create( array( 2323 'comment_post_ID' => self::$post_id, 2324 'comment_approved' => '1', 2325 'comment_parent' => $c1, 2326 ) ); 2327 2328 $c3 = self::factory()->comment->create( array( 2329 'comment_post_ID' => self::$post_id, 2330 'comment_approved' => '1', 2331 'comment_parent' => $c2, 2332 ) ); 2333 2334 $c4 = self::factory()->comment->create( array( 2335 'comment_post_ID' => self::$post_id, 2336 'comment_approved' => '1', 2337 'comment_parent' => $c1, 2338 ) ); 2339 2340 $c5 = self::factory()->comment->create( array( 2341 'comment_post_ID' => self::$post_id, 2342 'comment_approved' => '1', 2343 ) ); 2344 2345 $c6 = self::factory()->comment->create( array( 2346 'comment_post_ID' => self::$post_id, 2347 'comment_approved' => '1', 2348 'comment_parent' => $c5, 2349 ) ); 3839 $c1 = self::factory()->comment->create( 3840 array( 3841 'comment_post_ID' => self::$post_id, 3842 'comment_approved' => '1', 3843 ) 3844 ); 3845 3846 $c2 = self::factory()->comment->create( 3847 array( 3848 'comment_post_ID' => self::$post_id, 3849 'comment_approved' => '1', 3850 'comment_parent' => $c1, 3851 ) 3852 ); 3853 3854 $c3 = self::factory()->comment->create( 3855 array( 3856 'comment_post_ID' => self::$post_id, 3857 'comment_approved' => '1', 3858 'comment_parent' => $c2, 3859 ) 3860 ); 3861 3862 $c4 = self::factory()->comment->create( 3863 array( 3864 'comment_post_ID' => self::$post_id, 3865 'comment_approved' => '1', 3866 'comment_parent' => $c1, 3867 ) 3868 ); 3869 3870 $c5 = self::factory()->comment->create( 3871 array( 3872 'comment_post_ID' => self::$post_id, 3873 'comment_approved' => '1', 3874 ) 3875 ); 3876 3877 $c6 = self::factory()->comment->create( 3878 array( 3879 'comment_post_ID' => self::$post_id, 3880 'comment_approved' => '1', 3881 'comment_parent' => $c5, 3882 ) 3883 ); 2350 3884 2351 3885 $args = array( 2352 3886 'hierarchical' => 'threaded', 2353 'orderby' => 'comment_ID', 2354 'order' => 'ASC', 2355 ); 2356 2357 $query_args = array_merge( $args, array( 2358 'post_id' => self::$post_id, 2359 ) ); 3887 'orderby' => 'comment_ID', 3888 'order' => 'ASC', 3889 ); 3890 3891 $query_args = array_merge( 3892 $args, array( 3893 'post_id' => self::$post_id, 3894 ) 3895 ); 2360 3896 2361 3897 $q = new WP_Comment_Query( $query_args ); … … 2378 3914 */ 2379 3915 public function test_hierarchical_threaded_approved() { 2380 $c1 = self::factory()->comment->create( array( 2381 'comment_post_ID' => self::$post_id, 2382 'comment_approved' => '1', 2383 ) ); 2384 2385 $c2 = self::factory()->comment->create( array( 2386 'comment_post_ID' => self::$post_id, 2387 'comment_approved' => '1', 2388 'comment_parent' => $c1, 2389 ) ); 2390 2391 $c3 = self::factory()->comment->create( array( 2392 'comment_post_ID' => self::$post_id, 2393 'comment_approved' => '0', 2394 'comment_parent' => $c2, 2395 ) ); 2396 2397 $c4 = self::factory()->comment->create( array( 2398 'comment_post_ID' => self::$post_id, 2399 'comment_approved' => '1', 2400 'comment_parent' => $c1, 2401 ) ); 2402 2403 $c5 = self::factory()->comment->create( array( 2404 'comment_post_ID' => self::$post_id, 2405 'comment_approved' => '1', 2406 ) ); 2407 2408 self::factory()->comment->create( array( 2409 'comment_post_ID' => self::$post_id, 2410 'comment_approved' => '1', 2411 'comment_parent' => $c5, 2412 ) ); 3916 $c1 = self::factory()->comment->create( 3917 array( 3918 'comment_post_ID' => self::$post_id, 3919 'comment_approved' => '1', 3920 ) 3921 ); 3922 3923 $c2 = self::factory()->comment->create( 3924 array( 3925 'comment_post_ID' => self::$post_id, 3926 'comment_approved' => '1', 3927 'comment_parent' => $c1, 3928 ) 3929 ); 3930 3931 $c3 = self::factory()->comment->create( 3932 array( 3933 'comment_post_ID' => self::$post_id, 3934 'comment_approved' => '0', 3935 'comment_parent' => $c2, 3936 ) 3937 ); 3938 3939 $c4 = self::factory()->comment->create( 3940 array( 3941 'comment_post_ID' => self::$post_id, 3942 'comment_approved' => '1', 3943 'comment_parent' => $c1, 3944 ) 3945 ); 3946 3947 $c5 = self::factory()->comment->create( 3948 array( 3949 'comment_post_ID' => self::$post_id, 3950 'comment_approved' => '1', 3951 ) 3952 ); 3953 3954 self::factory()->comment->create( 3955 array( 3956 'comment_post_ID' => self::$post_id, 3957 'comment_approved' => '1', 3958 'comment_parent' => $c5, 3959 ) 3960 ); 2413 3961 2414 3962 $args = array( 2415 3963 'hierarchical' => 'threaded', 2416 'status' => 'approve', 2417 'orderby' => 'comment_ID', 2418 'order' => 'ASC', 2419 ); 2420 2421 $query_args = array_merge( $args, array( 2422 'post_id' => self::$post_id, 2423 ) ); 3964 'status' => 'approve', 3965 'orderby' => 'comment_ID', 3966 'order' => 'ASC', 3967 ); 3968 3969 $query_args = array_merge( 3970 $args, array( 3971 'post_id' => self::$post_id, 3972 ) 3973 ); 2424 3974 2425 3975 $q = new WP_Comment_Query( $query_args ); … … 2439 3989 */ 2440 3990 public function test_comment_clauses_prepend_callback_should_be_respected_when_filling_descendants() { 2441 $top_level_0 = self::factory()->comment->create( array( 2442 'comment_post_ID' => self::$post_id, 2443 'comment_approved' => '1', 2444 ) ); 2445 2446 $child1_of_0 = self::factory()->comment->create( array( 2447 'comment_post_ID' => self::$post_id, 2448 'comment_approved' => '1', 2449 'comment_parent' => $top_level_0, 2450 ) ); 2451 2452 $child2_of_0 = self::factory()->comment->create( array( 2453 'comment_post_ID' => self::$post_id, 2454 'comment_approved' => '1', 2455 'comment_parent' => $top_level_0, 2456 ) ); 2457 2458 $top_level_comments = self::factory()->comment->create_many( 3, array( 2459 'comment_post_ID' => self::$post_id, 2460 'comment_approved' => '1', 2461 ) ); 3991 $top_level_0 = self::factory()->comment->create( 3992 array( 3993 'comment_post_ID' => self::$post_id, 3994 'comment_approved' => '1', 3995 ) 3996 ); 3997 3998 $child1_of_0 = self::factory()->comment->create( 3999 array( 4000 'comment_post_ID' => self::$post_id, 4001 'comment_approved' => '1', 4002 'comment_parent' => $top_level_0, 4003 ) 4004 ); 4005 4006 $child2_of_0 = self::factory()->comment->create( 4007 array( 4008 'comment_post_ID' => self::$post_id, 4009 'comment_approved' => '1', 4010 'comment_parent' => $top_level_0, 4011 ) 4012 ); 4013 4014 $top_level_comments = self::factory()->comment->create_many( 4015 3, array( 4016 'comment_post_ID' => self::$post_id, 4017 'comment_approved' => '1', 4018 ) 4019 ); 2462 4020 2463 4021 $this->to_exclude = array( $child2_of_0, $top_level_comments[1] ); 2464 4022 2465 4023 add_filter( 'comments_clauses', array( $this, 'prepend_exclusions' ) ); 2466 $q = new WP_Comment_Query( array( 2467 'post_id' => self::$post_id, 2468 'hierarchical' => 'flat', 2469 ) ); 4024 $q = new WP_Comment_Query( 4025 array( 4026 'post_id' => self::$post_id, 4027 'hierarchical' => 'flat', 4028 ) 4029 ); 2470 4030 remove_filter( 'comments_clauses', array( $this, 'prepend_exclusions' ) ); 2471 4031 … … 2485 4045 */ 2486 4046 public function test_comment_clauses_append_callback_should_be_respected_when_filling_descendants() { 2487 $top_level_0 = self::factory()->comment->create( array( 2488 'comment_post_ID' => self::$post_id, 2489 'comment_approved' => '1', 2490 ) ); 2491 2492 $child1_of_0 = self::factory()->comment->create( array( 2493 'comment_post_ID' => self::$post_id, 2494 'comment_approved' => '1', 2495 'comment_parent' => $top_level_0, 2496 ) ); 2497 2498 $child2_of_0 = self::factory()->comment->create( array( 2499 'comment_post_ID' => self::$post_id, 2500 'comment_approved' => '1', 2501 'comment_parent' => $top_level_0, 2502 ) ); 2503 2504 $top_level_comments = self::factory()->comment->create_many( 3, array( 2505 'comment_post_ID' => self::$post_id, 2506 'comment_approved' => '1', 2507 ) ); 4047 $top_level_0 = self::factory()->comment->create( 4048 array( 4049 'comment_post_ID' => self::$post_id, 4050 'comment_approved' => '1', 4051 ) 4052 ); 4053 4054 $child1_of_0 = self::factory()->comment->create( 4055 array( 4056 'comment_post_ID' => self::$post_id, 4057 'comment_approved' => '1', 4058 'comment_parent' => $top_level_0, 4059 ) 4060 ); 4061 4062 $child2_of_0 = self::factory()->comment->create( 4063 array( 4064 'comment_post_ID' => self::$post_id, 4065 'comment_approved' => '1', 4066 'comment_parent' => $top_level_0, 4067 ) 4068 ); 4069 4070 $top_level_comments = self::factory()->comment->create_many( 4071 3, array( 4072 'comment_post_ID' => self::$post_id, 4073 'comment_approved' => '1', 4074 ) 4075 ); 2508 4076 2509 4077 $this->to_exclude = array( $child2_of_0, $top_level_comments[1] ); 2510 4078 2511 4079 add_filter( 'comments_clauses', array( $this, 'append_exclusions' ) ); 2512 $q = new WP_Comment_Query( array( 2513 'post_id' => self::$post_id, 2514 'hierarchical' => 'flat', 2515 ) ); 4080 $q = new WP_Comment_Query( 4081 array( 4082 'post_id' => self::$post_id, 4083 'hierarchical' => 'flat', 4084 ) 4085 ); 2516 4086 remove_filter( 'comments_clauses', array( $this, 'append_exclusions' ) ); 2517 4087 … … 2533 4103 global $wpdb; 2534 4104 2535 $p = self::factory()->post->create(); 2536 $comment_1 = self::factory()->comment->create( array( 2537 'comment_post_ID' => $p, 2538 'comment_approved' => '1', 2539 ) ); 2540 $comment_2 = self::factory()->comment->create( array( 2541 'comment_post_ID' => $p, 2542 'comment_approved' => '1', 2543 'comment_parent' => $comment_1, 2544 ) ); 2545 $comment_3 = self::factory()->comment->create( array( 2546 'comment_post_ID' => $p, 2547 'comment_approved' => '1', 2548 'comment_parent' => $comment_1, 2549 ) ); 2550 $comment_4 = self::factory()->comment->create( array( 2551 'comment_post_ID' => $p, 2552 'comment_approved' => '1', 2553 'comment_parent' => $comment_2, 2554 ) ); 2555 2556 $q1 = new WP_Comment_Query( array( 2557 'post_id' => $p, 2558 'hierarchical' => true, 2559 ) ); 4105 $p = self::factory()->post->create(); 4106 $comment_1 = self::factory()->comment->create( 4107 array( 4108 'comment_post_ID' => $p, 4109 'comment_approved' => '1', 4110 ) 4111 ); 4112 $comment_2 = self::factory()->comment->create( 4113 array( 4114 'comment_post_ID' => $p, 4115 'comment_approved' => '1', 4116 'comment_parent' => $comment_1, 4117 ) 4118 ); 4119 $comment_3 = self::factory()->comment->create( 4120 array( 4121 'comment_post_ID' => $p, 4122 'comment_approved' => '1', 4123 'comment_parent' => $comment_1, 4124 ) 4125 ); 4126 $comment_4 = self::factory()->comment->create( 4127 array( 4128 'comment_post_ID' => $p, 4129 'comment_approved' => '1', 4130 'comment_parent' => $comment_2, 4131 ) 4132 ); 4133 4134 $q1 = new WP_Comment_Query( 4135 array( 4136 'post_id' => $p, 4137 'hierarchical' => true, 4138 ) 4139 ); 2560 4140 $q1_ids = wp_list_pluck( $q1->comments, 'comment_ID' ); 2561 4141 2562 4142 $num_queries = $wpdb->num_queries; 2563 $q2 = new WP_Comment_Query( array( 2564 'post_id' => $p, 2565 'hierarchical' => true, 2566 ) ); 2567 $q2_ids = wp_list_pluck( $q2->comments, 'comment_ID' ); 4143 $q2 = new WP_Comment_Query( 4144 array( 4145 'post_id' => $p, 4146 'hierarchical' => true, 4147 ) 4148 ); 4149 $q2_ids = wp_list_pluck( $q2->comments, 'comment_ID' ); 2568 4150 2569 4151 $this->assertEqualSets( $q1_ids, $q2_ids ); … … 2577 4159 global $wpdb; 2578 4160 2579 $p = self::factory()->post->create(); 2580 $comment_1 = self::factory()->comment->create( array( 2581 'comment_post_ID' => $p, 2582 'comment_approved' => '1', 2583 ) ); 2584 $comment_2 = self::factory()->comment->create( array( 2585 'comment_post_ID' => $p, 2586 'comment_approved' => '1', 2587 'comment_parent' => $comment_1, 2588 ) ); 2589 $comment_3 = self::factory()->comment->create( array( 2590 'comment_post_ID' => $p, 2591 'comment_approved' => '1', 2592 'comment_parent' => $comment_1, 2593 ) ); 2594 $comment_4 = self::factory()->comment->create( array( 2595 'comment_post_ID' => $p, 2596 'comment_approved' => '1', 2597 'comment_parent' => $comment_2, 2598 ) ); 4161 $p = self::factory()->post->create(); 4162 $comment_1 = self::factory()->comment->create( 4163 array( 4164 'comment_post_ID' => $p, 4165 'comment_approved' => '1', 4166 ) 4167 ); 4168 $comment_2 = self::factory()->comment->create( 4169 array( 4170 'comment_post_ID' => $p, 4171 'comment_approved' => '1', 4172 'comment_parent' => $comment_1, 4173 ) 4174 ); 4175 $comment_3 = self::factory()->comment->create( 4176 array( 4177 'comment_post_ID' => $p, 4178 'comment_approved' => '1', 4179 'comment_parent' => $comment_1, 4180 ) 4181 ); 4182 $comment_4 = self::factory()->comment->create( 4183 array( 4184 'comment_post_ID' => $p, 4185 'comment_approved' => '1', 4186 'comment_parent' => $comment_2, 4187 ) 4188 ); 2599 4189 2600 4190 // Prime cache. 2601 $q1 = new WP_Comment_Query( array( 2602 'post_id' => $p, 2603 'hierarchical' => true, 2604 ) ); 4191 $q1 = new WP_Comment_Query( 4192 array( 4193 'post_id' => $p, 4194 'hierarchical' => true, 4195 ) 4196 ); 2605 4197 $q1_ids = wp_list_pluck( $q1->comments, 'comment_ID' ); 2606 4198 $this->assertEqualSets( array( $comment_1, $comment_2, $comment_3, $comment_4 ), $q1_ids ); … … 2608 4200 // Delete one of the parent caches. 2609 4201 $last_changed = wp_cache_get( 'last_changed', 'comment' ); 2610 $key = md5( serialize( wp_array_slice_assoc( $q1->query_vars, array_keys( $q1->query_var_defaults ) ) ) );2611 $cache_key = "get_comment_child_ids:$comment_2:$key:$last_changed";4202 $key = md5( serialize( wp_array_slice_assoc( $q1->query_vars, array_keys( $q1->query_var_defaults ) ) ) ); 4203 $cache_key = "get_comment_child_ids:$comment_2:$key:$last_changed"; 2612 4204 wp_cache_delete( $cache_key, 'comment' ); 2613 4205 2614 $q2 = new WP_Comment_Query( array( 2615 'post_id' => $p, 2616 'hierarchical' => true, 2617 ) ); 4206 $q2 = new WP_Comment_Query( 4207 array( 4208 'post_id' => $p, 4209 'hierarchical' => true, 4210 ) 4211 ); 2618 4212 $q2_ids = wp_list_pluck( $q2->comments, 'comment_ID' ); 2619 4213 $this->assertEqualSets( $q1_ids, $q2_ids ); … … 2625 4219 */ 2626 4220 public function test_fill_hierarchy_should_disregard_offset_and_number() { 2627 $c0 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2628 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2629 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1 ) ); 2630 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 2631 $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c3 ) ); 2632 $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c3 ) ); 2633 2634 $q = new WP_Comment_Query(); 2635 $found = $q->query( array( 2636 'orderby' => 'comment_date_gmt', 2637 'order' => 'ASC', 2638 'status' => 'approve', 2639 'post_id' => self::$post_id, 2640 'no_found_rows' => false, 2641 'hierarchical' => 'threaded', 2642 'number' => 2, 2643 'offset' => 1, 2644 ) ); 2645 2646 2647 $found_1 = $found[ $c1 ]; 4221 $c0 = self::factory()->comment->create( 4222 array( 4223 'comment_post_ID' => self::$post_id, 4224 'comment_approved' => '1', 4225 ) 4226 ); 4227 $c1 = self::factory()->comment->create( 4228 array( 4229 'comment_post_ID' => self::$post_id, 4230 'comment_approved' => '1', 4231 ) 4232 ); 4233 $c2 = self::factory()->comment->create( 4234 array( 4235 'comment_post_ID' => self::$post_id, 4236 'comment_approved' => '1', 4237 'comment_parent' => $c1, 4238 ) 4239 ); 4240 $c3 = self::factory()->comment->create( 4241 array( 4242 'comment_post_ID' => self::$post_id, 4243 'comment_approved' => '1', 4244 ) 4245 ); 4246 $c4 = self::factory()->comment->create( 4247 array( 4248 'comment_post_ID' => self::$post_id, 4249 'comment_approved' => '1', 4250 'comment_parent' => $c3, 4251 ) 4252 ); 4253 $c5 = self::factory()->comment->create( 4254 array( 4255 'comment_post_ID' => self::$post_id, 4256 'comment_approved' => '1', 4257 'comment_parent' => $c3, 4258 ) 4259 ); 4260 4261 $q = new WP_Comment_Query(); 4262 $found = $q->query( 4263 array( 4264 'orderby' => 'comment_date_gmt', 4265 'order' => 'ASC', 4266 'status' => 'approve', 4267 'post_id' => self::$post_id, 4268 'no_found_rows' => false, 4269 'hierarchical' => 'threaded', 4270 'number' => 2, 4271 'offset' => 1, 4272 ) 4273 ); 4274 4275 $found_1 = $found[ $c1 ]; 2648 4276 $children_1 = $found_1->get_children(); 2649 4277 $this->assertEqualSets( array( $c2 ), array_keys( $children_1 ) ); 2650 4278 2651 $found_3 = $found[ $c3 ];4279 $found_3 = $found[ $c3 ]; 2652 4280 $children_3 = $found_3->get_children(); 2653 4281 $this->assertEqualSets( array( $c4, $c5 ), array_keys( $children_3 ) ); … … 2663 4291 $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); 2664 4292 2665 $q = new WP_Comment_Query( array( 2666 'post_ID' => $p, 2667 ) ); 4293 $q = new WP_Comment_Query( 4294 array( 4295 'post_ID' => $p, 4296 ) 4297 ); 2668 4298 2669 4299 $num_queries = $wpdb->num_queries; … … 2681 4311 $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); 2682 4312 2683 $q = new WP_Comment_Query( array( 2684 'post_ID' => $p, 2685 'update_comment_post_cache' => true, 2686 ) ); 4313 $q = new WP_Comment_Query( 4314 array( 4315 'post_ID' => $p, 4316 'update_comment_post_cache' => true, 4317 ) 4318 ); 2687 4319 2688 4320 $num_queries = $wpdb->num_queries; … … 2701 4333 2702 4334 $num_queries = $wpdb->num_queries; 2703 $q = new WP_Comment_Query( array( 2704 'post_id' => self::$post_id, 2705 'no_found_rows' => true, 2706 'update_comment_post_cache' => false, 2707 'update_comment_meta_cache' => false, 2708 ) ); 4335 $q = new WP_Comment_Query( 4336 array( 4337 'post_id' => self::$post_id, 4338 'no_found_rows' => true, 4339 'update_comment_post_cache' => false, 4340 'update_comment_meta_cache' => false, 4341 ) 4342 ); 2709 4343 2710 4344 // 2 queries should have been fired: one for IDs, one to prime comment caches. … … 2726 4360 $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); 2727 4361 2728 $q = new WP_Comment_Query( array( 2729 'post_id' => self::$post_id, 2730 ) ); 4362 $q = new WP_Comment_Query( 4363 array( 4364 'post_id' => self::$post_id, 4365 ) 4366 ); 2731 4367 2732 4368 wp_suspend_cache_addition( $suspend ); … … 2739 4375 global $wpdb; 2740 4376 2741 $c = wp_insert_comment( array( 2742 'comment_author' => 'Foo', 2743 'comment_author_email' => 'foo@example.com', 2744 'comment_post_ID' => self::$post_id, 2745 ) ); 2746 2747 $q = new WP_Comment_Query( array( 2748 'post_id' => self::$post_id, 2749 'fields' => 'ids', 2750 ) ); 4377 $c = wp_insert_comment( 4378 array( 4379 'comment_author' => 'Foo', 4380 'comment_author_email' => 'foo@example.com', 4381 'comment_post_ID' => self::$post_id, 4382 ) 4383 ); 4384 4385 $q = new WP_Comment_Query( 4386 array( 4387 'post_id' => self::$post_id, 4388 'fields' => 'ids', 4389 ) 4390 ); 2751 4391 2752 4392 $num_queries = $wpdb->num_queries; 2753 4393 2754 $q2 = new WP_Comment_Query( array( 2755 'post_id' => self::$post_id, 2756 'fields' => 'ids', 2757 ) ); 4394 $q2 = new WP_Comment_Query( 4395 array( 4396 'post_id' => self::$post_id, 4397 'fields' => 'ids', 4398 ) 4399 ); 2758 4400 2759 4401 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 2763 4405 global $wpdb; 2764 4406 2765 $c = self::factory()->comment->create( array( 2766 'comment_post_ID' => self::$post_id, 2767 'comment_approved' => '1', 2768 ) ); 2769 2770 $q = new WP_Comment_Query( array( 2771 'post_id' => self::$post_id, 2772 'fields' => 'ids', 2773 ) ); 4407 $c = self::factory()->comment->create( 4408 array( 4409 'comment_post_ID' => self::$post_id, 4410 'comment_approved' => '1', 4411 ) 4412 ); 4413 4414 $q = new WP_Comment_Query( 4415 array( 4416 'post_id' => self::$post_id, 4417 'fields' => 'ids', 4418 ) 4419 ); 2774 4420 2775 4421 $num_queries = $wpdb->num_queries; 2776 4422 2777 $q = new WP_Comment_Query( array( 2778 'post_id' => self::$post_id, 2779 'fields' => 'ids', 2780 ) ); 4423 $q = new WP_Comment_Query( 4424 array( 4425 'post_id' => self::$post_id, 4426 'fields' => 'ids', 4427 ) 4428 ); 2781 4429 2782 4430 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 2787 4435 global $wpdb; 2788 4436 2789 $c = self::factory()->comment->create( array( 2790 'comment_post_ID' => self::$post_id, 2791 'comment_approved' => '1', 2792 ) ); 2793 2794 $q = new WP_Comment_Query( array( 2795 'post_id' => self::$post_id, 2796 'fields' => 'ids', 2797 ) ); 2798 2799 wp_update_comment( array( 2800 'comment_ID' => $c, 2801 'comment_author' => 'Foo', 2802 'comment_author_email' => 'foo@example.com', 2803 'comment_post_ID' => self::$post_id, 2804 ) ); 4437 $c = self::factory()->comment->create( 4438 array( 4439 'comment_post_ID' => self::$post_id, 4440 'comment_approved' => '1', 4441 ) 4442 ); 4443 4444 $q = new WP_Comment_Query( 4445 array( 4446 'post_id' => self::$post_id, 4447 'fields' => 'ids', 4448 ) 4449 ); 4450 4451 wp_update_comment( 4452 array( 4453 'comment_ID' => $c, 4454 'comment_author' => 'Foo', 4455 'comment_author_email' => 'foo@example.com', 4456 'comment_post_ID' => self::$post_id, 4457 ) 4458 ); 2805 4459 2806 4460 $num_queries = $wpdb->num_queries; 2807 4461 2808 $q = new WP_Comment_Query( array( 2809 'post_id' => self::$post_id, 2810 'fields' => 'ids', 2811 ) ); 4462 $q = new WP_Comment_Query( 4463 array( 4464 'post_id' => self::$post_id, 4465 'fields' => 'ids', 4466 ) 4467 ); 2812 4468 2813 4469 $num_queries++; … … 2819 4475 global $wpdb; 2820 4476 2821 $c = self::factory()->comment->create( array( 2822 'comment_post_ID' => self::$post_id, 2823 'comment_approved' => '1', 2824 ) ); 2825 2826 $q = new WP_Comment_Query( array( 2827 'post_id' => self::$post_id, 2828 'fields' => 'ids', 2829 ) ); 4477 $c = self::factory()->comment->create( 4478 array( 4479 'comment_post_ID' => self::$post_id, 4480 'comment_approved' => '1', 4481 ) 4482 ); 4483 4484 $q = new WP_Comment_Query( 4485 array( 4486 'post_id' => self::$post_id, 4487 'fields' => 'ids', 4488 ) 4489 ); 2830 4490 2831 4491 wp_delete_comment( $c ); … … 2833 4493 $num_queries = $wpdb->num_queries; 2834 4494 2835 $q = new WP_Comment_Query( array( 2836 'post_id' => self::$post_id, 2837 'fields' => 'ids', 2838 ) ); 4495 $q = new WP_Comment_Query( 4496 array( 4497 'post_id' => self::$post_id, 4498 'fields' => 'ids', 4499 ) 4500 ); 2839 4501 2840 4502 $num_queries++; … … 2846 4508 global $wpdb; 2847 4509 2848 $c = self::factory()->comment->create( array( 2849 'comment_post_ID' => self::$post_id, 2850 'comment_approved' => '1', 2851 ) ); 2852 2853 $q = new WP_Comment_Query( array( 2854 'post_id' => self::$post_id, 2855 'fields' => 'ids', 2856 ) ); 4510 $c = self::factory()->comment->create( 4511 array( 4512 'comment_post_ID' => self::$post_id, 4513 'comment_approved' => '1', 4514 ) 4515 ); 4516 4517 $q = new WP_Comment_Query( 4518 array( 4519 'post_id' => self::$post_id, 4520 'fields' => 'ids', 4521 ) 4522 ); 2857 4523 2858 4524 wp_trash_comment( $c ); … … 2860 4526 $num_queries = $wpdb->num_queries; 2861 4527 2862 $q = new WP_Comment_Query( array( 2863 'post_id' => self::$post_id, 2864 'fields' => 'ids', 2865 ) ); 4528 $q = new WP_Comment_Query( 4529 array( 4530 'post_id' => self::$post_id, 4531 'fields' => 'ids', 4532 ) 4533 ); 2866 4534 2867 4535 $num_queries++; … … 2873 4541 global $wpdb; 2874 4542 2875 $c = self::factory()->comment->create( array( 2876 'comment_post_ID' => self::$post_id, 2877 'comment_approved' => '1', 2878 ) ); 4543 $c = self::factory()->comment->create( 4544 array( 4545 'comment_post_ID' => self::$post_id, 4546 'comment_approved' => '1', 4547 ) 4548 ); 2879 4549 2880 4550 wp_trash_comment( $c ); 2881 4551 2882 $q = new WP_Comment_Query( array( 2883 'post_id' => self::$post_id, 2884 'fields' => 'ids', 2885 ) ); 4552 $q = new WP_Comment_Query( 4553 array( 4554 'post_id' => self::$post_id, 4555 'fields' => 'ids', 4556 ) 4557 ); 2886 4558 2887 4559 wp_untrash_comment( $c ); … … 2889 4561 $num_queries = $wpdb->num_queries; 2890 4562 2891 $q = new WP_Comment_Query( array( 2892 'post_id' => self::$post_id, 2893 'fields' => 'ids', 2894 ) ); 4563 $q = new WP_Comment_Query( 4564 array( 4565 'post_id' => self::$post_id, 4566 'fields' => 'ids', 4567 ) 4568 ); 2895 4569 2896 4570 $num_queries++; … … 2902 4576 global $wpdb; 2903 4577 2904 $c = self::factory()->comment->create( array( 2905 'comment_post_ID' => self::$post_id, 2906 'comment_approved' => '1', 2907 ) ); 2908 2909 $q = new WP_Comment_Query( array( 2910 'post_id' => self::$post_id, 2911 'fields' => 'ids', 2912 ) ); 4578 $c = self::factory()->comment->create( 4579 array( 4580 'comment_post_ID' => self::$post_id, 4581 'comment_approved' => '1', 4582 ) 4583 ); 4584 4585 $q = new WP_Comment_Query( 4586 array( 4587 'post_id' => self::$post_id, 4588 'fields' => 'ids', 4589 ) 4590 ); 2913 4591 2914 4592 wp_spam_comment( $c ); … … 2916 4594 $num_queries = $wpdb->num_queries; 2917 4595 2918 $q = new WP_Comment_Query( array( 2919 'post_id' => self::$post_id, 2920 'fields' => 'ids', 2921 ) ); 4596 $q = new WP_Comment_Query( 4597 array( 4598 'post_id' => self::$post_id, 4599 'fields' => 'ids', 4600 ) 4601 ); 2922 4602 2923 4603 $num_queries++; … … 2929 4609 global $wpdb; 2930 4610 2931 $c = self::factory()->comment->create( array( 2932 'comment_post_ID' => self::$post_id, 2933 'comment_approved' => '1', 2934 ) ); 4611 $c = self::factory()->comment->create( 4612 array( 4613 'comment_post_ID' => self::$post_id, 4614 'comment_approved' => '1', 4615 ) 4616 ); 2935 4617 2936 4618 wp_spam_comment( $c ); 2937 4619 2938 $q = new WP_Comment_Query( array( 2939 'post_id' => self::$post_id, 2940 'fields' => 'ids', 2941 ) ); 4620 $q = new WP_Comment_Query( 4621 array( 4622 'post_id' => self::$post_id, 4623 'fields' => 'ids', 4624 ) 4625 ); 2942 4626 2943 4627 wp_unspam_comment( $c ); … … 2945 4629 $num_queries = $wpdb->num_queries; 2946 4630 2947 $q = new WP_Comment_Query( array( 2948 'post_id' => self::$post_id, 2949 'fields' => 'ids', 2950 ) ); 4631 $q = new WP_Comment_Query( 4632 array( 4633 'post_id' => self::$post_id, 4634 'fields' => 'ids', 4635 ) 4636 ); 2951 4637 2952 4638 $num_queries++; … … 2963 4649 $q = new WP_Comment_Query(); 2964 4650 2965 $query_1 = $q->query( array( 2966 'fields' => 'ids', 2967 'number' => 3, 2968 'order' => 'ASC', 2969 ) ); 4651 $query_1 = $q->query( 4652 array( 4653 'fields' => 'ids', 4654 'number' => 3, 4655 'order' => 'ASC', 4656 ) 4657 ); 2970 4658 2971 4659 $number_of_queries = $wpdb->num_queries; 2972 4660 2973 $query_2 = $q->query( array( 2974 'fields' => 'ids', 2975 'number' => 3, 2976 'order' => 'ASC', 2977 'count' => true, 2978 ) ); 4661 $query_2 = $q->query( 4662 array( 4663 'fields' => 'ids', 4664 'number' => 3, 4665 'order' => 'ASC', 4666 'count' => true, 4667 ) 4668 ); 2979 4669 $this->assertEquals( $number_of_queries + 1, $wpdb->num_queries ); 2980 4670 } … … 2988 4678 $q = new WP_Comment_Query(); 2989 4679 2990 $query_1 = $q->query( array( 2991 'fields' => 'ids', 2992 'number' => 3, 2993 'order' => 'ASC', 2994 'count' => true, 2995 ) ); 4680 $query_1 = $q->query( 4681 array( 4682 'fields' => 'ids', 4683 'number' => 3, 4684 'order' => 'ASC', 4685 'count' => true, 4686 ) 4687 ); 2996 4688 $number_of_queries = $wpdb->num_queries; 2997 4689 2998 $query_2 = $q->query( array( 2999 'fields' => 'ids', 3000 'number' => 3, 3001 'order' => 'ASC', 3002 'count' => true, 3003 ) ); 4690 $query_2 = $q->query( 4691 array( 4692 'fields' => 'ids', 4693 'number' => 3, 4694 'order' => 'ASC', 4695 'count' => true, 4696 ) 4697 ); 3004 4698 $this->assertEquals( $number_of_queries, $wpdb->num_queries ); 3005 4699 } … … 3013 4707 $q = new WP_Comment_Query(); 3014 4708 3015 $query_1 = $q->query( array( 3016 'fields' => 'all', 3017 'number' => 3, 3018 'order' => 'ASC', 3019 ) ); 4709 $query_1 = $q->query( 4710 array( 4711 'fields' => 'all', 4712 'number' => 3, 4713 'order' => 'ASC', 4714 ) 4715 ); 3020 4716 $number_of_queries = $wpdb->num_queries; 3021 4717 3022 $query_2 = $q->query( array( 3023 'fields' => 'ids', 3024 'number' => 3, 3025 'order' => 'ASC', 3026 ) ); 4718 $query_2 = $q->query( 4719 array( 4720 'fields' => 'ids', 4721 'number' => 3, 4722 'order' => 'ASC', 4723 ) 4724 ); 3027 4725 3028 4726 $this->assertEquals( $number_of_queries, $wpdb->num_queries ); … … 3035 4733 global $wpdb; 3036 4734 3037 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );4735 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 3038 4736 $c1 = self::factory()->comment->create_post_comments( $p, 1 ); 3039 4737 $c2 = self::factory()->comment->create_post_comments( $p, 1 ); … … 3043 4741 } 3044 4742 3045 $cached = get_comments( array( 3046 'post_id' => $p, 3047 'fields' => 'ids', 3048 'meta_query' => array( 3049 array( 3050 'key' => 'sauce', 3051 'value' => 'fire', 4743 $cached = get_comments( 4744 array( 4745 'post_id' => $p, 4746 'fields' => 'ids', 4747 'meta_query' => array( 4748 array( 4749 'key' => 'sauce', 4750 'value' => 'fire', 4751 ), 3052 4752 ), 3053 4753 ) 3054 ) );4754 ); 3055 4755 3056 4756 $this->assertEqualSets( $c1, $cached ); … … 3060 4760 } 3061 4761 3062 $found = get_comments( array( 3063 'post_id' => $p, 3064 'fields' => 'ids', 3065 'meta_query' => array( 3066 array( 3067 'key' => 'sauce', 3068 'value' => 'fire', 4762 $found = get_comments( 4763 array( 4764 'post_id' => $p, 4765 'fields' => 'ids', 4766 'meta_query' => array( 4767 array( 4768 'key' => 'sauce', 4769 'value' => 'fire', 4770 ), 3069 4771 ), 3070 4772 ) 3071 ) );4773 ); 3072 4774 3073 4775 $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); … … 3080 4782 global $wpdb; 3081 4783 3082 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );4784 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 3083 4785 $c1 = self::factory()->comment->create_post_comments( $p, 1 ); 3084 4786 $c2 = self::factory()->comment->create_post_comments( $p, 1 ); … … 3088 4790 } 3089 4791 3090 $cached = get_comments( array( 3091 'post_id' => $p, 3092 'fields' => 'ids', 3093 'meta_query' => array( 3094 array( 3095 'key' => 'sauce', 3096 'value' => 'fire', 4792 $cached = get_comments( 4793 array( 4794 'post_id' => $p, 4795 'fields' => 'ids', 4796 'meta_query' => array( 4797 array( 4798 'key' => 'sauce', 4799 'value' => 'fire', 4800 ), 3097 4801 ), 3098 4802 ) 3099 ) );4803 ); 3100 4804 3101 4805 $this->assertEqualSets( array_merge( $c1, $c2 ), $cached ); … … 3105 4809 } 3106 4810 3107 $found = get_comments( array( 3108 'post_id' => $p, 3109 'fields' => 'ids', 3110 'meta_query' => array( 3111 array( 3112 'key' => 'sauce', 3113 'value' => 'fire', 4811 $found = get_comments( 4812 array( 4813 'post_id' => $p, 4814 'fields' => 'ids', 4815 'meta_query' => array( 4816 array( 4817 'key' => 'sauce', 4818 'value' => 'fire', 4819 ), 3114 4820 ), 3115 4821 ) 3116 ) );4822 ); 3117 4823 3118 4824 $this->assertEqualSets( $c1, $found ); … … 3125 4831 global $wpdb; 3126 4832 3127 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );4833 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 3128 4834 $c1 = self::factory()->comment->create_post_comments( $p, 1 ); 3129 4835 $c2 = self::factory()->comment->create_post_comments( $p, 1 ); … … 3133 4839 } 3134 4840 3135 $cached = get_comments( array( 3136 'post_id' => $p, 3137 'fields' => 'ids', 3138 'meta_query' => array( 3139 array( 3140 'key' => 'sauce', 3141 'value' => 'fire', 4841 $cached = get_comments( 4842 array( 4843 'post_id' => $p, 4844 'fields' => 'ids', 4845 'meta_query' => array( 4846 array( 4847 'key' => 'sauce', 4848 'value' => 'fire', 4849 ), 3142 4850 ), 3143 4851 ) 3144 ) );4852 ); 3145 4853 3146 4854 $this->assertEqualSets( array_merge( $c1, $c2 ), $cached ); … … 3150 4858 } 3151 4859 3152 $found = get_comments( array( 3153 'post_id' => $p, 3154 'fields' => 'ids', 3155 'meta_query' => array( 3156 array( 3157 'key' => 'sauce', 3158 'value' => 'fire', 4860 $found = get_comments( 4861 array( 4862 'post_id' => $p, 4863 'fields' => 'ids', 4864 'meta_query' => array( 4865 array( 4866 'key' => 'sauce', 4867 'value' => 'fire', 4868 ), 3159 4869 ), 3160 4870 ) 3161 ) );4871 ); 3162 4872 3163 4873 $this->assertEqualSets( $c1, $found );
Note: See TracChangeset
for help on using the changeset viewer.