<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Mock::Quick - Quickly mock objects and classes, even temporarily replace
    them, side-effect free.

DESCRIPTION
    Mock-Quick is here to solve the current problems with Mocking libraries.

    There are a couple Mocking libraries available on CPAN. The primary
    problems with these libraries include verbose syntax, and most
    importantly side-effects. Some Mocking libraries expect you to mock a
    specific class, and will unload it then redefine it. This is
    particularily a problem if you only want to override a class on a
    lexical level.

    Mock-Object provides a declarative mocking interface that results in a
    very concise, but clear syntax. There are seperate facilities for
    mocking object instances, and classes. You can quickly create an
    instance of an object with custom attributes and methods. You can also
    quickly create an anonymous class, optionally inhereting from another,
    with whatever methods you desire.

    Mock-Object also provides a tool that provides an OO interface to
    overriding methods in existing classes. This tool also allows for the
    restoration of the original class methods. Best of all this is a
    localized tool, when your control object falls out of scope the original
    class is restored.

SYNOPSIS
  MOCKING OBJECTS
        use Mock::Quick;

        my $obj = obj(
            foo =&gt; 'bar',            # define attribute
            do_it =&gt; qmeth { ... },  # define method
            ...
        );

        is( $obj-&gt;foo, 'bar' );
        $obj-&gt;foo( 'baz' );
        is( $obj-&gt;foo, 'baz' );

        $obj-&gt;do_it();

        # define the new attribute automatically
        $obj-&gt;bar( 'xxx' );

        # define a new method on the fly
        $obj-&gt;baz( qmeth { ... });

        # remove an attribute or method
        $obj-&gt;baz( qclear() );

  MOCKING CLASSES
        use Mock::Quick;

        my $control = qclass(
            # Insert a generic new() method (blessed hash)
            -with_new =&gt; 1,

            # Inheritance
            -subclass =&gt; 'Some::Class',
            # Can also do
            -subclass =&gt; [ 'Class::A', 'Class::B' ],

            # generic get/set attribute methods.
            -attributes =&gt; [ qw/a b c d/ ],

            # Method that simply returns a value.
            simple =&gt; 'value',

            # Custom method.
            method =&gt; sub { ... },
        );

        my $obj = $control-&gt;packahe-&gt;new;

        # Override a method
        $control-&gt;override( foo =&gt; sub { ... });

        # Restore it to the original
        $control-&gt;restore( 'foo' );

        # Remove the anonymous namespace we created.
        $control-&gt;undefine();

  TAKING OVER EXISTING CLASSES
        use Mock::Quick;

        my $control = qtakeover( 'Some::Package' );

        # Override a method
        $control-&gt;override( foo =&gt; sub { ... });

        # Restore it to the original
        $control-&gt;restore( 'foo' );

        # Destroy the control object and completely restore the original class Some::Package.
        $control = undef;

EXPORTS
    Mock-Quick uses Exporter::Declare. This allows for exports to be
    prefixed or renamed. See "RENAMING IMPORTED ITEMS" in Exporter::Declare
    for more information.

    $obj = qobj( attribute =&gt; value, ... )
        Create an object. Every possible attribute works fine as a get/set
        accessor. You can define other methods using qmeth {...} and
        assigning that to an attribute. You can clear a method using
        qclear() as an argument.

        See Mock::Quick::Object for more.

    $control = qclass( -config =&gt; ..., name =&gt; $value || sub { ... }, ... )
        Define an anonymous package with the desired methods and
        specifications.

        See Mock::Quick::Class for more.

    $control = qtakeover( $package )
        Take control over an existing class.

        See Mock::Quick::Class for more.

    qclear()
        Returns a special reference that when used as an argument, will
        cause Mock::Quick::Object methods to be cleared.

    qmeth { my $self = shift; ... }
        Define a method for an Mock::Quick::Object instance.

AUTHORS
    Chad Granum exodist7@gmail.com

CONTRIBUTORS
    Contributors are listed as authors in modules they have touched.

    Glen Hinkle glen@empireenterprises.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.

</pre></body></html>