[wp-trac] [WordPress Trac] #14994: Introduce a way to identify a hook in progress
WordPress Trac
noreply at wordpress.org
Fri Jan 31 21:00:57 UTC 2014
#14994: Introduce a way to identify a hook in progress
---------------------------------------------+------------------
Reporter: nacin | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.9
Component: Plugins | Version:
Severity: normal | Resolution:
Keywords: has-patch commit has-unit-tests | Focuses:
---------------------------------------------+------------------
Changes (by ericmann):
* keywords: has-patch commit => has-patch commit has-unit-tests
Comment:
> If you insist on getting unit tests for this, at least mandate proper
tests that actually use the relevant WP API, instead of sidestepping it
and populating an array in case the internals change
No. Unit tests are functions that test the smallest unit of work in a
program - in this case the actual functions being added by the ticket.
The relevant API you want tested, in the way you want it tested, would be
an integration tests - some WP tests are integration tests, some are unit
tests, so I can understand the confusion.
To make things a little bit cleaner here, I've modified the original
function calls to reference `current_filter()` and `current_action()`
instead of a global variable. This way, if the internals of the
`current_*()` methods change, it's a cleaner cut.
But mocking the internal behavior of these functions - that depend on a
global array - is still necessary, so manually populating the global, even
if the function we're testing no longer directly depends on it, is still
the way to test the functions themselves and not the entire action/filter
API.
I have no problem pointing out that this is proper encapsulation of the
proposed functionality (i.e. "separation of concerns" =>
http://en.wikipedia.org/wiki/Separation_of_concerns separation of
concerns), something WP could use a lot more of.
If there are problems with the tests themselves or the patch as a whole,
let's discuss.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/14994#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list