Commit e59d0c2e90f for woocommerce
commit e59d0c2e90f072ba0b483817427db446fc95fe29
Author: Valery Sukhomlinov <683297+dmvrtx@users.noreply.github.com>
Date: Tue Sep 15 15:49:45 2026 +0200
Remove PHP8.1 skips in tests and outdated shim (#68563)
Purely technical changes in the test harness:
- Removed outdated `skip_on_php_8_1()` check that prevented several tests from running for some time, as `wp-env` was pinned to PHP8.1 for more than 1 year.
- Removed the `assertIsInteger` shim, which was required for PHPUnit < 8.0, and we use 9.6.
diff --git a/plugins/woocommerce/changelog/wooplug-7695-remove-php-81-and-phpunit-test-skips-that-hide-8-tests b/plugins/woocommerce/changelog/wooplug-7695-remove-php-81-and-phpunit-test-skips-that-hide-8-tests
new file mode 100644
index 00000000000..6979aa0272d
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-7695-remove-php-81-and-phpunit-test-skips-that-hide-8-tests
@@ -0,0 +1,4 @@
+Significance: minor
+Type: dev
+
+Remove outdated shims and skips from the test suites.
diff --git a/plugins/woocommerce/tests/legacy/framework/class-wc-unit-test-case.php b/plugins/woocommerce/tests/legacy/framework/class-wc-unit-test-case.php
index a7f78efc52a..edb13bcbd9f 100644
--- a/plugins/woocommerce/tests/legacy/framework/class-wc-unit-test-case.php
+++ b/plugins/woocommerce/tests/legacy/framework/class-wc-unit-test-case.php
@@ -574,28 +574,6 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
return $output;
}
- /**
- * Asserts that a variable is of type int.
- * TODO: After upgrading to PHPUnit 8 or newer, remove this method and replace calls with PHPUnit's built-in 'assertIsInt'.
- *
- * @param mixed $actual The value to check.
- * @param mixed $message Error message to use if the assertion fails.
- * @return bool mixed True if the value is of integer type, false otherwise.
- */
- public static function assertIsInteger( $actual, $message = '' ) {
- return self::assertIsInt( $actual, $message );
- }
-
- /**
- * Skip the current test on PHP 8.1 and higher.
- * TODO: Remove this method and its usages once WordPress is compatible with PHP 8.1. Please note that there are multiple copies of this method.
- */
- protected function skip_on_php_8_1() {
- if ( version_compare( PHP_VERSION, '8.1', '>=' ) ) {
- $this->markTestSkipped( 'Waiting for WordPress compatibility with PHP 8.1' );
- }
- }
-
/**
* Get recorded tracks event by name.
*
diff --git a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
index 0ac4bb79624..21873d81183 100644
--- a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
+++ b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
@@ -91,7 +91,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_returns_root_properties() {
- $this->skip_on_php_8_1();
$system_status_data = $this->fetch_or_get_system_status_data_for_user( self::$administrator_user );
$this->assertArrayHasKey( 'environment', $system_status_data );
$this->assertArrayHasKey( 'database', $system_status_data );
@@ -108,8 +107,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_environment() {
- $this->skip_on_php_8_1();
-
$store_id = get_option( \WC_Install::STORE_ID_OPTION, null );
if ( empty( $store_id ) ) {
$store_id = 'a1b2c3d4-e5f6-a1b2-c3d4-a1b2c3d4e5f6';
@@ -136,8 +133,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_database() {
- $this->skip_on_php_8_1();
-
global $wpdb;
$database = (array) $this->fetch_or_get_system_status_data_for_user( self::$administrator_user )['database'];
@@ -189,7 +184,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_theme() {
- $this->skip_on_php_8_1();
$active_theme = wp_get_theme();
$theme = (array) $this->fetch_or_get_system_status_data_for_user( self::$administrator_user )['theme'];
@@ -204,8 +198,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_settings() {
- $this->skip_on_php_8_1();
-
$term_response = array();
$terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
foreach ( $terms as $term ) {
@@ -226,8 +218,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_security() {
- $this->skip_on_php_8_1();
-
$settings = (array) $this->fetch_or_get_system_status_data_for_user( self::$administrator_user )['security'];
$this->assertEquals( 2, count( $settings ) );
@@ -241,8 +231,6 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
* @since 3.0.0
*/
public function test_get_system_status_info_pages() {
- $this->skip_on_php_8_1();
-
$pages = $this->fetch_or_get_system_status_data_for_user( self::$administrator_user )['pages'];
$this->assertEquals( 5, count( $pages ) );
}
diff --git a/plugins/woocommerce/tests/php/includes/class-wc-ajax-test.php b/plugins/woocommerce/tests/php/includes/class-wc-ajax-test.php
index c2b5a11fd42..52e47c2c948 100644
--- a/plugins/woocommerce/tests/php/includes/class-wc-ajax-test.php
+++ b/plugins/woocommerce/tests/php/includes/class-wc-ajax-test.php
@@ -110,8 +110,6 @@ class WC_AJAX_Test extends \WP_Ajax_UnitTestCase {
* Creating an API Key with too long of a description should report failure.
*/
public function test_create_api_key_long_description_failure() {
- $this->skip_on_php_8_1();
-
$this->_setRole( 'administrator' );
$description = 'This_description_is_really_very_long_and_is_meant_to_exceed_the_database_column_length_of_200_characters_';
@@ -143,16 +141,6 @@ class WC_AJAX_Test extends \WP_Ajax_UnitTestCase {
$this->assertEquals( $response['data']['message'], 'There was an error generating your API Key.' );
}
- /**
- * Skip the current test on PHP 8.1 and higher.
- * TODO: Remove this method and its usages once WordPress is compatible with PHP 8.1. Please note that there are multiple copies of this method.
- */
- protected function skip_on_php_8_1() {
- if ( version_compare( PHP_VERSION, '8.1', '>=' ) ) {
- $this->markTestSkipped( 'Waiting for WordPress compatibility with PHP 8.1' );
- }
- }
-
/**
* Test to verify that term color is saved in AJAX calls, but only for terms belonging to a visual attribute.
*
diff --git a/plugins/woocommerce/tests/php/includes/wc-stock-functions-tests.php b/plugins/woocommerce/tests/php/includes/wc-stock-functions-tests.php
index c05b122c787..2704cea10b1 100644
--- a/plugins/woocommerce/tests/php/includes/wc-stock-functions-tests.php
+++ b/plugins/woocommerce/tests/php/includes/wc-stock-functions-tests.php
@@ -349,7 +349,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
*/
private function assertIsIntAndEquals( $expected, $actual ) {
$this->assertEquals( $expected, $actual );
- self::assertIsInteger( $actual );
+ self::assertIsInt( $actual );
}
/**
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsProvidersTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsProvidersTest.php
index b9d5148d3cd..a1b6cbd5cdc 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsProvidersTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsProvidersTest.php
@@ -1534,7 +1534,7 @@ class PaymentsProvidersTest extends WC_Unit_Test_Case {
$this->assertArrayHasKey( 'id', $pref_suggestion, 'Suggestion `id` entry is missing' );
$this->assertSame( 'suggestion1', $pref_suggestion['id'] );
$this->assertArrayHasKey( '_priority', $pref_suggestion, 'Suggestion `_priority` entry is missing' );
- $this->assertIsInteger( $pref_suggestion['_priority'], 'Suggestion `_priority` entry is not an integer' );
+ $this->assertIsInt( $pref_suggestion['_priority'], 'Suggestion `_priority` entry is not an integer' );
$this->assertSame( 1, $pref_suggestion['_priority'] );
$this->assertArrayHasKey( '_type', $pref_suggestion, 'Suggestion `_type` entry is missing' );
$this->assertSame( ExtensionSuggestions::TYPE_PSP, $pref_suggestion['_type'] );
@@ -1565,7 +1565,7 @@ class PaymentsProvidersTest extends WC_Unit_Test_Case {
$this->assertArrayHasKey( 'id', $other_suggestion, 'Suggestion `id` entry is missing' );
$this->assertSame( 'suggestion5', $other_suggestion['id'] );
$this->assertArrayHasKey( '_priority', $other_suggestion, 'Suggestion `_priority` entry is missing' );
- $this->assertIsInteger( $other_suggestion['_priority'], 'Suggestion `_priority` entry is not an integer' );
+ $this->assertIsInt( $other_suggestion['_priority'], 'Suggestion `_priority` entry is not an integer' );
$this->assertSame( 5, $other_suggestion['_priority'] );
$this->assertArrayHasKey( '_type', $other_suggestion, 'Suggestion `_type` entry is missing' );
$this->assertSame( ExtensionSuggestions::TYPE_PSP, $other_suggestion['_type'] );
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsRestControllerTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsRestControllerTest.php
index ead71daa19b..729d110c1de 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsRestControllerTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsRestControllerTest.php
@@ -251,7 +251,7 @@ class PaymentsRestControllerTest extends WC_Unit_Test_Case {
foreach ( $data['suggestions'] as $suggestion ) {
$this->assertArrayHasKey( 'id', $suggestion, 'Suggestion `id` entry is missing' );
$this->assertArrayHasKey( '_priority', $suggestion, 'Suggestion `_priority` entry is missing' );
- $this->assertIsInteger( $suggestion['_priority'], 'Suggestion `_priority` entry is not an integer' );
+ $this->assertIsInt( $suggestion['_priority'], 'Suggestion `_priority` entry is not an integer' );
$this->assertArrayHasKey( '_type', $suggestion, 'Suggestion `_type` entry is missing' );
$this->assertArrayHasKey( 'title', $suggestion, 'Suggestion `title` entry is missing' );
$this->assertArrayHasKey( 'description', $suggestion, 'Suggestion `description` entry is missing' );
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsTest.php
index 859bde26b11..b4e6c1af8ae 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsTest.php
@@ -207,7 +207,7 @@ class PaymentsTest extends WC_Unit_Test_Case {
$this->assertArrayHasKey( 'id', $group, 'Group `id` entry is missing' );
$this->assertEquals( PaymentsProviders::OFFLINE_METHODS_ORDERING_GROUP, $group['id'] );
$this->assertArrayHasKey( '_order', $group, 'Group `_order` entry is missing' );
- $this->assertIsInteger( $group['_order'], 'Group `_order` entry is not an integer' );
+ $this->assertIsInt( $group['_order'], 'Group `_order` entry is not an integer' );
$this->assertArrayHasKey( '_type', $group, 'Group `_type` entry is missing' );
$this->assertEquals( PaymentsProviders::TYPE_OFFLINE_PMS_GROUP, $group['_type'], 'Group `_type` entry is not `' . PaymentsProviders::TYPE_OFFLINE_PMS_GROUP . '`' );
$this->assertArrayHasKey( 'title', $group, 'Group `title` entry is missing' );
@@ -385,7 +385,7 @@ class PaymentsTest extends WC_Unit_Test_Case {
$this->assertEquals( PaymentsProviders::SUGGESTION_ORDERING_PREFIX . 'suggestion1', $suggestion1['id'] );
$this->assertEquals( 'suggestion1', $suggestion1['_suggestion_id'] );
$this->assertArrayHasKey( '_order', $suggestion1, 'Provider `_order` entry is missing' );
- $this->assertIsInteger( $suggestion1['_order'], 'Provider `_order` entry is not an integer' );
+ $this->assertIsInt( $suggestion1['_order'], 'Provider `_order` entry is not an integer' );
$this->assertEquals( 0, $suggestion1['_order'] );
$this->assertArrayHasKey( '_type', $suggestion1, 'Provider `_type` entry is missing' );
$this->assertEquals( PaymentsProviders::TYPE_SUGGESTION, $suggestion1['_type'] );
diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php
index 8e2097d4a28..ad4decc7ad4 100644
--- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php
+++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php
@@ -385,7 +385,7 @@ class OrdersTableDataStoreTests extends \HposTestCase {
$order = $this->create_complex_cot_order();
$order_id = $order->get_id();
- $this->assertIsInteger( $order_id );
+ $this->assertIsInt( $order_id );
$this->assertLessThan( $order_id, 0 );
wp_cache_flush();