Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ Test::Core implements the following mocking functions using [Test::MockModule](h

- `MO(%mocks)`

# Takes an optional "isa" for extending existing objects
# Takes an optional "extends" for extending existing objects
my $mock = MO(
isa => 'DateTime',
now => sub { DateTime->now->add(days => 3) },
extends => 'DateTime',
now => sub { DateTime->now->add(days => 3) },
);

# BUGS
Expand Down
8 changes: 4 additions & 4 deletions lib/Test/Core.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sub mock_module {

sub mock_object {
my (%mocks) = @_;
my $isa = delete $mocks{isa};
my $isa = delete $mocks{isa} || delete $mocks{extends};
my $mock_object = $isa
? Test::MockObject::Extends->new($isa)
: Test::MockObject->new;
Expand Down Expand Up @@ -270,10 +270,10 @@ Test::Core implements the following mocking functions using L<Test::MockModule>,

=item C<< MO(%mocks) >>

# Takes an optional "isa" for extending existing objects
# Takes an optional "extends" for extending existing objects
my $mock = MO(
isa => 'DateTime',
now => sub { DateTime->now->add(days => 3) },
extends => 'DateTime',
now => sub { DateTime->now->add(days => 3) },
);

=back
Expand Down
5 changes: 5 additions & 0 deletions t/04-mocking.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ is $mock_dt->year => '1776';
ok $mock_dt->isa('DateTime');
ok !$mock_dt->isa('Test::MockObject');

$mock_dt = MO(extends => DateTime->now, year => 1776);
is $mock_dt->year => '1776';
ok $mock_dt->isa('DateTime');
ok !$mock_dt->isa('Test::MockObject');

done_testing;