Documentation

PHPUnit_Framework_MockObject_Generator
in package

Mock Object Code Generator

Tags
since

Class available since Release 1.0.0

Table of Contents

$blacklistedMethodNames  : array<string|int, mixed>
$cache  : array<string|int, mixed>
generate()  : array<string|int, mixed>
generateClassFromWsdl()  : string
getMock()  : object
Returns a mock object for the specified class.
getMockForAbstractClass()  : object
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods to mock can be specified with the last parameter
getMockForTrait()  : object
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the `$mockedMethods` parameter.
getObjectForTrait()  : object
Returns an object for the specified trait.
canMockMethod()  : bool
evalClass()  : mixed
generateClassName()  : array<string|int, mixed>
generateMock()  : array<string|int, mixed>
generateMockClassDeclaration()  : array<string|int, mixed>
generateMockedMethodDefinition()  : string
generateMockedMethodDefinitionFromExisting()  : string
getMethodParameters()  : string
Returns the parameters of a function or method.
getObject()  : object
getClassMethods()  : array<string|int, mixed>
hasType()  : bool
isVariadic()  : bool

Properties

$blacklistedMethodNames

protected array<string|int, mixed> $blacklistedMethodNames = array('__CLASS__' => rue, '__DIR__' => rue, '__FILE__' => rue, '__FUNCTION__' => rue, '__LINE__' => rue, '__METHOD__' => rue, '__NAMESPACE__' => rue, '__TRAIT__' => rue, '__clone' => rue, '__halt_compiler' => rue, 'abstract' => rue, 'and' => rue, 'array' => rue, 'as' => rue, 'break' => rue, 'callable' => rue, 'case' => rue, 'catch' => rue, 'class' => rue, 'clone' => rue, 'const' => rue, 'continue' => rue, 'declare' => rue, 'default' => rue, 'die' => rue, 'do' => rue, 'echo' => rue, 'else' => rue, 'elseif' => rue, 'empty' => rue, 'enddeclare' => rue, 'endfor' => rue, 'endforeach' => rue, 'endif' => rue, 'endswitch' => rue, 'endwhile' => rue, 'eval' => rue, 'exit' => rue, 'expects' => rue, 'extends' => rue, 'final' => rue, 'for' => rue, 'foreach' => rue, 'function' => rue, 'global' => rue, 'goto' => rue, 'if' => rue, 'implements' => rue, 'include' => rue, 'include_once' => rue, 'instanceof' => rue, 'insteadof' => rue, 'interface' => rue, 'isset' => rue, 'list' => rue, 'namespace' => rue, 'new' => rue, 'or' => rue, 'print' => rue, 'private' => rue, 'protected' => rue, 'public' => rue, 'require' => rue, 'require_once' => rue, 'return' => rue, 'static' => rue, 'switch' => rue, 'throw' => rue, 'trait' => rue, 'try' => rue, 'unset' => rue, 'use' => rue, 'var' => rue, 'while' => rue, 'xor' => rue)

$cache

private static array<string|int, mixed> $cache = array()

Methods

generate()

public generate(array<string|int, mixed>|string $type[, array<string|int, mixed> $methods = null ][, string $mockClassName = '' ][, bool $callOriginalClone = true ][, bool $callAutoload = true ][, bool $cloneArguments = true ][, bool $callOriginalMethods = false ]) : array<string|int, mixed>
Parameters
$type : array<string|int, mixed>|string
$methods : array<string|int, mixed> = null
$mockClassName : string = ''
$callOriginalClone : bool = true
$callAutoload : bool = true
$cloneArguments : bool = true
$callOriginalMethods : bool = false
Return values
array<string|int, mixed>

generateClassFromWsdl()

