| | 274 | /** |
| | 275 | * @ticket 29908 |
| | 276 | */ |
| | 277 | public function test_beforeafter_with_date_string_Y() { |
| | 278 | $p1 = $this->factory->post->create( array( |
| | 279 | 'post_date' => '2008-05-06 13:00:00', |
| | 280 | ) ); |
| | 281 | $p2 = $this->factory->post->create( array( |
| | 282 | 'post_date' => '2007-05-07 13:00:00', |
| | 283 | ) ); |
| | 284 | |
| | 285 | $before_posts = $this->_get_query_result( array( |
| | 286 | 'fields' => 'ids', |
| | 287 | 'update_post_meta_cache' => false, |
| | 288 | 'update_post_term_cache' => false, |
| | 289 | 'date_query' => array( |
| | 290 | 'before' => '2008', |
| | 291 | ), |
| | 292 | ) ); |
| | 293 | |
| | 294 | $after_posts = $this->_get_query_result( array( |
| | 295 | 'fields' => 'ids', |
| | 296 | 'update_post_meta_cache' => false, |
| | 297 | 'update_post_term_cache' => false, |
| | 298 | 'date_query' => array( |
| | 299 | 'after' => '2007', |
| | 300 | ), |
| | 301 | ) ); |
| | 302 | |
| | 303 | $this->assertEquals( array( $p2 ), $before_posts ); |
| | 304 | $this->assertEquals( array( $p1 ), $after_posts ); |
| | 305 | } |
| | 306 | |
| | 307 | /** |
| | 308 | * @ticket 29908 |
| | 309 | */ |
| | 310 | public function test_beforeafter_with_date_string_Y_inclusive() { |
| | 311 | $p1 = $this->factory->post->create( array( |
| | 312 | 'post_date' => '2008-05-06 13:00:00', |
| | 313 | ) ); |
| | 314 | $p2 = $this->factory->post->create( array( |
| | 315 | 'post_date' => '2007-05-07 13:00:00', |
| | 316 | ) ); |
| | 317 | |
| | 318 | $before_posts = $this->_get_query_result( array( |
| | 319 | 'fields' => 'ids', |
| | 320 | 'update_post_meta_cache' => false, |
| | 321 | 'update_post_term_cache' => false, |
| | 322 | 'date_query' => array( |
| | 323 | 'before' => '2008', |
| | 324 | 'inclusive' => true, |
| | 325 | ), |
| | 326 | ) ); |
| | 327 | |
| | 328 | $after_posts = $this->_get_query_result( array( |
| | 329 | 'fields' => 'ids', |
| | 330 | 'update_post_meta_cache' => false, |
| | 331 | 'update_post_term_cache' => false, |
| | 332 | 'date_query' => array( |
| | 333 | 'after' => '2007', |
| | 334 | 'inclusive' => true, |
| | 335 | ), |
| | 336 | ) ); |
| | 337 | |
| | 338 | $this->assertEqualSets( array( $p1, $p2 ), $before_posts ); |
| | 339 | $this->assertEqualSets( array( $p1, $p2 ), $after_posts ); |
| | 340 | } |
| | 341 | |
| | 342 | /** |
| | 343 | * @ticket 29908 |
| | 344 | */ |
| | 345 | public function test_beforeafter_with_date_string_Ym() { |
| | 346 | $p1 = $this->factory->post->create( array( |
| | 347 | 'post_date' => '2008-05-06 13:00:00', |
| | 348 | ) ); |
| | 349 | $p2 = $this->factory->post->create( array( |
| | 350 | 'post_date' => '2008-04-07 13:00:00', |
| | 351 | ) ); |
| | 352 | |
| | 353 | $before_posts = $this->_get_query_result( array( |
| | 354 | 'fields' => 'ids', |
| | 355 | 'update_post_meta_cache' => false, |
| | 356 | 'update_post_term_cache' => false, |
| | 357 | 'date_query' => array( |
| | 358 | 'before' => '2008-05', |
| | 359 | ), |
| | 360 | ) ); |
| | 361 | |
| | 362 | $after_posts = $this->_get_query_result( array( |
| | 363 | 'fields' => 'ids', |
| | 364 | 'update_post_meta_cache' => false, |
| | 365 | 'update_post_term_cache' => false, |
| | 366 | 'date_query' => array( |
| | 367 | 'after' => '2008-04', |
| | 368 | ), |
| | 369 | ) ); |
| | 370 | |
| | 371 | $this->assertEquals( array( $p2 ), $before_posts ); |
| | 372 | $this->assertEquals( array( $p1 ), $after_posts ); |
| | 373 | } |
| | 374 | |
| | 375 | /** |
| | 376 | * @ticket 29908 |
| | 377 | */ |
| | 378 | public function test_beforeafter_with_date_string_Ym_forwardslashes() { |
| | 379 | $p1 = $this->factory->post->create( array( |
| | 380 | 'post_date' => '2008-05-06 13:00:00', |
| | 381 | ) ); |
| | 382 | $p2 = $this->factory->post->create( array( |
| | 383 | 'post_date' => '2008-04-07 13:00:00', |
| | 384 | ) ); |
| | 385 | |
| | 386 | $before_posts = $this->_get_query_result( array( |
| | 387 | 'fields' => 'ids', |
| | 388 | 'update_post_meta_cache' => false, |
| | 389 | 'update_post_term_cache' => false, |
| | 390 | 'date_query' => array( |
| | 391 | 'before' => '2008/05', |
| | 392 | ), |
| | 393 | ) ); |
| | 394 | |
| | 395 | $after_posts = $this->_get_query_result( array( |
| | 396 | 'fields' => 'ids', |
| | 397 | 'update_post_meta_cache' => false, |
| | 398 | 'update_post_term_cache' => false, |
| | 399 | 'date_query' => array( |
| | 400 | 'after' => '2008/04', |
| | 401 | ), |
| | 402 | ) ); |
| | 403 | |
| | 404 | $this->assertEquals( array( $p2 ), $before_posts ); |
| | 405 | $this->assertEquals( array( $p1 ), $after_posts ); |
| | 406 | } |
| | 407 | |
| | 408 | /** |
| | 409 | * @ticket 29908 |
| | 410 | */ |
| | 411 | public function test_beforeafter_with_date_string_Ym_inclusive() { |
| | 412 | $p1 = $this->factory->post->create( array( |
| | 413 | 'post_date' => '2008-05-06 13:00:00', |
| | 414 | ) ); |
| | 415 | $p2 = $this->factory->post->create( array( |
| | 416 | 'post_date' => '2008-04-07 13:00:00', |
| | 417 | ) ); |
| | 418 | |
| | 419 | $before_posts = $this->_get_query_result( array( |
| | 420 | 'fields' => 'ids', |
| | 421 | 'update_post_meta_cache' => false, |
| | 422 | 'update_post_term_cache' => false, |
| | 423 | 'date_query' => array( |
| | 424 | 'before' => '2008-05', |
| | 425 | 'inclusive' => true, |
| | 426 | ), |
| | 427 | ) ); |
| | 428 | |
| | 429 | $after_posts = $this->_get_query_result( array( |
| | 430 | 'fields' => 'ids', |
| | 431 | 'update_post_meta_cache' => false, |
| | 432 | 'update_post_term_cache' => false, |
| | 433 | 'date_query' => array( |
| | 434 | 'after' => '2008-04', |
| | 435 | 'inclusive' => true, |
| | 436 | ), |
| | 437 | ) ); |
| | 438 | |
| | 439 | $this->assertEqualSets( array( $p1, $p2 ), $before_posts ); |
| | 440 | $this->assertEqualSets( array( $p1, $p2 ), $after_posts ); |
| | 441 | } |
| | 442 | |
| | 443 | /** |
| | 444 | * @ticket 29908 |
| | 445 | */ |
| | 446 | public function test_beforeafter_with_date_string_Ymd() { |
| | 447 | $p1 = $this->factory->post->create( array( |
| | 448 | 'post_date' => '2008-05-06 13:00:00', |
| | 449 | ) ); |
| | 450 | $p2 = $this->factory->post->create( array( |
| | 451 | 'post_date' => '2008-05-05 13:00:00', |
| | 452 | ) ); |
| | 453 | |
| | 454 | $before_posts = $this->_get_query_result( array( |
| | 455 | 'fields' => 'ids', |
| | 456 | 'update_post_meta_cache' => false, |
| | 457 | 'update_post_term_cache' => false, |
| | 458 | 'date_query' => array( |
| | 459 | 'before' => '2008-05-06', |
| | 460 | ), |
| | 461 | ) ); |
| | 462 | |
| | 463 | $after_posts = $this->_get_query_result( array( |
| | 464 | 'fields' => 'ids', |
| | 465 | 'update_post_meta_cache' => false, |
| | 466 | 'update_post_term_cache' => false, |
| | 467 | 'date_query' => array( |
| | 468 | 'after' => '2008-05-05', |
| | 469 | ), |
| | 470 | ) ); |
| | 471 | |
| | 472 | $this->assertEquals( array( $p2 ), $before_posts ); |
| | 473 | $this->assertEquals( array( $p1 ), $after_posts ); |
| | 474 | } |
| | 475 | |
| | 476 | /** |
| | 477 | * @ticket 29908 |
| | 478 | */ |
| | 479 | public function test_beforeafter_with_date_string_Ymd_inclusive() { |
| | 480 | $p1 = $this->factory->post->create( array( |
| | 481 | 'post_date' => '2008-05-06 13:00:00', |
| | 482 | ) ); |
| | 483 | $p2 = $this->factory->post->create( array( |
| | 484 | 'post_date' => '2008-05-05 13:00:00', |
| | 485 | ) ); |
| | 486 | |
| | 487 | $before_posts = $this->_get_query_result( array( |
| | 488 | 'fields' => 'ids', |
| | 489 | 'update_post_meta_cache' => false, |
| | 490 | 'update_post_term_cache' => false, |
| | 491 | 'date_query' => array( |
| | 492 | 'before' => '2008-05-06', |
| | 493 | 'inclusive' => true, |
| | 494 | ), |
| | 495 | ) ); |
| | 496 | |
| | 497 | $after_posts = $this->_get_query_result( array( |
| | 498 | 'fields' => 'ids', |
| | 499 | 'update_post_meta_cache' => false, |
| | 500 | 'update_post_term_cache' => false, |
| | 501 | 'date_query' => array( |
| | 502 | 'after' => '2008-05-05', |
| | 503 | 'inclusive' => true, |
| | 504 | ), |
| | 505 | ) ); |
| | 506 | |
| | 507 | $this->assertEqualSets( array( $p1, $p2 ), $before_posts ); |
| | 508 | $this->assertEqualSets( array( $p1, $p2 ), $after_posts ); |
| | 509 | } |
| | 510 | |
| | 511 | /** |
| | 512 | * @ticket 29908 |
| | 513 | */ |
| | 514 | public function test_beforeafter_with_date_string_YmdHi() { |
| | 515 | $p1 = $this->factory->post->create( array( |
| | 516 | 'post_date' => '2008-05-06 14:05:00', |
| | 517 | ) ); |
| | 518 | $p2 = $this->factory->post->create( array( |
| | 519 | 'post_date' => '2008-05-06 14:04:00', |
| | 520 | ) ); |
| | 521 | |
| | 522 | $before_posts = $this->_get_query_result( array( |
| | 523 | 'fields' => 'ids', |
| | 524 | 'update_post_meta_cache' => false, |
| | 525 | 'update_post_term_cache' => false, |
| | 526 | 'date_query' => array( |
| | 527 | 'before' => '2008-05-06 14:05', |
| | 528 | ), |
| | 529 | ) ); |
| | 530 | |
| | 531 | $after_posts = $this->_get_query_result( array( |
| | 532 | 'fields' => 'ids', |
| | 533 | 'update_post_meta_cache' => false, |
| | 534 | 'update_post_term_cache' => false, |
| | 535 | 'date_query' => array( |
| | 536 | 'after' => '2008-05-06 14:04', |
| | 537 | ), |
| | 538 | ) ); |
| | 539 | |
| | 540 | $this->assertEquals( array( $p2 ), $before_posts ); |
| | 541 | $this->assertEquals( array( $p1 ), $after_posts ); |
| | 542 | } |
| | 543 | |
| | 544 | /** |
| | 545 | * @ticket 29908 |
| | 546 | */ |
| | 547 | public function test_beforeafter_with_date_string_YmdHi_inclusive() { |
| | 548 | $p1 = $this->factory->post->create( array( |
| | 549 | 'post_date' => '2008-05-06 14:05:00', |
| | 550 | ) ); |
| | 551 | $p2 = $this->factory->post->create( array( |
| | 552 | 'post_date' => '2008-05-06 14:04:00', |
| | 553 | ) ); |
| | 554 | |
| | 555 | $before_posts = $this->_get_query_result( array( |
| | 556 | 'fields' => 'ids', |
| | 557 | 'update_post_meta_cache' => false, |
| | 558 | 'update_post_term_cache' => false, |
| | 559 | 'date_query' => array( |
| | 560 | 'before' => '2008-05-06 14:05', |
| | 561 | 'inclusive' => true, |
| | 562 | ), |
| | 563 | ) ); |
| | 564 | |
| | 565 | $after_posts = $this->_get_query_result( array( |
| | 566 | 'fields' => 'ids', |
| | 567 | 'update_post_meta_cache' => false, |
| | 568 | 'update_post_term_cache' => false, |
| | 569 | 'date_query' => array( |
| | 570 | 'after' => '2008-05-06 14:04', |
| | 571 | 'inclusive' => true, |
| | 572 | ), |
| | 573 | ) ); |
| | 574 | |
| | 575 | $this->assertEqualSets( array( $p1, $p2 ), $before_posts ); |
| | 576 | $this->assertEqualSets( array( $p1, $p2 ), $after_posts ); |
| | 577 | } |
| | 578 | |
| | 579 | /** |
| | 580 | * @ticket 29908 |
| | 581 | */ |
| | 582 | public function test_beforeafter_with_date_string_YmdHis() { |
| | 583 | $p1 = $this->factory->post->create( array( |
| | 584 | 'post_date' => '2008-05-06 14:05:15', |
| | 585 | ) ); |
| | 586 | $p2 = $this->factory->post->create( array( |
| | 587 | 'post_date' => '2008-05-06 14:05:14', |
| | 588 | ) ); |
| | 589 | |
| | 590 | $before_posts = $this->_get_query_result( array( |
| | 591 | 'fields' => 'ids', |
| | 592 | 'update_post_meta_cache' => false, |
| | 593 | 'update_post_term_cache' => false, |
| | 594 | 'date_query' => array( |
| | 595 | 'before' => '2008-05-06 14:05:15', |
| | 596 | ), |
| | 597 | ) ); |
| | 598 | |
| | 599 | $after_posts = $this->_get_query_result( array( |
| | 600 | 'fields' => 'ids', |
| | 601 | 'update_post_meta_cache' => false, |
| | 602 | 'update_post_term_cache' => false, |
| | 603 | 'date_query' => array( |
| | 604 | 'after' => '2008-05-06 14:05:14', |
| | 605 | ), |
| | 606 | ) ); |
| | 607 | |
| | 608 | $this->assertEquals( array( $p2 ), $before_posts ); |
| | 609 | $this->assertEquals( array( $p1 ), $after_posts ); |
| | 610 | } |
| | 611 | |
| | 612 | /** |
| | 613 | * @ticket 29908 |
| | 614 | */ |
| | 615 | public function test_beforeafter_with_date_string_YmdHis_inclusive() { |
| | 616 | $p1 = $this->factory->post->create( array( |
| | 617 | 'post_date' => '2008-05-06 14:04:15', |
| | 618 | ) ); |
| | 619 | $p2 = $this->factory->post->create( array( |
| | 620 | 'post_date' => '2008-05-06 14:04:14', |
| | 621 | ) ); |
| | 622 | |
| | 623 | $before_posts = $this->_get_query_result( array( |
| | 624 | 'fields' => 'ids', |
| | 625 | 'update_post_meta_cache' => false, |
| | 626 | 'update_post_term_cache' => false, |
| | 627 | 'date_query' => array( |
| | 628 | 'before' => '2008-05-06 14:04:15', |
| | 629 | 'inclusive' => true, |
| | 630 | ), |
| | 631 | ) ); |
| | 632 | |
| | 633 | $after_posts = $this->_get_query_result( array( |
| | 634 | 'fields' => 'ids', |
| | 635 | 'update_post_meta_cache' => false, |
| | 636 | 'update_post_term_cache' => false, |
| | 637 | 'date_query' => array( |
| | 638 | 'after' => '2008-05-06 14:04:14', |
| | 639 | 'inclusive' => true, |
| | 640 | ), |
| | 641 | ) ); |
| | 642 | |
| | 643 | $this->assertEqualSets( array( $p1, $p2 ), $before_posts ); |
| | 644 | $this->assertEqualSets( array( $p1, $p2 ), $after_posts ); |
| | 645 | } |
| | 646 | |
| | 647 | /** |
| | 648 | * @ticket 29908 |
| | 649 | */ |
| | 650 | public function test_beforeafter_with_date_string_non_parseable() { |
| | 651 | $p1 = $this->factory->post->create( array( |
| | 652 | 'post_date' => '2008-05-06 14:05:15', |
| | 653 | ) ); |
| | 654 | $p2 = $this->factory->post->create( array( |
| | 655 | 'post_date' => '2008-05-06 14:05:14', |
| | 656 | ) ); |
| | 657 | |
| | 658 | $before_posts = $this->_get_query_result( array( |
| | 659 | 'fields' => 'ids', |
| | 660 | 'update_post_meta_cache' => false, |
| | 661 | 'update_post_term_cache' => false, |
| | 662 | 'date_query' => array( |
| | 663 | 'before' => 'June 12, 2008', |
| | 664 | ), |
| | 665 | ) ); |
| | 666 | |
| | 667 | $after_posts = $this->_get_query_result( array( |
| | 668 | 'fields' => 'ids', |
| | 669 | 'update_post_meta_cache' => false, |
| | 670 | 'update_post_term_cache' => false, |
| | 671 | 'date_query' => array( |
| | 672 | 'after' => 'June 12, 2007', |
| | 673 | ), |
| | 674 | ) ); |
| | 675 | |
| | 676 | $this->assertEquals( array( $p1, $p2 ), $before_posts ); |
| | 677 | } |
| | 678 | |