This is the place where the mocked methods are defined. The method also proves that the method you like to mock actually exists.
=head3 synopsis
This method takes one parameter, which is the name of the method you like to mock.
Because you need to specify more detailed the behaviour of this mock you have to chain the method signature (when) and the expected return value (then...).
For example, the next line will create a mocked version of the method log, but only if this method is called with any string and the number 123. In this case it will return the String 'Hello World'. Mockify will throw an error if this method is called somehow else.
my $MockObjectBuilder = Test::Mockify->new( 'Sample::Logger', [] );
Use spy if you want to observe a method. You can use the L<Test::Mockify::Verify|Test::Mockify::Verify> to ensure that the method was called with the expected parameters.
=head3 synopsis
This method takes one parameter, which is the name of the method you like to spy.
Because you need to specify more detailed the behaviour of this spy you have to define the method signature with C<when>
For example, the next line will create a method spy of the method log, but only if this method is called with any string and the number 123. Mockify will throw an error if this method is called in another way.
my $MockObjectBuilder = Test::Mockify->new( 'Sample::Logger', [] );
my$SubWithPrototype= eval( 'return sub ('. $Prototype.') {$Sub->(@_)}'); ## no critic (ProhibitStringyEval RequireInterpolationOfMetachars ) This is the only dynamic way to add the prototype
Error($@, {'Error in eval, line'=> __LINE__ - 1}) if($@); # Rethrow error if something went wrong in the eval. (For debugging)
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHOR
Christian Breitkreutz E<lt>christianbreitkreutz@gmx.deE<gt>
=head1 ACKNOWLEDGEMENTS
Thanks to Dustin Buckenmeyer E<lt>dustin.buckenmeyer@gmail.comE<gt> and L<ECS Tuning|https://www.ecstuning.com/> for giving Dustin the opportunity to pursue this idea and ultimately give it back to the community!
=cut
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
go to github issues (only if github is preferred repository)