Class PHPProphet
A Prophet for built-in PHP functions.
Example:
$prophet = new PHPProphet();
$prophecy = $prophet->prophesize(__NAMESPACE__);
$prophecy->time()->willReturn(123);
$prophecy->reveal();
assert(123 == time());
$prophet->checkPredictions();
Methods summary
public
|
#
__construct( Prophecy\Prophet $prophet = null )
Builds the prophet.
Parameters
- $prophet
- optional proxied prophet
|
public
Prophecy\Prophecy\ProphecyInterface
|
#
prophesize( string $namespace )
Creates a new function prophecy for a given namespace.
Creates a new function prophecy for a given namespace.
Parameters
- $namespace
- function namespace
Returns
Prophecy\Prophecy\ProphecyInterface function prophecy
|
public
|
#
checkPredictions( )
Checks all predictions defined by prophecies of this Prophet.
Checks all predictions defined by prophecies of this Prophet.
It will also disable all previously revealed function prophecies.
Throws
Prophecy\Exception\Prediction\AggregateException If any prediction fails.
|
public static
|
#
define( string $namespace, string $name )
Defines the function prophecy in the given namespace.
Defines the function prophecy in the given namespace.
In most cases you don't have to call this method. phpmock\prophecy\PHPProphet::prophesize()
is doing this for you. But if the prophecy is defined after the first
call in the tested class, the tested class doesn't resolve to the prophecy.
This is documented in Bug #68541. You therefore have to define
the namespaced function before the first call.
Defining the function has no side effects. If the function was
already defined this method does nothing.
Parameters
- $namespace
- function namespace
- $name
- function name
See
Link
|