MockContainer
in package
implements
ServiceLocatorInterface
Uses
MockContainerTrait
Container that produces mock objects.
Tags
Interfaces, Classes, Traits and Enums
- ServiceLocatorInterface
Table of Contents
- $disabled : array<string|int, string>
- Disabled services.
- $mockAliases : array<string|int, mixed>
- Common service aliases.
- $mockServices : array<string|int, mixed>
- Services
- $test : TestCase
- Test case (for building mock objects)
- __construct() : mixed
- Constructor
- build() : mixed
- Alias for createMock(), needed to conform to ServiceLocatorInterface.
- createMock() : mixed
- Create a mock object.
- disable() : object
- Disable a service
- get() : mixed
- Finds an entry of the container by its identifier and returns it.
- has() : bool
- Returns true if the container can return an entry for the given identifier.
- set() : object
- Explicitly set an entry in the container.
- setAlias() : object
- Add an alias.
Properties
$disabled
Disabled services.
protected
array<string|int, string>
$disabled
= []
$mockAliases
Common service aliases.
protected
array<string|int, mixed>
$mockAliases
= ['ViewHelperManager' => \Laminas\View\HelperPluginManager::class]
$mockServices
Services
protected
array<string|int, mixed>
$mockServices
= []
$test
Test case (for building mock objects)
protected
TestCase
$test
Methods
__construct()
Constructor
public
__construct(TestCase $test) : mixed
Parameters
- $test : TestCase
-
Test using the container
Return values
mixed —build()
Alias for createMock(), needed to conform to ServiceLocatorInterface.
public
build(string $name[, array<string|int, mixed> $options = null ]) : mixed
Parameters
- $name : string
-
Name of service to build
- $options : array<string|int, mixed> = null
-
Options
Return values
mixed —createMock()
Create a mock object.
public
createMock(string $id[, array<string|int, mixed> $methods = [] ]) : mixed
Parameters
- $id : string
-
Identifier of the service to mock out.
- $methods : array<string|int, mixed> = []
-
Methods to mock.
Return values
mixed —disable()
Disable a service
public
disable(string $id) : object
Parameters
- $id : string
-
Identifier of the entry to disable.
Return values
object —get()
Finds an entry of the container by its identifier and returns it.
public
get(string $rawId[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $rawId : string
-
Identifier of the entry to look for.
- $options : array<string|int, mixed> = []
-
Additional options (used for method list here)
Return values
mixed —has()
Returns true if the container can return an entry for the given identifier.
public
has(string $rawId) : bool
Returns false otherwise.
Parameters
- $rawId : string
-
Identifier of the entry to look for.
Return values
bool —set()
Explicitly set an entry in the container.
public
set(string $id, mixed $obj) : object
Parameters
- $id : string
-
Identifier of the entry to set.
- $obj : mixed
-
The service to set.
Return values
object —setAlias()
Add an alias.
public
setAlias(string $alias, string $target) : object
Parameters
- $alias : string
-
Alias of the service.
- $target : string
-
Target service.