Tests: Add a helper method for for creating named data providers in `WP_UnitTestCase_Base`.
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 occur. 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 method. Typical usage of this method: {{{ public function data_provider_for_test_name() { $array = array( 'value1', 'value2', ); return $this->text_array_to_dataprovider( $array ); } }}} The returned result will look like: {{{ array( 'value1' => array( 'value1' ), 'value2' => array( 'value2' ), ) }}} Props jrf, hellofromTonya, adamsilverstein. See #55652. Built from https://develop.svn.wordpress.org/trunk@53521 git-svn-id: http://core.svn.wordpress.org/trunk@53110 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
481da1b9f4
commit
6e12ff3b89
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53520';
|
$wp_version = '6.1-alpha-53521';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue