Documentation

Mockery
in package

Table of Contents

BLOCKS  = 'Mockery_Forward_Blocks'
$_config  : Configuration
Global configuration handler containing configuration options.
$_container  : Container|null
Global container to hold all mocks for the current unit test running.
$_generator  : Generator
$_loader  : Loader
$_filesToCleanUp  : array<string|int, mixed>
andAnyOtherArgs()  : AndAnyOtherArgs
Return instance of AndAnyOtherArgs matcher.
andAnyOthers()  : AndAnyOtherArgs
Return instance of AndAnyOtherArgs matcher.
any()  : Any
Return instance of ANY matcher.
anyOf()  : AnyOf
Return instance of ANYOF matcher.
builtInTypes()  : array<string|int, mixed>
capture()  : Closure
Return instance of CLOSURE matcher.
close()  : void
Static shortcut to closing up and verifying all mocks in the global container, and resetting the container static variable to null.
contains()  : Contains
Return instance of CONTAINS matcher.
declareClass()  : mixed
declareInterface()  : mixed
ducktype()  : Ducktype
Return instance of DUCKTYPE matcher.
fetchMock()  : Mock
Static fetching of a mock associated with a name or explicit class poser.
formatArgs()  : string
Utility method to format method name and arguments into a string.
formatObjects()  : string
Utility function to format objects to printable arrays.
getConfiguration()  : Configuration
Lazy loader and Getter for the global configuration container.
getContainer()  : Container
Lazy loader and getter for the container property.
getDefaultGenerator()  : CachingGenerator
Creates and returns a default generator used inside this class.
getDefaultLoader()  : EvalLoader
Gets an EvalLoader to be used as default.
getGenerator()  : Generator
Lazy loader method and getter for the generator property.
getLoader()  : Loader
Lazy loader method and getter for the $_loader property.
globalHelpers()  : void
Defines the global helper functions
hasKey()  : HasKey
Return instance of HASKEY matcher.
hasValue()  : HasValue
Return instance of HASVALUE matcher.
instanceMock()  : MockInterface|LegacyMockInterface
Static and Semantic shortcut to \Mockery\Container::mock().
isBuiltInType()  : bool
mock()  : MockInterface|LegacyMockInterface
Static shortcut to \Mockery\Container::mock().
mustBe()  : MustBe
Return instance of MUSTBE matcher.
namedMock()  : MockInterface|LegacyMockInterface
Static shortcut to \Mockery\Container::mock(), first argument names the mock.
not()  : Not
Return instance of NOT matcher.
notAnyOf()  : NotAnyOf
Return instance of NOTANYOF matcher.
on()  : Closure
Return instance of CLOSURE matcher.
parseShouldReturnArgs()  : CompositeExpectation
Utility function to parse shouldReceive() arguments and generate expectations from such as needed.
pattern()  : Pattern
Return instance of PATTERN matcher.
registerFileForCleanUp()  : mixed
Register a file to be deleted on tearDown.
resetContainer()  : void
Reset the container to null.
self()  : MockInterface|LegacyMockInterface
Static shortcut to \Mockery\Container::self().
setContainer()  : Container
Set the container.
setGenerator()  : mixed
Setter for the $_generator static property.
setLoader()  : mixed
Setter for the $_loader static property.
spy()  : MockInterface|LegacyMockInterface
Static and semantic shortcut for getting a mock from the container and applying the spy's expected behavior into it.
subset()  : Subset
Return instance of SUBSET matcher.
type()  : Type
Return instance of TYPE matcher.
buildDemeterChain()  : ExpectationInterface
Sets up expectations on the members of the CompositeExpectation and builds up any demeter chain that was passed to shouldReceive.
cleanupArray()  : mixed
Utility method for recursively gerating a representation of the given array.
cleanupNesting()  : mixed
Utility method used for recursively generating an object or array representation.
declareType()  : mixed
extractInstancePublicProperties()  : array<string|int, mixed>
Returns all public instance properties.
formatArgument()  : mixed
Gets the string representation of any passed argument.
getExistingDemeterMock()  : mixed
Gets an specific demeter mock from the ones kept by the container.
getNewDemeterMock()  : Mock
Gets a new demeter configured mock from the container.
noMoreElementsInChain()  : bool
Checks if the passed array representing a demeter chain with the method names is empty.
objectToArray()  : array<string|int, mixed>
Utility function to turn public properties and public get* and is* method values into an array.

