MockConfiguration
in package
This class describes the configuration of mocks and hides away some of the reflection implementation
Table of Contents
- $allMethods : mixed
- Instance cache of all methods
- $blackListedMethods : mixed
- Methods that should specifically not be mocked
- $constantsMap : mixed
- $instanceMock : mixed
- An instance mock is where we override the original class before it's autoloaded
- $mockOriginalDestructor : mixed
- If true, overrides original class destructor
- $name : mixed
- The class name we'd like to use for a generated mock
- $parameterOverrides : mixed
- Param overrides
- $targetClass : mixed
- A class that we'd like to mock
- $targetClassName : mixed
- $targetInterfaceNames : mixed
- $targetInterfaces : mixed
- A number of interfaces we'd like to mock, keyed by name to attempt to keep unique
- $targetObject : mixed
- An object we'd like our mock to proxy to
- $targetTraitNames : mixed
- $targetTraits : mixed
- A number of traits we'd like to mock, keyed by name to attempt to keep unique
- $whiteListedMethods : mixed
- If not empty, only these methods will be mocked
- __construct() : mixed
- generateName() : mixed
- Generate a suitable name based on the config
- getBlackListedMethods() : mixed
- getConstantsMap() : mixed
- getHash() : string
- Attempt to create a hash of the configuration, in order to allow caching
- getMethodsToMock() : mixed
- Gets a list of methods from the classes, interfaces and objects and filters them appropriately. Lot's of filtering going on, perhaps we could have filter classes to iterate through
- getName() : mixed
- getNamespaceName() : mixed
- getParameterOverrides() : mixed
- getShortName() : mixed
- getTargetClass() : mixed
- getTargetClassName() : mixed
- getTargetInterfaces() : mixed
- getTargetObject() : mixed
- getTargetTraits() : mixed
- getWhiteListedMethods() : mixed
- isInstanceMock() : mixed
- isMockOriginalDestructor() : mixed
- rename() : mixed
- requiresCallStaticTypeHintRemoval() : mixed
- We declare the __callStatic method to handle undefined stuff, if the class we're mocking has also defined it, we need to comply with their interface
- requiresCallTypeHintRemoval() : mixed
- We declare the __call method to handle undefined stuff, if the class we're mocking has also defined it, we need to comply with their interface
- addTarget() : mixed
- addTargetInterfaceName() : mixed
- If we attempt to implement Traversable, we must ensure we are also implementing either Iterator or IteratorAggregate, and that whichever one it is comes before Traversable in the list of implements.
- addTargets() : mixed
- addTargetTraitName() : mixed
- getAllMethods() : mixed
- setTargetClassName() : mixed
- setTargetObject() : mixed
Properties
$allMethods
Instance cache of all methods
protected
mixed
$allMethods
$blackListedMethods
Methods that should specifically not be mocked
protected
mixed
$blackListedMethods
= array()
This is currently populated with stuff we don't know how to deal with, should really be somewhere else
$constantsMap
protected
mixed
$constantsMap
= array()
$instanceMock
An instance mock is where we override the original class before it's autoloaded
protected
mixed
$instanceMock
= false
$mockOriginalDestructor
If true, overrides original class destructor
protected
mixed
$mockOriginalDestructor
= false
$name
The class name we'd like to use for a generated mock
protected
mixed
$name
$parameterOverrides
Param overrides
protected
mixed
$parameterOverrides
= array()
$targetClass
A class that we'd like to mock
protected
mixed
$targetClass
$targetClassName
protected
mixed
$targetClassName
$targetInterfaceNames
protected
mixed
$targetInterfaceNames
= array()
$targetInterfaces
A number of interfaces we'd like to mock, keyed by name to attempt to keep unique
protected
mixed
$targetInterfaces
= array()
$targetObject
An object we'd like our mock to proxy to
protected
mixed
$targetObject
$targetTraitNames
protected
mixed
$targetTraitNames
= array()
$targetTraits
A number of traits we'd like to mock, keyed by name to attempt to keep unique
protected
mixed
$targetTraits
= array()
$whiteListedMethods
If not empty, only these methods will be mocked
protected
mixed
$whiteListedMethods
= array()
Methods
__construct()
public
__construct([array<string|int, mixed> $targets = array() ][, array<string|int, mixed> $blackListedMethods = array() ][, array<string|int, mixed> $whiteListedMethods = array() ][, mixed $name = null ][, mixed $instanceMock = false ][, array<string|int, mixed> $parameterOverrides = array() ][, mixed $mockOriginalDestructor = false ][, array<string|int, mixed> $constantsMap = array() ]) : mixed
Parameters
- $targets : array<string|int, mixed> = array()
- $blackListedMethods : array<string|int, mixed> = array()
- $whiteListedMethods : array<string|int, mixed> = array()
- $name : mixed = null
- $instanceMock : mixed = false
- $parameterOverrides : array<string|int, mixed> = array()
- $mockOriginalDestructor : mixed = false
- $constantsMap : array<string|int, mixed> = array()
Return values
mixed —generateName()
Generate a suitable name based on the config
public
generateName() : mixed
Return values
mixed —getBlackListedMethods()
public
getBlackListedMethods() : mixed
Return values
mixed —getConstantsMap()
public
getConstantsMap() : mixed
Return values
mixed —getHash()
Attempt to create a hash of the configuration, in order to allow caching
public
getHash() : string
Tags
Return values
string —getMethodsToMock()
Gets a list of methods from the classes, interfaces and objects and filters them appropriately. Lot's of filtering going on, perhaps we could have filter classes to iterate through
public
getMethodsToMock() : mixed
Return values
mixed —getName()
public
getName() : mixed
Return values
mixed —getNamespaceName()
public
getNamespaceName() : mixed
Return values
mixed —getParameterOverrides()
public
getParameterOverrides() : mixed
Return values
mixed —getShortName()
public
getShortName() : mixed
Return values
mixed —getTargetClass()
public
getTargetClass() : mixed
Return values
mixed —getTargetClassName()
public
getTargetClassName() : mixed
Return values
mixed —getTargetInterfaces()
public
getTargetInterfaces() : mixed
Return values
mixed —getTargetObject()
public
getTargetObject() : mixed
Return values
mixed —getTargetTraits()
public
getTargetTraits() : mixed
Return values
mixed —getWhiteListedMethods()
public
getWhiteListedMethods() : mixed
Return values
mixed —isInstanceMock()
public
isInstanceMock() : mixed
Return values
mixed —isMockOriginalDestructor()
public
isMockOriginalDestructor() : mixed
Return values
mixed —rename()
public
rename(mixed $className) : mixed
Parameters
- $className : mixed
Return values
mixed —requiresCallStaticTypeHintRemoval()
We declare the __callStatic method to handle undefined stuff, if the class we're mocking has also defined it, we need to comply with their interface
public
requiresCallStaticTypeHintRemoval() : mixed
Return values
mixed —requiresCallTypeHintRemoval()
We declare the __call method to handle undefined stuff, if the class we're mocking has also defined it, we need to comply with their interface
public
requiresCallTypeHintRemoval() : mixed
Return values
mixed —addTarget()
protected
addTarget(mixed $target) : mixed
Parameters
- $target : mixed
Return values
mixed —addTargetInterfaceName()
If we attempt to implement Traversable, we must ensure we are also implementing either Iterator or IteratorAggregate, and that whichever one it is comes before Traversable in the list of implements.
protected
addTargetInterfaceName(mixed $targetInterface) : mixed
Parameters
- $targetInterface : mixed
Return values
mixed —addTargets()
protected
addTargets(mixed $interfaces) : mixed
Parameters
- $interfaces : mixed
Return values
mixed —addTargetTraitName()
protected
addTargetTraitName(mixed $targetTraitName) : mixed
Parameters
- $targetTraitName : mixed
Return values
mixed —getAllMethods()
protected
getAllMethods() : mixed
Return values
mixed —setTargetClassName()
protected
setTargetClassName(mixed $targetClassName) : mixed
Parameters
- $targetClassName : mixed
Return values
mixed —setTargetObject()
protected
setTargetObject(mixed $object) : mixed
Parameters
- $object : mixed