NAME
Mock::Quick::Class - Class mocking for Mock::Quick
DESCRIPTION
Provides class mocking for Mock::Quick
SYNOPSIS
MOCKING CLASSES
use Mock::Quick::Class;
my $control = Mock::Quick::Class->new(
# Insert a generic new() method (blessed hash)
-with_new => 1,
# Inheritance
-subclass => 'Some::Class',
# Can also do
-subclass => [ 'Class::A', 'Class::B' ],
# generic get/set attribute methods.
-attributes => [ qw/a b c d/ ],
# Method that simply returns a value.
simple => 'value',
# Custom method.
method => sub { ... },
);
my $obj = $control->package->new;
# Override a method
$control->override( foo => sub { ... });
# Restore it to the original
$control->restore( 'foo' );
# Remove the anonymous namespace we created.
$control->undefine();
TAKING OVER EXISTING CLASSES
use Mock::Quick::Class;
my $control = Mock::Quick::Class->takeover( 'Some::Package' );
# Override a method
$control->override( foo => sub { ... });
# Restore it to the original
$control->restore( 'foo' );
# Destroy the control object and completely restore the original class Some::Package.
$control = undef;
AUTHORS
Chad Granum exodist7@gmail.com
COPYRIGHT
Copyright (C) 2011 Chad Granum
Mock-Quick is free software; Standard perl licence.
Mock-Quick is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.