Constants

BLOCKS

public mixed BLOCKS = 'Mockery_Forward_Blocks'

Properties

$_config

Global configuration handler containing configuration options.

protected static Configuration $_config = ull

$_container

Global container to hold all mocks for the current unit test running.

protected static Container|null $_container = ull

$_filesToCleanUp

private static array<string|int, mixed> $_filesToCleanUp = []

Methods

andAnyOthers()

Return instance of AndAnyOtherArgs matcher.

public static andAnyOthers() : AndAnyOtherArgs

An alternative name to andAnyOtherArgs so the API stays closer to any as well.

Return values
AndAnyOtherArgs

any()

Return instance of ANY matcher.

public static any() : Any
Return values
Any

anyOf()

Return instance of ANYOF matcher.

public static anyOf(array<string|int, mixed> ...$args) : AnyOf
Parameters
$args : array<string|int, mixed>
Return values
AnyOf

builtInTypes()

public static builtInTypes() : array<string|int, mixed>
Tags
deprecated

since 1.3.2 and will be removed in 2.0.

Return values
array<string|int, mixed>

capture()

Return instance of CLOSURE matcher.

public static capture( &$reference) : Closure
Parameters
$reference :
Return values
Closure

close()

Static shortcut to closing up and verifying all mocks in the global container, and resetting the container static variable to null.

public static close() : void
Return values
void

contains()

Return instance of CONTAINS matcher.

public static contains(mixed ...$args) : Contains
Parameters
$args : mixed
Return values
Contains

declareClass()

public static declareClass(mixed $fqn) : mixed
Parameters
$fqn : mixed
Return values
mixed

declareInterface()

public static declareInterface(mixed $fqn) : mixed
Parameters
$fqn : mixed
Return values
mixed

ducktype()

Return instance of DUCKTYPE matcher.

public static ducktype(array<string|int, mixed> ...$args) : Ducktype
Parameters
$args : array<string|int, mixed>
Return values
Ducktype

fetchMock()

Static fetching of a mock associated with a name or explicit class poser.

public static fetchMock(string $name) : Mock
Parameters
$name : string
Return values
Mock

formatArgs()

Utility method to format method name and arguments into a string.

public static formatArgs(string $method[, array<string|int, mixed> $arguments = null ]) : string
Parameters
$method : string
$arguments : array<string|int, mixed> = null
Return values
string

formatObjects()

Utility function to format objects to printable arrays.

public static formatObjects([array<string|int, mixed> $objects = null ]) : string
Parameters
$objects : array<string|int, mixed> = null
Return values
string

getContainer()

Lazy loader and getter for the container property.

public static getContainer() : Container
Return values
Container

getDefaultGenerator()

Creates and returns a default generator used inside this class.

public static getDefaultGenerator() : CachingGenerator
Return values
CachingGenerator

getDefaultLoader()

Gets an EvalLoader to be used as default.

public static getDefaultLoader() : EvalLoader
Return values
EvalLoader

getGenerator()

Lazy loader method and getter for the generator property.

public static getGenerator() : Generator
Return values
Generator

getLoader()

Lazy loader method and getter for the $_loader property.

public static getLoader() : Loader
Return values
Loader

globalHelpers()

Defines the global helper functions

public static globalHelpers() : void
Return values
void

hasKey()

Return instance of HASKEY matcher.

public static hasKey(mixed $key) : HasKey
Parameters
$key : mixed
Return values
HasKey

hasValue()

