Skip to content


Subversion checkout URL

You can clone with
Download ZIP


New method which can return mocked method. #3

wants to merge 1 commit into from

2 participants


I put simply method which can return reference of mocked method.

I have problem when I want to now when program run some method,
than first I mocked this method to some own function and when called this mocked method,
than I can call all code too, such as this example:

mock("CGI","header", sub {
# ... doing something
$code = mocked("CGI", "header");
&$code(); # run old mocked method


Thanks for the pull request, but can you provide update the unit tests as well, to cover the new "mocked" method?


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/Test/
9 lib/Test/
@@ -8,11 +8,12 @@ use Carp qw{ croak };
use vars qw(@EXPORT $VERSION);
use base 'Exporter';
-$VERSION = '0.03';
+$VERSION = '0.05';
my $mocks = {};
-@EXPORT = qw(mock unmock should method methods);
+@EXPORT = qw(mock unmock should method methods mocked);
+sub mocked($$) {$mocks->{join("::", @_)}}
sub method($) {@_}
sub methods($) {@_}
sub should(&) {@_}
@@ -190,6 +191,10 @@ And using multiple methods at the same time:
unmock 'Foo::Bar' => methods ['a_method', 'b_method'];
+=head2 mocked($module, $method)
+Return CODE of mocked method
=head2 method
Syntactic sugar for mock()
Something went wrong with that request. Please try again.