#33867 closed enhancement (fixed)
Unit tests to protect against breaking pluggable function changes
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch |
Focuses: | Cc: |
Description
In [33023] and [33620], the parameters of the pluggable wp_new_user_notification()
function were changed, which caused breakage. See #33654.
We can introduce unit tests which protect us against this by using reflection to compare the functions in pluggable.php against an array of expected signatures (well, parameter names and default values at least). That way, if a pluggable function's parameters are changed, the unit tests will fail.
It's not fool-proof (a parameter can be re-purposed without having its name or default value changed), but it gets us a long way.
Attachments (2)
Change History (11)
#2
@
9 years ago
- Summary changed from Unit tests to protected against breaking pluggable function changes to Unit tests to protect against breaking pluggable function changes
#3
in reply to:
↑ 1
@
9 years ago
This is a great idea John, thanks!.
I tested locally and verified the test fail when i changed a pluggable function parameter signature.
What do you think about adding @group pluggable to the header? I added this to help me run just these tests and notice we already have some tests in this group. Added in 33867.2.patch.
Replying to johnbillion:
Any of the following changes will cause the tests in 33867.patch to fail:
- Renaming a pluggable function parameter.
- Changing, adding, or removing the default value of a pluggable function parameter.
- Deleting a pluggable function, or moving it outside of pluggable.php.
- Adding a new pluggable function.
Any of the following changes will cause the tests in 33867.patch to fail: