-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test coverage to handler and return sequence classes #219
Add test coverage to handler and return sequence classes #219
Conversation
*/ | ||
public static function handleFunction(string $functionName, array $args = []) | ||
{ | ||
if (self::handlerExists($functionName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about using stattic::
instead of self::
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually just moved this class from its original into a namespace and did not alter its contents
php/WP_Mock/Functions/Handler.php
Outdated
throw $exception; | ||
} | ||
|
||
$result = ob_get_clean() ?: ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you expect the buttfer to be closed at anytime while handling the function? I see the catched expception get thrown right after ending/closing the buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the exception is caught but then thrown again before closing the buffer output
when not thrown, the buffer is captured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't need the ?: ''
in this case right?
$result = ob_get_clean() ?: ''; | |
$result = ob_get_clean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
71c133d we can, and maybe it's a good idea to throw an exception if ob_get_clean
returns false (not a string)
note for reviewers: as for this moment there are some GitHub issues also reported in https://www.githubstatus.com/ where some PR functions in GH are degraded - I'm pushing commits to this PR and they appear to hold in git (via CLI) but they don't show up in this PR and in the GH workflow - you may be able however to |
Summary
Adds test coverage for the
Handler
andReturnSequence
classes.These classes were refactored and moved into the
WP_Mock/Functions
namespace.Even though these methods are internal, it's a minor API break. However, we are considering to tag v1.0.0 soon so it should be acceptable.
The only change is for devs implementing their own function mocks outside of
WP_Mock::userFunction()
etc. by directly calling\WP_Mock\Functions\Handler::handleFunction(__FUNCTION__, func_get_args());
-- this is documented in the docs.Details
Note: this depends on #216 to be merged first.Contributor checklist
Testing
Reviewer checklist