Make WordPress Core

Changeset 51852

Timestamp:
09/22/2021 11:05:59 PM (3 years ago)
Author:
hellofromTonya
Message:

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.

Location:
trunk/tests/phpunit/tests
Files:
7 added
1 deleted

Note: See TracChangeset for help on using the changeset viewer.