Test::Mock::Two - Inspection module for Test::Mock::One
version 0.011
use Test::Mock::One; use Test::Mock::Two qw(:all); use Test::Deep; my $mock = Test::Mock::One->new( 'X-Mock-Called' => 1, ); # Do things in your testsuite # You may omit the test message, it defaults to a sane value one_called_ok($mock, 'foo', 'Pkg::Foo::bar', "'foo' called by Pkg::Foo::bar"); one_called_times_ok($mock, 'foo', 'Pkg::Foo::bar', 1, "'foo' called once by Pkg::Foo::bar"); # Check if the arguments are correct # one_called_ok and one_called_times_ok return the same values my $rv = one_called_times_ok($mock, 'foo', "Pkg::Foo::bar", 1); cmp_deeply($rv->[0], [], "Called without arguments"); $rv = one_called_ok($mock, 'foo', "Pkg::Foo::bar"); cmp_deeply($rv->[0], [], "Called without arguments");
This module does the introspection of the Test::Mock::One object. This is to keep Test::Mock::One as empty as possible, implementing as little as possible additional methods.
This module exports nothing by default, and has two export tags:
All functions
All test functions (everything ending with _ok)
one_called($mock, 'mock_method', "Pkg::Name::method");
Check if Pkg::Name::method called $mock->mock_method
Pkg::Name::method
A Test::Builder enabled version of one_called.
one_called
one_called($mock, 'mock_method, "Pkg::Name::method", $times);
Test whether the mock object was called so many times for a given function.
Wesley Schwengle <waterkip@cpan.org>
This software is Copyright (c) 2017 by Wesley Schwengle.
This is free software, licensed under:
The (three-clause) BSD License
To install Test::Mock::One, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Mock::One
CPAN shell
perl -MCPAN -e shell install Test::Mock::One
For more information on module installation, please visit the detailed CPAN module installation guide.