public generateClassFromWsdl(string $wsdlFile, string $className[, array<string|int, mixed> $methods = array() ][, array<string|int, mixed> $options = array() ]) : string
Parameters
$wsdlFile : string
$className : string
$methods : array<string|int, mixed> = array()
$options : array<string|int, mixed> = array()
Tags
throws
PHPUnit_Framework_MockObject_RuntimeException
Return values
string

getMock()

Returns a mock object for the specified class.

public getMock(array<string|int, mixed>|string $type[, array<string|int, mixed> $methods = array() ][, array<string|int, mixed> $arguments = array() ][, string $mockClassName = '' ][, bool $callOriginalConstructor = true ][, bool $callOriginalClone = true ][, bool $callAutoload = true ][, bool $cloneArguments = true ][, bool $callOriginalMethods = false ][, object $proxyTarget = null ]) : object
Parameters
$type : array<string|int, mixed>|string
$methods : array<string|int, mixed> = array()
$arguments : array<string|int, mixed> = array()
$mockClassName : string = ''
$callOriginalConstructor : bool = true
$callOriginalClone : bool = true
$callAutoload : bool = true
$cloneArguments : bool = true
$callOriginalMethods : bool = false
$proxyTarget : object = null
Tags
throws
InvalidArgumentException
throws
PHPUnit_Framework_Exception
throws
PHPUnit_Framework_MockObject_RuntimeException
since

Method available since Release 1.0.0

Return values
object

getMockForAbstractClass()

Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods to mock can be specified with the last parameter

public getMockForAbstractClass(string $originalClassName[, array<string|int, mixed> $arguments = array() ][, string $mockClassName = '' ][, bool $callOriginalConstructor = true ][, bool $callOriginalClone = true ][, bool $callAutoload = true ][, array<string|int, mixed> $mockedMethods = array() ][, bool $cloneArguments = true ]) : object
Parameters
$originalClassName : string
$arguments : array<string|int, mixed> = array()
$mockClassName : string = ''
$callOriginalConstructor : bool = true
$callOriginalClone : bool = true
$callAutoload : bool = true
$mockedMethods : array<string|int, mixed> = array()
$cloneArguments : bool = true
Tags
since

Method available since Release 1.0.0

throws
PHPUnit_Framework_MockObject_RuntimeException
throws
PHPUnit_Framework_Exception
Return values
object

getMockForTrait()

Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the `$mockedMethods` parameter.

public getMockForTrait(string $traitName[, array<string|int, mixed> $arguments = array() ][, string $mockClassName = '' ][, bool $callOriginalConstructor = true ][, bool $callOriginalClone = true ][, bool $callAutoload = true ][, array<string|int, mixed> $mockedMethods = array() ][, bool $cloneArguments = true ]) : object
Parameters
$traitName : string
$arguments : array<string|int, mixed> = array()
$mockClassName : string = ''
$callOriginalConstructor : bool = true
$callOriginalClone : bool = true
$callAutoload : bool = true
$mockedMethods : array<string|int, mixed> = array()
$cloneArguments : bool = true
Tags
since

Method available since Release 1.2.3

throws
PHPUnit_Framework_MockObject_RuntimeException
throws
PHPUnit_Framework_Exception
Return values
object

getObjectForTrait()

Returns an object for the specified trait.

public getObjectForTrait(string $traitName[, array<string|int, mixed> $arguments = array() ][, string $traitClassName = '' ][, bool $callOriginalConstructor = true ][, bool $callOriginalClone = true ][, bool $callAutoload = true ]) : object
Parameters
$traitName : string
$arguments : array<string|int, mixed> = array()
$traitClassName : string = ''
$callOriginalConstructor : bool = true
$callOriginalClone : bool = true
$callAutoload : bool = true
Tags
since

Method available since Release 1.1.0

throws
PHPUnit_Framework_MockObject_RuntimeException
throws
PHPUnit_Framework_Exception
Return values
object

canMockMethod()

protected canMockMethod(ReflectionMethod $method) : bool
Parameters
$method : ReflectionMethod
Return values
bool

