Changeset 47122 for trunk/tests/phpunit/tests/date/query.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/date/query.php
r46586 r47122 322 322 $q = new WP_Date_Query( array() ); 323 323 324 // Single integer 324 // Single integer. 325 325 $found = $q->build_value( 'IN', 4 ); 326 326 $this->assertSame( '(4)', $found ); 327 327 328 // Single non-integer 328 // Single non-integer. 329 329 $found = $q->build_value( 'IN', 'foo' ); 330 330 $this->assertFalse( $found ); 331 331 332 // Array of integers 332 // Array of integers. 333 333 $found = $q->build_value( 'IN', array( 1, 4, 7 ) ); 334 334 $this->assertSame( '(1,4,7)', $found ); 335 335 336 // Array containing non-integers 336 // Array containing non-integers. 337 337 $found = $q->build_value( 'IN', array( 1, 'foo', 7 ) ); 338 338 $this->assertSame( '(1,7)', $found ); … … 345 345 $q = new WP_Date_Query( array() ); 346 346 347 // Single integer 347 // Single integer. 348 348 $found = $q->build_value( 'NOT IN', 4 ); 349 349 $this->assertSame( '(4)', $found ); 350 350 351 // Single non-integer 351 // Single non-integer. 352 352 $found = $q->build_value( 'NOT IN', 'foo' ); 353 353 $this->assertFalse( $found ); 354 354 355 // Array of integers 355 // Array of integers. 356 356 $found = $q->build_value( 'NOT IN', array( 1, 4, 7 ) ); 357 357 $this->assertSame( '(1,4,7)', $found ); 358 358 359 // Array containing non-integers 359 // Array containing non-integers. 360 360 $found = $q->build_value( 'NOT IN', array( 1, 'foo', 7 ) ); 361 361 $this->assertSame( '(1,7)', $found ); … … 504 504 $q = new WP_Date_Query( array() ); 505 505 506 // This might be a fragile test if it takes longer than 1 second to run 506 // This might be a fragile test if it takes longer than 1 second to run. 507 507 $found = $q->build_mysql_datetime( 'foo' ); 508 508 $expected = gmdate( 'Y-m-d H:i:s', false ); … … 608 608 $q = new WP_Date_Query( array() ); 609 609 610 // Just hour 610 // Just hour. 611 611 $found = $q->build_time_query( 'post_date', 'IN', array( 1, 2 ) ); 612 612 $this->assertSame( 'HOUR( post_date ) IN (1,2)', $found ); 613 613 614 // Skip minute 614 // Skip minute. 615 615 $found = $q->build_time_query( 'post_date', 'IN', array( 1, 2 ), null, 6 ); 616 616 $this->assertSame( 'HOUR( post_date ) IN (1,2) AND SECOND( post_date ) IN (6)', $found ); 617 617 618 // All three 618 // All three. 619 619 $found = $q->build_time_query( 'post_date', 'IN', array( 1, 2 ), array( 3, 4, 5 ), 6 ); 620 620 $this->assertSame( 'HOUR( post_date ) IN (1,2) AND MINUTE( post_date ) IN (3,4,5) AND SECOND( post_date ) IN (6)', $found ); … … 624 624 $q = new WP_Date_Query( array() ); 625 625 626 // Just hour 626 // Just hour. 627 627 $found = $q->build_time_query( 'post_date', 'NOT IN', array( 1, 2 ) ); 628 628 $this->assertSame( 'HOUR( post_date ) NOT IN (1,2)', $found ); 629 629 630 // Skip minute 630 // Skip minute. 631 631 $found = $q->build_time_query( 'post_date', 'NOT IN', array( 1, 2 ), null, 6 ); 632 632 $this->assertSame( 'HOUR( post_date ) NOT IN (1,2) AND SECOND( post_date ) NOT IN (6)', $found ); 633 633 634 // All three 634 // All three. 635 635 $found = $q->build_time_query( 'post_date', 'NOT IN', array( 1, 2 ), array( 3, 4, 5 ), 6 ); 636 636 $this->assertSame( 'HOUR( post_date ) NOT IN (1,2) AND MINUTE( post_date ) NOT IN (3,4,5) AND SECOND( post_date ) NOT IN (6)', $found ); … … 640 640 $q = new WP_Date_Query( array() ); 641 641 642 // Just hour 642 // Just hour. 643 643 $found = $q->build_time_query( 'post_date', 'BETWEEN', array( 1, 2 ) ); 644 644 $this->assertSame( 'HOUR( post_date ) BETWEEN 1 AND 2', $found ); 645 645 646 // Skip minute 646 // Skip minute. 647 647 $found = $q->build_time_query( 'post_date', 'BETWEEN', array( 1, 2 ), null, array( 6, 7 ) ); 648 648 $this->assertSame( 'HOUR( post_date ) BETWEEN 1 AND 2 AND SECOND( post_date ) BETWEEN 6 AND 7', $found ); 649 649 650 // All three 650 // All three. 651 651 $found = $q->build_time_query( 'post_date', 'BETWEEN', array( 1, 2 ), array( 3, 4 ), array( 6, 7 ) ); 652 652 $this->assertSame( 'HOUR( post_date ) BETWEEN 1 AND 2 AND MINUTE( post_date ) BETWEEN 3 AND 4 AND SECOND( post_date ) BETWEEN 6 AND 7', $found ); … … 656 656 $q = new WP_Date_Query( array() ); 657 657 658 // Just hour 658 // Just hour. 659 659 $found = $q->build_time_query( 'post_date', 'NOT BETWEEN', array( 1, 2 ) ); 660 660 $this->assertSame( 'HOUR( post_date ) NOT BETWEEN 1 AND 2', $found ); 661 661 662 // Skip minute 662 // Skip minute. 663 663 $found = $q->build_time_query( 'post_date', 'NOT BETWEEN', array( 1, 2 ), null, array( 6, 7 ) ); 664 664 $this->assertSame( 'HOUR( post_date ) NOT BETWEEN 1 AND 2 AND SECOND( post_date ) NOT BETWEEN 6 AND 7', $found ); 665 665 666 // All three 666 // All three. 667 667 $found = $q->build_time_query( 'post_date', 'NOT BETWEEN', array( 1, 2 ), array( 3, 4 ), array( 6, 7 ) ); 668 668 $this->assertSame( 'HOUR( post_date ) NOT BETWEEN 1 AND 2 AND MINUTE( post_date ) NOT BETWEEN 3 AND 4 AND SECOND( post_date ) NOT BETWEEN 6 AND 7', $found ); … … 704 704 705 705 // $compare value is floating point - use regex to account for 706 // varying precision on different PHP installations 706 // varying precision on different PHP installations. 707 707 $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) ); 708 708 } … … 715 715 716 716 // $compare value is floating point - use regex to account for 717 // varying precision on different PHP installations 717 // varying precision on different PHP installations. 718 718 $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); 719 719 } … … 726 726 727 727 // $compare value is floating point - use regex to account for 728 // varying precision on different PHP installations 728 // varying precision on different PHP installations. 729 729 $this->assertRegExp( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); 730 730 }
Note: See TracChangeset
for help on using the changeset viewer.