Skip to content
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

Merged

Conversation

unfulvio-godaddy
Copy link
Member

@unfulvio-godaddy unfulvio-godaddy commented Jun 29, 2023

Summary

Adds test coverage for the Handler and ReturnSequence 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

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly
  • I have added tests to cover changes introduced by this pull request
  • All new and existing tests pass

Testing

Reviewer checklist

@unfulvio-godaddy unfulvio-godaddy self-assigned this Jun 29, 2023
@unfulvio-godaddy unfulvio-godaddy added the Tests Updates to tests label Jun 29, 2023
@unfulvio-godaddy unfulvio-godaddy added this to the v1.0.0 milestone Jun 29, 2023
@coveralls
Copy link

coveralls commented Jun 29, 2023

Coverage Status

coverage: 65.421% (+5.2%) from 60.188% when pulling 482a9e8 on chore/add-test-coverage-to-handler-and-return-sequence into 7934d33 on trunk.

@unfulvio-godaddy unfulvio-godaddy changed the base branch from trunk to update-dependencies June 29, 2023 04:36
@unfulvio-godaddy unfulvio-godaddy requested a review from a team June 29, 2023 04:48
@unfulvio-godaddy unfulvio-godaddy marked this pull request as ready for review June 29, 2023 04:48
Base automatically changed from update-dependencies to trunk July 5, 2023 01:44
@nmolham-godaddy nmolham-godaddy self-requested a review July 5, 2023 04:39
*/
public static function handleFunction(string $functionName, array $args = [])
{
if (self::handlerExists($functionName)) {
Copy link
Contributor

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::?

Copy link
Member Author

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

@unfulvio-godaddy unfulvio-godaddy requested review from nmolham-godaddy and a team July 5, 2023 04:43
throw $exception;
}

$result = ob_get_clean() ?: '';
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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?

Suggested change
$result = ob_get_clean() ?: '';
$result = ob_get_clean();

Copy link
Member Author

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)

@unfulvio-godaddy
Copy link
Member Author

unfulvio-godaddy commented Jul 5, 2023

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 git pull the changes I have applied

@unfulvio-godaddy unfulvio-godaddy requested review from nmolham-godaddy and a team July 5, 2023 06:32
@unfulvio-godaddy unfulvio-godaddy merged commit c176fd8 into trunk Jul 5, 2023
@unfulvio-godaddy unfulvio-godaddy deleted the chore/add-test-coverage-to-handler-and-return-sequence branch July 5, 2023 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tests Updates to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants