From 16c1da1062dea9357c056990620096224378a121 Mon Sep 17 00:00:00 2001 From: rvpatel Date: Thu, 22 Oct 2026 00:43:41 +0530 Subject: [PATCH] Tests: Make Secrets API test data providers static. PHPUnit 10 deprecates data providers that are not public and static, and PHPUnit 11 removes support for them. None of these providers use `$this`, so only the `static` keyword is added. See #66211. --- tests/phpunit/tests/secrets/capabilities.php | 2 +- tests/phpunit/tests/secrets/errorCodes.php | 2 +- tests/phpunit/tests/secrets/wpSecret.php | 4 ++-- tests/phpunit/tests/secrets/wpSecretsCipher.php | 8 ++++---- .../phpunit/tests/secrets/wpSecretsConfigKeyProvider.php | 4 ++-- tests/phpunit/tests/secrets/wpSecretsKeyManager.php | 2 +- tests/phpunit/tests/secrets/wpSecretsValidateName.php | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/tests/secrets/capabilities.php b/tests/phpunit/tests/secrets/capabilities.php index d0dc26a52e70f..5298809144594 100644 --- a/tests/phpunit/tests/secrets/capabilities.php +++ b/tests/phpunit/tests/secrets/capabilities.php @@ -89,7 +89,7 @@ public function test_upgrade_720_grants_manage_secrets_below_its_db_version( $db * * @return array */ - public function data_upgrade_720_gate() { + public static function data_upgrade_720_gate() { return array( 'upgrading from 7.0' => array( 61644, true ), 'upgrading from just below 7.2' => array( 64336, true ), diff --git a/tests/phpunit/tests/secrets/errorCodes.php b/tests/phpunit/tests/secrets/errorCodes.php index 9d5dc6f0e9ce4..c2ad48c597b09 100644 --- a/tests/phpunit/tests/secrets/errorCodes.php +++ b/tests/phpunit/tests/secrets/errorCodes.php @@ -20,7 +20,7 @@ public function test_error_code_values_match_the_published_contract( $constant, /** * @return array */ - public function data_published_error_codes() { + public static function data_published_error_codes() { return array( 'decryption failed' => array( 'WP_SECRETS_ERROR_DECRYPTION_FAILED', 'secret_decryption_failed' ), 'key unavailable' => array( 'WP_SECRETS_ERROR_KEY_UNAVAILABLE', 'secret_key_unavailable' ), diff --git a/tests/phpunit/tests/secrets/wpSecret.php b/tests/phpunit/tests/secrets/wpSecret.php index 2418044531fab..68c84441ebfa2 100644 --- a/tests/phpunit/tests/secrets/wpSecret.php +++ b/tests/phpunit/tests/secrets/wpSecret.php @@ -90,7 +90,7 @@ public function test_masking_surfaces_never_contain_the_plaintext( $callback ): /** * @return array */ - public function data_masking_surfaces() { + public static function data_masking_surfaces() { return array( '(string) cast' => array( function ( WP_Secret $secret ) { @@ -205,7 +205,7 @@ public function test_serialization_magic_methods_throw_directly( $method, $args /** * @return array}> */ - public function data_refusing_magic_methods() { + public static function data_refusing_magic_methods() { return array( '__sleep' => array( '__sleep', array() ), '__wakeup' => array( '__wakeup', array() ), diff --git a/tests/phpunit/tests/secrets/wpSecretsCipher.php b/tests/phpunit/tests/secrets/wpSecretsCipher.php index 63b8eec0a0bc3..ec7b1f9d7e28d 100644 --- a/tests/phpunit/tests/secrets/wpSecretsCipher.php +++ b/tests/phpunit/tests/secrets/wpSecretsCipher.php @@ -90,7 +90,7 @@ public function test_encrypt_rejects_a_bad_master_key( $bad_key ): void { /** * @return array */ - public function data_bad_master_keys() { + public static function data_bad_master_keys() { return array( 'too short' => array( str_repeat( 'a', 31 ) ), 'too long' => array( str_repeat( 'a', 33 ) ), @@ -167,7 +167,7 @@ public function test_decrypt_fails_when_context_does_not_match( $scope, $site_id /** * @return array */ - public function data_mismatched_context() { + public static function data_mismatched_context() { return array( 'different scope' => array( 'network', 1, self::NAME, WP_Secret_Version::CURRENT ), 'different site id' => array( 'site', 2, self::NAME, WP_Secret_Version::CURRENT ), @@ -214,7 +214,7 @@ public function test_decrypt_fails_when_a_field_is_tampered( $field ): void { /** * @return array */ - public function data_tamperable_fields() { + public static function data_tamperable_fields() { return array( 'ciphertext' => array( 'ct' ), 'value nonce' => array( 'nonce' ), @@ -240,7 +240,7 @@ public function test_decrypt_rejects_a_malformed_record( $record ): void { /** * @return array */ - public function data_malformed_records() { + public static function data_malformed_records() { return array( 'not an array' => array( 'just a string' ), 'missing ct' => array( diff --git a/tests/phpunit/tests/secrets/wpSecretsConfigKeyProvider.php b/tests/phpunit/tests/secrets/wpSecretsConfigKeyProvider.php index b19a9941ef049..b14d19549cb0e 100644 --- a/tests/phpunit/tests/secrets/wpSecretsConfigKeyProvider.php +++ b/tests/phpunit/tests/secrets/wpSecretsConfigKeyProvider.php @@ -131,7 +131,7 @@ public function test_is_canonical_base64_32( $value, $expected ): void { /** * @return array */ - public function data_canonical_base64_32(): array { + public static function data_canonical_base64_32(): array { return array( 'exactly 32 bytes, canonical encoding' => array( base64_encode( str_repeat( 'A', 32 ) ), true ), '31 bytes' => array( base64_encode( str_repeat( 'A', 31 ) ), false ), @@ -159,7 +159,7 @@ public function test_are_usable_salt_values( $key, $salt, $expected ): void { /** * @return array */ - public function data_usable_salt_values(): array { + public static function data_usable_salt_values(): array { return array( 'both usable' => array( 'a real key', 'a real salt', true ), 'key is the placeholder' => array( 'put your unique phrase here', 'a real salt', false ), diff --git a/tests/phpunit/tests/secrets/wpSecretsKeyManager.php b/tests/phpunit/tests/secrets/wpSecretsKeyManager.php index a42f6078bd435..501cba32c0d83 100644 --- a/tests/phpunit/tests/secrets/wpSecretsKeyManager.php +++ b/tests/phpunit/tests/secrets/wpSecretsKeyManager.php @@ -121,7 +121,7 @@ public function test_get_master_key_reports_an_invalid_site_id_as_a_wp_error( $s /** * @return array */ - public function data_invalid_site_ids(): array { + public static function data_invalid_site_ids(): array { return array( 'zero' => array( 0 ), 'negative' => array( -1 ), diff --git a/tests/phpunit/tests/secrets/wpSecretsValidateName.php b/tests/phpunit/tests/secrets/wpSecretsValidateName.php index 0e097a8ccd000..7555552d39674 100644 --- a/tests/phpunit/tests/secrets/wpSecretsValidateName.php +++ b/tests/phpunit/tests/secrets/wpSecretsValidateName.php @@ -16,7 +16,7 @@ public function test_accepts_valid_names( $name ): void { /** * @return array */ - public function data_valid_names(): array { + public static function data_valid_names(): array { return array( 'simple' => array( 'myplugin/api-key' ), 'single character segments' => array( 'a/b' ), @@ -60,7 +60,7 @@ public function test_accepts_an_unnamespaced_name_but_reports_it( $name ): void /** * @return array */ - public function data_unnamespaced_names(): array { + public static function data_unnamespaced_names(): array { return array( 'simple' => array( 'api_key' ), 'with hyphen' => array( 'api-key' ), @@ -84,7 +84,7 @@ public function test_an_unnamespaced_name_still_obeys_the_character_rules(): voi /** * @return array */ - public function data_invalid_names(): array { + public static function data_invalid_names(): array { return array( 'empty string' => array( '' ), 'two slashes' => array( 'too/many/slashes' ),