Return instance of HASVALUE matcher.

public static hasValue(mixed $val) : HasValue
Parameters
$val : mixed
Return values
HasValue

isBuiltInType()

public static isBuiltInType(string $type) : bool
Parameters
$type : string
Tags
deprecated

since 1.3.2 and will be removed in 2.0.

Return values
bool

mustBe()

Return instance of MUSTBE matcher.

public static mustBe(mixed $expected) : MustBe
Parameters
$expected : mixed
Return values
MustBe

not()

Return instance of NOT matcher.

public static not(mixed $expected) : Not
Parameters
$expected : mixed
Return values
Not

notAnyOf()

Return instance of NOTANYOF matcher.

public static notAnyOf(array<string|int, mixed> ...$args) : NotAnyOf
Parameters
$args : array<string|int, mixed>
Return values
NotAnyOf

on()

Return instance of CLOSURE matcher.

public static on(mixed $closure) : Closure
Parameters
$closure : mixed
Return values
Closure

pattern()

Return instance of PATTERN matcher.

public static pattern(mixed $expected) : Pattern
Parameters
$expected : mixed
Return values
Pattern

registerFileForCleanUp()

Register a file to be deleted on tearDown.

public static registerFileForCleanUp(string $fileName) : mixed
Parameters
$fileName : string
Return values
mixed

resetContainer()

Reset the container to null.

public static resetContainer() : void
Return values
void

setGenerator()

Setter for the $_generator static property.

public static setGenerator(Generator $generator) : mixed
Parameters
$generator : Generator
Return values
mixed

setLoader()

Setter for the $_loader static property.

public static setLoader(Loader $loader) : mixed
Parameters
$loader : Loader
Return values
mixed

subset()

Return instance of SUBSET matcher.

public static subset(array<string|int, mixed> $part[, bool $strict = true ]) : Subset
Parameters
$part : array<string|int, mixed>
$strict : bool = true
  • (Optional) True for strict comparison, false for loose
Return values
Subset

type()

Return instance of TYPE matcher.

public static type(mixed $expected) : Type
Parameters
$expected : mixed
Return values
Type

cleanupArray()

Utility method for recursively gerating a representation of the given array.

private static cleanupArray(array<string|int, mixed> $argument[, int $nesting = 3 ]) : mixed
Parameters
$argument : array<string|int, mixed>
$nesting : int = 3
Return values
mixed

cleanupNesting()

Utility method used for recursively generating an object or array representation.

private static cleanupNesting(mixed $argument, int $nesting) : mixed
Parameters
$argument : mixed
$nesting : int
Return values
mixed

declareType()

private static declareType(mixed $fqn, mixed $type) : mixed
Parameters
$fqn : mixed
$type : mixed
Return values
mixed

extractInstancePublicProperties()

Returns all public instance properties.

private static extractInstancePublicProperties(mixed $object, int $nesting) : array<string|int, mixed>
Parameters
$object : mixed
$nesting : int
Return values
array<string|int, mixed>

formatArgument()

Gets the string representation of any passed argument.

private static formatArgument(mixed $argument, int $depth) : mixed
Parameters
$argument : mixed
$depth : int
Return values
mixed

getExistingDemeterMock()

Gets an specific demeter mock from the ones kept by the container.

private static getExistingDemeterMock(Container $container, string $demeterMockKey) : mixed
Parameters
$container : Container
$demeterMockKey : string
Return values
mixed

noMoreElementsInChain()

Checks if the passed array representing a demeter chain with the method names is empty.

private static noMoreElementsInChain(array<string|int, mixed> $methodNames) : bool
Parameters
$methodNames : array<string|int, mixed>
Return values
bool

objectToArray()

Utility function to turn public properties and public get* and is* method values into an array.

private static objectToArray(object $object[, int $nesting = 3 ]) : array<string|int, mixed>
Parameters
$object : object
$nesting : int = 3
Return values
array<string|int, mixed>

Search results