From 3c6680b657884c83ff93ae668180cf2ee202d295 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Tue, 19 Dec 2023 23:11:11 +0000 Subject: [PATCH] Build/Test: Add Tests for _wp_mysql_week. Props pbearne. Fixes #59931. git-svn-id: https://develop.svn.wordpress.org/trunk@57207 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions/WpMysqlWeek.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/phpunit/tests/functions/WpMysqlWeek.php 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 )' ), + ); + } +}