evalClass()

protected evalClass(string $code, string $className) : mixed
Parameters
$code : string
$className : string
Return values
mixed

generateClassName()

protected generateClassName(array<string|int, mixed>|string $type, string $className, string $prefix) : array<string|int, mixed>
Parameters
$type : array<string|int, mixed>|string
$className : string
$prefix : string
Return values
array<string|int, mixed>

generateMock()

protected generateMock(array<string|int, mixed>|string $type, array<string|int, mixed>|null $methods, string $mockClassName, bool $callOriginalClone, bool $callAutoload, bool $cloneArguments, bool $callOriginalMethods) : array<string|int, mixed>
Parameters
$type : array<string|int, mixed>|string
$methods : array<string|int, mixed>|null
$mockClassName : string
$callOriginalClone : bool
$callAutoload : bool
$cloneArguments : bool
$callOriginalMethods : bool
Tags
throws
PHPUnit_Framework_Exception
Return values
array<string|int, mixed>

generateMockClassDeclaration()

protected generateMockClassDeclaration(array<string|int, mixed> $mockClassName, bool $isInterface[, array<string|int, mixed> $additionalInterfaces = array() ]) : array<string|int, mixed>
Parameters
$mockClassName : array<string|int, mixed>
$isInterface : bool
$additionalInterfaces : array<string|int, mixed> = array()
Return values
array<string|int, mixed>

generateMockedMethodDefinition()

protected generateMockedMethodDefinition(string $templateDir, string $className, string $methodName[, bool $cloneArguments = true ][, string $modifier = 'public' ][, string $arguments_decl = '' ][, string $arguments_call = '' ][, string $reference = '' ][, bool $callOriginalMethods = false ][, bool $static = false ]) : string
Parameters
$templateDir : string
$className : string
$methodName : string
$cloneArguments : bool = true
$modifier : string = 'public'
$arguments_decl : string = ''
$arguments_call : string = ''
$reference : string = ''
$callOriginalMethods : bool = false
$static : bool = false
Return values
string

generateMockedMethodDefinitionFromExisting()

protected generateMockedMethodDefinitionFromExisting(string $templateDir, ReflectionMethod $method, bool $cloneArguments, bool $callOriginalMethods) : string
Parameters
$templateDir : string
$method : ReflectionMethod
$cloneArguments : bool
$callOriginalMethods : bool
Return values
string

getMethodParameters()

Returns the parameters of a function or method.

protected getMethodParameters(ReflectionMethod $method[, bool $forCall = false ]) : string
Parameters
$method : ReflectionMethod
$forCall : bool = false
Tags
throws
PHPUnit_Framework_MockObject_RuntimeException
since

Method available since Release 2.0.0

Return values
string

getObject()

protected getObject(string $code, string $className[, array<string|int, mixed>|string $type = '' ][, bool $callOriginalConstructor = false ][, bool $callAutoload = false ][, array<string|int, mixed> $arguments = array() ][, bool $callOriginalMethods = false ][, object $proxyTarget = null ]) : object
Parameters
$code : string
$className : string
$type : array<string|int, mixed>|string = ''
$callOriginalConstructor : bool = false
$callAutoload : bool = false
$arguments : array<string|int, mixed> = array()
$callOriginalMethods : bool = false
$proxyTarget : object = null
Return values
object

getClassMethods()

private getClassMethods(string $className) : array<string|int, mixed>
Parameters
$className : string
Tags
since

Method available since Release 2.3.2

Return values
array<string|int, mixed>

hasType()

private hasType(ReflectionParameter $parameter) : bool
Parameters
$parameter : ReflectionParameter
Tags
since

Method available since Release 2.3.4

Return values
bool

isVariadic()

private isVariadic(ReflectionParameter $parameter) : bool
Parameters
$parameter : ReflectionParameter
Tags
since

Method available since Release 2.2.1

Return values
bool

Search results