From 1d62e1f2fbcf7b7faaf8300d36102425cb0bb1cc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 23 May 2022 14:07:47 +0000 Subject: [PATCH] Tests: Improve the assertions in recommended MySQL and MariaDB version tests. Comparing human-readable dates instead of numeric timestamps gives identical results, but makes the message more clear in case of failure. Follow-up to [33946], [52418], [52421], [52424]. See #55791, #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53433 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/external-http/basic.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/external-http/basic.php b/tests/phpunit/tests/external-http/basic.php index e34f4841ba..bb7415b2af 100644 --- a/tests/phpunit/tests/external-http/basic.php +++ b/tests/phpunit/tests/external-http/basic.php @@ -52,9 +52,10 @@ class Tests_External_HTTP_Basic extends WP_UnitTestCase { * * TODO: Reduce this back to 5 years once MySQL 8.0 compatibility is achieved. */ - $mysql_eol = strtotime( $mysql_matches[1] . ' +8 years' ); + $mysql_eol = gmdate( 'Y-m-d', strtotime( $mysql_matches[1] . ' +8 years' ) ); + $current_date = gmdate( 'Y-m-d' ); - $this->assertLessThan( $mysql_eol, time(), "readme.html's Recommended MySQL version is too old. Remember to update the WordPress.org Requirements page, too." ); + $this->assertLessThan( $mysql_eol, $current_date, "readme.html's Recommended MySQL version is too old. Remember to update the WordPress.org Requirements page, too." ); } /** @@ -84,9 +85,10 @@ class Tests_External_HTTP_Basic extends WP_UnitTestCase { preg_match( '#.*Stable.*?(\d{2} [A-Za-z]{3} \d{4})#s', $response_body, $mariadb_matches ); // Per https://mariadb.org/about/#maintenance-policy, MariaDB releases are supported for 5 years. - $mariadb_eol = strtotime( $mariadb_matches[1] . ' +5 years' ); + $mariadb_eol = gmdate( 'Y-m-d', strtotime( $mariadb_matches[1] . ' +5 years' ) ); + $current_date = gmdate( 'Y-m-d' ); - $this->assertLessThan( $mariadb_eol, time(), "readme.html's Recommended MariaDB version is too old. Remember to update the WordPress.org Requirements page, too." ); + $this->assertLessThan( $mariadb_eol, $current_date, "readme.html's Recommended MariaDB version is too old. Remember to update the WordPress.org Requirements page, too." ); } /**