Documentation

MockBuilder
in package

FinalYes
Tags
psalm-template

MockedType

no-named-arguments

Parameter names are not covered by the backward compatibility promise for PHPUnit

Table of Contents

Properties

$allowMockingUnknownTypes  : bool
$autoload  : bool
$callOriginalMethods  : bool
$cloneArguments  : bool
$constructorArgs  : array<string|int, mixed>
$emptyMethodsArray  : bool
$generator  : Generator
$methods  : null|array<string|int, string>
$mockClassName  : string
$originalClone  : bool
$originalConstructor  : bool
$proxyTarget  : object|null
$returnValueGeneration  : bool
$testCase  : TestCase
$type  : string

Methods

__construct()  : mixed
addMethods()  : $this
Specifies methods that don't exist in the class which you want to mock.
allowMockingUnknownTypes()  : $this
disableArgumentCloning()  : $this
Disables the cloning of arguments passed to mocked methods.
disableAutoload()  : $this
Disables the use of class autoloading while creating the mock object.
disableAutoReturnValueGeneration()  : $this
disableOriginalClone()  : $this
Disables the invocation of the original clone constructor.
disableOriginalConstructor()  : $this
Disables the invocation of the original constructor.
disableProxyingToOriginalMethods()  : $this
Disables the invocation of the original methods.
disallowMockingUnknownTypes()  : $this
enableArgumentCloning()  : $this
Enables the cloning of arguments passed to mocked methods.
enableAutoload()  : $this
Enables the use of class autoloading while creating the mock object.
enableAutoReturnValueGeneration()  : $this
enableOriginalClone()  : $this
Enables the invocation of the original clone constructor.
enableOriginalConstructor()  : $this
Enables the invocation of the original constructor.
enableProxyingToOriginalMethods()  : $this
Enables the invocation of the original methods.
getMock()  : MockObject
Creates a mock object using a fluent interface.
getMockForAbstractClass()  : MockObject
Creates a mock object for an abstract class using a fluent interface.
getMockForTrait()  : MockObject
Creates a mock object for a trait using a fluent interface.
onlyMethods()  : $this
Specifies the subset of methods to mock, requiring each to exist in the class.
setConstructorArgs()  : $this
Specifies the arguments for the constructor.
setMethods()  : $this
Specifies the subset of methods to mock. Default is to mock none of them.
setMethodsExcept()  : self
Specifies the subset of methods to not mock. Default is to mock all of them.
setMockClassName()  : $this
Specifies the name for the mock class.
setProxyTarget()  : $this
Sets the proxy target.

Properties

$allowMockingUnknownTypes

private bool $allowMockingUnknownTypes = true

$callOriginalMethods

private bool $callOriginalMethods = false

$cloneArguments

private bool $cloneArguments = false

$constructorArgs

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

$emptyMethodsArray

private bool $emptyMethodsArray = false

$methods

private null|array<string|int, string> $methods = []

$originalConstructor

private bool $originalConstructor = true

$returnValueGeneration

private bool $returnValueGeneration = true

Methods

__construct()

public __construct(TestCase $testCase, string|array<string|int, string> $type) : mixed
Parameters
$testCase : TestCase
$type : string|array<string|int, string>
Tags
psalm-param

class-string<MockedType>|string|string[] $type

addMethods()

Specifies methods that don't exist in the class which you want to mock.

public addMethods(array<string|int, string> $methods) : $this
Parameters
$methods : array<string|int, string>
Tags
throws
CannotUseAddMethodsException
throws
ReflectionException
throws
RuntimeException
Return values
$this

allowMockingUnknownTypes()

public allowMockingUnknownTypes() : $this
Return values
$this

disableArgumentCloning()

Disables the cloning of arguments passed to mocked methods.

public disableArgumentCloning() : $this
Return values
$this

disableAutoload()

Disables the use of class autoloading while creating the mock object.

public disableAutoload() : $this
Return values
$this

disableAutoReturnValueGeneration()

public disableAutoReturnValueGeneration() : $this
Return values
$this

disableOriginalClone()

Disables the invocation of the original clone constructor.

public disableOriginalClone() : $this
Return values
$this

disableOriginalConstructor()

Disables the invocation of the original constructor.

public disableOriginalConstructor() : $this
Return values
$this

disableProxyingToOriginalMethods()

Disables the invocation of the original methods.

public disableProxyingToOriginalMethods() : $this
Return values
$this

disallowMockingUnknownTypes()

public disallowMockingUnknownTypes() : $this
Return values
$this

enableArgumentCloning()

Enables the cloning of arguments passed to mocked methods.

public enableArgumentCloning() : $this
Return values
$this

enableAutoload()

Enables the use of class autoloading while creating the mock object.

public enableAutoload() : $this
Return values
$this

enableAutoReturnValueGeneration()

public enableAutoReturnValueGeneration() : $this
Return values
$this

enableOriginalClone()

Enables the invocation of the original clone constructor.

public enableOriginalClone() : $this
Return values
$this

enableOriginalConstructor()

Enables the invocation of the original constructor.

public enableOriginalConstructor() : $this
Return values
$this

enableProxyingToOriginalMethods()

Enables the invocation of the original methods.

public enableProxyingToOriginalMethods() : $this
Return values
$this

getMock()

Creates a mock object using a fluent interface.

public getMock() : MockObject
Tags
throws
ClassAlreadyExistsException
throws
ClassIsFinalException
throws
ClassIsReadonlyException
throws
DuplicateMethodException
throws
InvalidArgumentException
throws
InvalidMethodNameException
throws
OriginalConstructorInvocationRequiredException
throws
ReflectionException
throws
RuntimeException
throws
UnknownTypeException
psalm-return

MockObject&MockedType

Return values
MockObject

getMockForAbstractClass()

Creates a mock object for an abstract class using a fluent interface.

public getMockForAbstractClass() : MockObject
Tags
psalm-return

MockObject&MockedType

throws
Exception
throws
ReflectionException
throws
RuntimeException
Return values
MockObject

getMockForTrait()

Creates a mock object for a trait using a fluent interface.

public getMockForTrait() : MockObject
Tags
psalm-return

MockObject&MockedType

throws
Exception
throws
ReflectionException
throws
RuntimeException
Return values
MockObject

onlyMethods()

Specifies the subset of methods to mock, requiring each to exist in the class.

public onlyMethods(array<string|int, string> $methods) : $this
Parameters
$methods : array<string|int, string>
Tags
throws
CannotUseOnlyMethodsException
throws
ReflectionException
Return values
$this

setConstructorArgs()

Specifies the arguments for the constructor.

public setConstructorArgs(array<string|int, mixed> $args) : $this
Parameters
$args : array<string|int, mixed>
Return values
$this

setMethods()

Specifies the subset of methods to mock. Default is to mock none of them.

public setMethods([array<string|int, mixed>|null $methods = null ]) : $this

https://github.com/sebastianbergmann/phpunit/pull/3687

Parameters
$methods : array<string|int, mixed>|null = null
Return values
$this

setMethodsExcept()

Specifies the subset of methods to not mock. Default is to mock all of them.

public setMethodsExcept([array<string|int, mixed> $methods = [] ]) : self

https://github.com/sebastianbergmann/phpunit/pull/3687

Parameters
$methods : array<string|int, mixed> = []
Tags
throws
ReflectionException
Return values
self

setMockClassName()

Specifies the name for the mock class.

public setMockClassName(string $name) : $this
Parameters
$name : string
Return values
$this

setProxyTarget()

Sets the proxy target.

public setProxyTarget(object $object) : $this
Parameters
$object : object
Return values
$this

        
On this page

Search results