PrintingFunctionsTrait::is_printing_function(): add tests#2716
PrintingFunctionsTrait::is_printing_function(): add tests#2716rodrigoprimo wants to merge 1 commit intoWordPress:developfrom
Conversation
jrfnl
left a comment
There was a problem hiding this comment.
❌ I'm going to block this PR in its current state.
The is_printing_function() can't be considered properly tested unless the get_printing_functions() method is also tested.
So either dedicated tests for the get_printing_functions() method need to be added ahead of adding the tests for the is_printing_function() method; or the is_printing_function() tests need to be expanded to include covering what happens in get_printing_functions() (which I believe would be the wrong choice).
Adding tests only for is_printing_function() without having tests for get_printing_functions() is misleading and incomplete.
As a side-note regarding the test setup:
I understand what you are trying to do, but why did you choose this way to do it ?
I mean, why not just use PrintingFunctionsTrait; in the test class ? (which would also give the tests access to the private properties if needed).
|
Thanks for the review, Juliette.
Regarding testing
Regarding the test setup, I opted for the anonymous class approach to keep a clear separation between the test subject and the test class. Using I can see that the anonymous class approach adds boilerplate (and in the case of the |
I already said that this PR is blocked until tests for
Understood. Thanks for sharing your reasoning.
No strong preference. I totally see the value of the separation, but I can also see the value of the simpler approach for a simple trait like this if it would make testing the trait more straight-forward (less jumping through hoops to test what needs testing). I guess for a first set of tests, I would be pragmatic (whatever works), while when iterating on it after, I would consolidate to a standardized, consistent approach based on what we then know is needed. It's difficult to standardize/make things consistent if it's not clear yet what will be needed across the board. Hope that input helps. |
Description
In preparation for supporting PHPCS 4.0, this PR adds unit tests for the
PrintingFunctionsTrait::is_printing_function()method.Suggested changelog entry
N/A