PHP Class Dotink\Parody\Mime

Author: Matthew J. Sahagian [mjs] ([email protected])
Inheritance: extends Quip
Datei anzeigen Open project: dotink/parody Class Usage Examples

Public Methods

Method Description
__call ( string $method, array $args ) : Mime Handle missing calls which, in short, means we should be looking for an extension.
__callStatic ( string $method, array $args ) : mixed Allow us to call certain method statically, specifically create
__construct ( string | object $target = NULL ) : void Create a new Mime.
__invoke ( ) : Quip Get the quip
define ( string $class ) : Mime Define a new quip (mocked class) to work on.
expect ( ) : Mime Tell an open method what to expect
extending ( string $parent_class ) : Mime Tells the class we're defining to extend a parent class, creating it if it does not exist.
give ( mixed $value = NULL ) : Mime Define a value to give for the open method or property
implementing ( string $interface ) : Mime Tells the class we're defining to implement interfaces, creating it if it does not exist.
onCall ( string $method ) : Mime Opens a method on the quip object
onGet ( string $property ) : Mime Opens a property on the quip object
onNew ( ) : Mime Register a factory for adding methods/property mocks to objects instantiated later.
resolve ( $target ) : Quip Gets the current working quip object (for injection)
using ( string $trait ) : Mime Tell the class we're defining to use a given trait and if it doesn't exist, create it

Private Methods

Method Description
create ( string $class, string $overload_static = FALSE ) : Mime Create a new quip (mocked object) of a particular class to work on.
make ( string $class ) : string Literally makes (evals) a class.

Method Details

__call() public method

Handle missing calls which, in short, means we should be looking for an extension.
public __call ( string $method, array $args ) : Mime
$method string The method we tried to call
$args array The arguments we passed to it
return Mime The mime for method chaining

__callStatic() public static method

Allow us to call certain method statically, specifically create
public static __callStatic ( string $method, array $args ) : mixed
$method string The method that was called
$args array The arguments passed to the method
return mixed The return value for the called method

__construct() public method

Create a new Mime.
public __construct ( string | object $target = NULL ) : void
$target string | object A class name or quip to work with.
return void

__invoke() public method

Get the quip
public __invoke ( ) : Quip
return Quip The quip

define() public static method

Define a new quip (mocked class) to work on.
public static define ( string $class ) : Mime
$class string The class to define
return Mime The mime object for defining the class

expect() public method

Tell an open method what to expect
public expect ( ) : Mime
return Mime The mime for method chaining

extending() public method

Tells the class we're defining to extend a parent class, creating it if it does not exist.
public extending ( string $parent_class ) : Mime
$parent_class string The parent class to define
return Mime A new mime for defining the parent

give() public method

Define a value to give for the open method or property
public give ( mixed $value = NULL ) : Mime
$value mixed The value to return for the open method or property
return Mime For method chaining

implementing() public method

Tells the class we're defining to implement interfaces, creating it if it does not exist.
public implementing ( string $interface ) : Mime
$interface string The interface to implement
return Mime The mime for method chaining

onCall() public method

Opens a method on the quip object
public onCall ( string $method ) : Mime
$method string The name of the method to open
return Mime The mime for method chaining

onGet() public method

Opens a property on the quip object
public onGet ( string $property ) : Mime
$property string The name of the property to open
return Mime The mime for method chaining

onNew() public method

This is useful if the code you are testing has a call such as new Class(). Since the code is dependent on that object, but it is not injected we essentially want to delay our method/property configuration for the mock till after that call. Once the factory is run it is removed from the stack automatically.
public onNew ( ) : Mime
return Mime The mime for method chaining

resolve() public method

Gets the current working quip object (for injection)
public resolve ( $target ) : Quip
return Quip The quip object, whose class will actually be whatever class you're mocking

using() public method

Tell the class we're defining to use a given trait and if it doesn't exist, create it
public using ( string $trait ) : Mime
$trait string The trait to use
return Mime The mime for method chaining