From 546114eca839a0d9b23073c2b523ceb2fb0417f4 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 3 May 2022 18:55:45 +0000 Subject: [PATCH] Build/Test Tools: Ensure version number is in 'X.X' format after float math: `Tests_Basic::test_security_md()`. After subtracing `0.1` from a `X.1` current version, the result was a single digit without the `.0` decimal. Using `number_format()` ensures each current version has a decimal before appending the `.x` before the test. This commit also reverts [55346] which was a temporary workaround. Follow-up to [55346], [47403]. Fixes #55667. git-svn-id: https://develop.svn.wordpress.org/trunk@53347 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/basic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/basic.php b/tests/phpunit/tests/basic.php index 51b0c78519..05fdbeaf29 100644 --- a/tests/phpunit/tests/basic.php +++ b/tests/phpunit/tests/basic.php @@ -24,8 +24,8 @@ class Tests_Basic extends WP_UnitTestCase { $security = file_get_contents( dirname( ABSPATH ) . '/SECURITY.md' ); preg_match( '#\d.\d.x#', $security, $matches ); $current_version = substr( $GLOBALS['wp_version'], 0, 3 ); - $latest_stable = sprintf( '%s.x', (float) $current_version - 0.1 ); - // $this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." ); + $latest_stable = number_format( (float) $current_version - 0.1, 1 ) . '.x'; + $this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." ); } public function test_package_json() {