diff --git a/tests/phpunit/tests/functions/WpMysqlWeek.php b/tests/phpunit/tests/functions/WpMysqlWeek.php new file mode 100644 index 0000000000000..7fc33fa30060f --- /dev/null +++ b/tests/phpunit/tests/functions/WpMysqlWeek.php @@ -0,0 +1,44 @@ +assertSame( $expected_sql, _wp_mysql_week( 'col_name' ) ); + } + + /** + * @return array[] + */ + public function data_test_wp_mysql_week() { + return array( + array( '1969-12-25', 0, 'WEEK( col_name, 0 )' ), + array( '1969-12-25', 1, 'WEEK( col_name, 1 )' ), + array( '1969-12-25', 2, 'WEEK( DATE_SUB( col_name, INTERVAL 2 DAY ), 0 )' ), + array( '1969-12-25', 3, 'WEEK( DATE_SUB( col_name, INTERVAL 3 DAY ), 0 )' ), + array( '1969-12-25', 4, 'WEEK( DATE_SUB( col_name, INTERVAL 4 DAY ), 0 )' ), + array( '1969-12-25', 5, 'WEEK( DATE_SUB( col_name, INTERVAL 5 DAY ), 0 )' ), + array( '1969-12-25', 6, 'WEEK( DATE_SUB( col_name, INTERVAL 6 DAY ), 0 )' ), + array( '1969-12-25', 9, 'WEEK( col_name, 0 )' ), + ); + } +}