We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We need some functionality similar to around. This could be useful when we override only particular calls
around
The text was updated successfully, but these errors were encountered:
You can always get the origjnal from the $mock object: https://metacpan.org/pod/Test2::Mock#$mock-%3Eorig($SYMBOL)
Also there is an 'around' method to Test2::Mock, and that is usable in Test2::Tools::Mock which is just candy around it: https://metacpan.org/pod/Test2::Mock#$mock-%3Earound($NAME,-sub-{-...-})
So this works fine:
use Test2::V0; { package Foo; sub blah { 'blah' } } my $mock = mock 'Foo' => ( around => [ blah => sub { my ($orig, $class, @args) = @_; my $got = $class->$orig(@args); return "around $got"; }, ] ); is(Foo->blah, "around blah", "Mocked foo() and called original inside it"); done_testing;
ok 1 - Mocked foo() and called original inside it 1..1
So maybe the problem is we need more documentation?
Sorry, something went wrong.
yes, would be nice to know list of methods which could be used like override and add. And now I know that around could be used too.
override
add
No branches or pull requests
We need some functionality similar to
around
. This could be useful when we override only particular callsThe text was updated successfully, but these errors were encountered: