[wp-trac] [WordPress Trac] #55652: Test tool and unit test improvements for 6.1

WordPress Trac noreply at wordpress.org
Sat Jun 18 21:28:53 UTC 2022

#55652: Test tool and unit test improvements for 6.1
 Reporter:  hellofromTonya            |       Owner:  (none)
     Type:  task (blessed)            |      Status:  new
 Priority:  normal                    |   Milestone:  6.1
Component:  Build/Test Tools          |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:

Comment (by SergeyBiryukov):

 In [changeset:"53521" 53521]:
 #!CommitTicketReference repository="" revision="53521"
 Tests: Add a helper method for for creating named data providers in

 This introduces a new test helper function which allows for turning a
 single-level array containing text strings into a data provider with named
 data sets, where the value of the data set will also be used as the name
 of the data set.

 The function contains safeguards to ensure that it is only used with data
 compatible with this principle and will throw generic PHP exceptions when
 the data is incompatible. These type of exceptions will be displayed
 before the tests even start running and will stop the test run when they

 While generally speaking, all test cases ''should'' extend the base
 `WP_UnitTestCase_Base` class, this is still made a `public static` method
 to allow for a test, which by exception directly extends the PHPUnit base
 `TestCase` or the `PHPUnit_Adapter_TestCase`, to also be able to use this

 Typical usage of this method:
 public function data_provider_for_test_name() {
         $array = array(

         return $this->text_array_to_dataprovider( $array );
 The returned result will look like:
         'value1' => array( 'value1' ),
         'value2' => array( 'value2' ),

 Props jrf, hellofromTonya, adamsilverstein.
 See #55652.

Ticket URL: <https://core.trac.wordpress.org/ticket/55652#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list