PHP Class Mockery\Container

显示文件 Open project: padraic/mockery Class Usage Examples

Protected Properties

Property Type Description
$_allocatedOrder integer Order number of allocation
$_currentOrder integer Current ordered number
$_generator Mockery\Generator\Generator\Generator
$_groups array Ordered groups
$_loader Mockery\Loader\Loader
$_mocks array Store of mock objects
$_namedMocks array

Public Methods

Method Description
__construct ( Mockery\Generator\Generator $generator = null, Mockery\Loader\Loader $loader = null )
fetchMock ( $reference ) : Mock Return a specific remembered mock according to the array index it was stored to in this container instance
getGenerator ( )
getKeyOfDemeterMockFor ( string $method ) : string | null
getLoader ( )
getMocks ( ) : array
instanceMock ( )
isValidClassName ( string $className ) : boolean see http://php.net/manual/en/language.oop5.basic.php
mock ( ) : Mock Generates a new mock object for this container
mockery_allocateOrder ( ) : integer Fetch the next available allocation order number
mockery_close ( ) : void Reset the container to its original state
mockery_getCurrentOrder ( ) : integer Get current ordered number
mockery_getExpectationCount ( ) : integer Gets the count of expectations on the mocks
mockery_getGroups ( ) : array Fetch array of ordered groups
mockery_setCurrentOrder ( integer $order ) : integer Set current ordered number
mockery_setGroup ( mixed $group, integer $order ) Set ordering for a group
mockery_teardown ( ) : void Tear down tasks for this container
mockery_validateOrder ( string $method, integer $order, Mockery\MockInterface $mock ) : void Validate the current mock's ordering
mockery_verify ( ) : void Verify the container mocks
rememberMock ( Mockery\MockInterface $mock ) : Mock Store a mock and set its container reference
self ( ) : Mock Retrieve the last remembered mock object, which is the same as saying retrieve the current mock being programmed where you have yet to call mock() to change it - thus why the method name is "self" since it will be be used during the programming of the same mock.

Protected Methods

Method Description
_getInstance ( $mockName, $constructorArgs = null )
checkForNamedMockClashes ( $config )

Method Details

__construct() public method

public __construct ( Mockery\Generator\Generator $generator = null, Mockery\Loader\Loader $loader = null )
$generator Mockery\Generator\Generator
$loader Mockery\Loader\Loader

_getInstance() protected method

protected _getInstance ( $mockName, $constructorArgs = null )

checkForNamedMockClashes() protected method

protected checkForNamedMockClashes ( $config )

fetchMock() public method

Return a specific remembered mock according to the array index it was stored to in this container instance
public fetchMock ( $reference ) : Mock
return Mock

getGenerator() public method

public getGenerator ( )

getKeyOfDemeterMockFor() public method

public getKeyOfDemeterMockFor ( string $method ) : string | null
$method string
return string | null

getLoader() public method

public getLoader ( )

getMocks() public method

public getMocks ( ) : array
return array

instanceMock() public method

public instanceMock ( )

isValidClassName() public method

see http://php.net/manual/en/language.oop5.basic.php
public isValidClassName ( string $className ) : boolean
$className string
return boolean

mock() public method

I apologies in advance for this. A God Method just fits the API which doesn't require differentiating between classes, interfaces, abstracts, names or partials - just so long as it's something that can be mocked. I'll refactor it one day so it's easier to follow.
public mock ( ) : Mock
return Mock

mockery_allocateOrder() public method

Fetch the next available allocation order number
public mockery_allocateOrder ( ) : integer
return integer

mockery_close() public method

Reset the container to its original state
public mockery_close ( ) : void
return void

mockery_getCurrentOrder() public method

Get current ordered number

mockery_getExpectationCount() public method

Gets the count of expectations on the mocks

mockery_getGroups() public method

Fetch array of ordered groups
public mockery_getGroups ( ) : array
return array

mockery_setCurrentOrder() public method

Set current ordered number
public mockery_setCurrentOrder ( integer $order ) : integer
$order integer
return integer The current order number that was set

mockery_setGroup() public method

Set ordering for a group
public mockery_setGroup ( mixed $group, integer $order )
$group mixed
$order integer

mockery_teardown() public method

Tear down tasks for this container
public mockery_teardown ( ) : void
return void

mockery_validateOrder() public method

Validate the current mock's ordering
public mockery_validateOrder ( string $method, integer $order, Mockery\MockInterface $mock ) : void
$method string
$order integer
$mock Mockery\MockInterface
return void

mockery_verify() public method

Verify the container mocks
public mockery_verify ( ) : void
return void

rememberMock() public method

Store a mock and set its container reference
public rememberMock ( Mockery\MockInterface $mock ) : Mock
$mock Mockery\MockInterface
return Mock

self() public method

Retrieve the last remembered mock object, which is the same as saying retrieve the current mock being programmed where you have yet to call mock() to change it - thus why the method name is "self" since it will be be used during the programming of the same mock.
public self ( ) : Mock
return Mock

Property Details

$_allocatedOrder protected_oe property

Order number of allocation
protected int $_allocatedOrder
return integer

$_currentOrder protected_oe property

Current ordered number
protected int $_currentOrder
return integer

$_generator protected_oe property

protected Generator,Mockery\Generator\Generator $_generator
return Mockery\Generator\Generator\Generator

$_groups protected_oe property

Ordered groups
protected array $_groups
return array

$_loader protected_oe property

protected Loader,Mockery\Loader $_loader
return Mockery\Loader\Loader

$_mocks protected_oe property

Store of mock objects
protected array $_mocks
return array

$_namedMocks protected_oe property

protected array $_namedMocks
return array