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

WordPress Trac noreply at wordpress.org
Wed Sep 22 23:06:15 UTC 2021


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

Comment (by hellofromTonya):

 In [changeset:"51852" 51852]:
 {{{
 #!CommitTicketReference repository="" revision="51852"
 Build/Test Tools: Splits and improves `compat` tests.

 Splits the tests in the `tests/phpunit/tests/compat.php` file up into
 individual test classes for each function being tested.

 Improvements to individual test cases:
 * Adds `@covers` tags.
 * Adds visibility modifiers to all methods.
 * Adds function availability test.
 * Where relevant, fixes the assertion parameter order.
 * Data provider:
    * Where relevant, reworks a test to use a data provider.
    * Where relevant, renames data provider methods to have a more obvious
 link to the test it applies to.
    * Makes the data provider more readable by adding keys within the data
 sets.
    * Moves the data provider below its associated tests.
    * Adds/removes data sets in data providers.
 * Makes the actual test code more readable by using descriptive variables
 and multi-line function calls.
 * Adds the `$message` parameter to all assertions when a test method
 contains more than one assertion.

 Specifically for the `_mb_substr()` tests:
 * Splits the `test_mb_substr_phpcore()` method into two test methods based
 on the PHP Core test files they are emulating.
 * Makes the actual test code within the `test_mb_substr_phpcore_basic()`
 method more readable by using descriptive variables and multi-line
 function calls.
 * Splits the data used for the second part of the
 `test_mb_substr_phpcore()` function, now
 `test_mb_substr_phpcore_input_type_handling()`, off into a separate data
 provider with named data sets.
 * Removes duplicate data sets from the
 `data_mb_substr_phpcore_input_type_handling()`.
    * Why? The PHP native tests test against upper/lowercase `false`,
 `true`, `null` and some other text string single quote/double quote
 variations. As things were, those differentiations had been undone when
 the coding standards were put in place, so in effect those weren't being
 tested anymore. And as this is userland code, there's no point in adding
 these differentiations back as they will be handled the same by PHP anyway
 (and that is safeguarded via the PHP native tests).
 * Removes the "undefined variable" and "unset variable" test cases as,
 while those are relevant to the C code in which PHP is written, they are
 not relevant for testing userland code and will behave the same as the
 test passing `null`.

 Follow-to [25002], [32364], [42228], [42343], [43034], [43036], [43220],
 [43571], [45607], [47122], [47198], [48937], [48996], [51415], [51563],
 [51594].

 Props jrf, hellofromTonya.
 See #39265, #53363.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53363#comment:82>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list