NAME
Test::Mock::One - Mock the world with one object
VERSION
version 0.004
SYNOPSIS
use Test::Mock::One;
my $mock = Test::Mock::One->new(
foo => 'return value',
bar => 1,
hashref => \{ foo => bar },
arrayref => \[ foo => bar ],
code => sub { return your_special_function },
);
$mock->foo; # 'return value'
$mock->bar; # 1
$mock->hashref; # { foo => bar}
$mock->arrayref; # [ foo, bar ]
$mock->code; # executes your_special_function
DESCRIPTION
Be able to mock many things with little code by using AUTOLOAD.
METHODS
new
Ways to override specific behaviours
- X-Mock-Strict
-
Boolean value. Undefined attributes will not be mocked and calling them makes us die.
- X-Mock-ISA
-
Mock the ISA into the given class. Supported ways to mock the ISA:
'X-Mock-ISA' => 'Some::Pkg', 'X-Mock-ISA' => qr/Some::Pkg/, 'X-Mock-ISA' => [qw(Some::Pkg Other::Pkg)], 'X-Mock-ISA' => sub { return 0 }, 'X-Mock-ISA' => undef,
- X-Mock-Stringify
-
Tell us how to stringify the object
'X-Mock-Stringify' => 'My custom string', 'X-Mock-Stringify' => sub { return "foo" },
isa
Override the ISA from the object
AUTHOR
Wesley Schwengle <waterkip@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2017 by Wesley Schwengle.
This is free software, licensed under:
The (three-clause) BSD License