Make WordPress Core

Changeset 64088


Ignore:
Timestamp:
10/04/2026 07:54:09 PM (18 hours ago)
Author:
lancewillett
Message:

Tests: Make Abilities API test data providers static.

Declare five data providers as public static for compatibility with newer PHPUnit versions. Use an anonymous object for the instance-method callback dataset so it no longer depends on $this, preserving coverage of object-method callables.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13975

Props huzaifaalmesbah.
See #66211.

Location:
trunk/tests/phpunit/tests/abilities-api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/abilities-api/wpAbility.php

    r62737 r64088  
    387387         * @return array<string, array{0: array, 1: callable, 2: mixed, 3: mixed}> Data sets with different configurations.
    388388         */
    389         public function data_execute_input() {
     389        public static function data_execute_input() {
    390390                return array(
    391391                        'null input'    => array(
    … …  
    525525         * @return array<string, array{0: array, 1: mixed, 2: bool}> Data sets.
    526526         */
    527         public function data_validate_input_top_level_required() {
     527        public static function data_validate_input_top_level_required() {
    528528                $required_true   = array(
    529529                        'type'     => 'string',
    … …  
    635635         * @return array<string, array{0: callable}> Data sets with different execute callbacks.
    636636         */
    637         public function data_execute_callback() {
     637        public static function data_execute_callback() {
    638638                return array(
    639639                        'function name string'       => array(
    … …  
    652652                        ),
    653653                        'object method'              => array(
    654                                 array( $this, 'my_instance_execute_callback' ),
     654                                array(
     655                                        new class() {
     656                                                public function my_instance_execute_callback( string $input ): int {
     657                                                        return strlen( $input );
     658                                                }
     659                                        },
     660                                        'my_instance_execute_callback',
     661                                ),
    655662                        ),
    656663                );
  • trunk/tests/phpunit/tests/abilities-api/wpAbilityCategoryRegistry.php

    r61032 r64088  
    395395         * @return array<int, array<string>> Valid ability category slugs.
    396396         */
    397         public function data_valid_slug_provider(): array {
     397        public static function data_valid_slug_provider(): array {
    398398                return array(
    399399                        array( 'test-simple' ),
    … …  
    431431         * @return array<int, array<string>> Invalid ability category slugs.
    432432         */
    433         public function data_invalid_slug_provider(): array {
     433        public static function data_invalid_slug_provider(): array {
    434434                return array(
    435435                        array( 'Test-Uppercase' ),
Note: See TracChangeset for help on using the changeset viewer.