From 64917465590c0b1b8e960b270a682632fa55bcc5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 22 May 2019 17:52:22 +0000 Subject: [PATCH] Date/Time: Use strict comparison in `is_new_day()`, add a unit test. Props pbearne. Fixes #46627. git-svn-id: https://develop.svn.wordpress.org/trunk@45375 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 3 +- tests/phpunit/tests/functions/isNewDay.php | 36 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/functions/isNewDay.php diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index c6542d62d9..ce45499d0c 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -797,7 +797,8 @@ function wp_get_http_headers( $url, $deprecated = false ) { */ function is_new_day() { global $currentday, $previousday; - if ( $currentday != $previousday ) { + + if ( $currentday !== $previousday ) { return 1; } else { return 0; diff --git a/tests/phpunit/tests/functions/isNewDay.php b/tests/phpunit/tests/functions/isNewDay.php new file mode 100644 index 0000000000..629a6d3de5 --- /dev/null +++ b/tests/phpunit/tests/functions/isNewDay.php @@ -0,0 +1,36 @@ +assertSame( $expected, is_new_day() ); + } + + public function _data_is_new_date() { + return array( + array( '21.05.19', '21.05.19', 0 ), + array( '21.05.19', '20.05.19', 1 ), + array( '21.05.19', false, 1 ), + ); + } + +}