Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 28, 2024 via composer

phpspec/prophecy v1.18.0

Highly opinionated mocking framework for PHP 5.3+
Package summary
Share
0
issues
2
licenses
8
MIT
4
BSD-3-Clause
Package created
25 Mar 2013
Version published
7 Dec 2023
Maintainers
2
Total deps
12
Direct deps
4
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
8 Packages, Including:
doctrine/deprecations@1.1.3
doctrine/instantiator@2.0.0
phpdocumentor/reflection-common@2.2.0
phpdocumentor/reflection-docblock@5.4.0
phpdocumentor/type-resolver@1.8.2
phpspec/prophecy@v1.18.0
phpstan/phpdoc-parser@1.28.0
webmozart/assert@1.11.0

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
4 Packages, Including:
sebastian/comparator@5.0.1
sebastian/diff@5.1.1
sebastian/exporter@5.1.2
sebastian/recursion-context@5.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

4
All Dependencies CSV
β“˜ This is a list of phpspec/prophecy 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
doctrine/instantiator2.0.010.75 kBMIT
prod
phpdocumentor/reflection-docblock5.4.0-MIT
prod
sebastian/comparator5.0.119.55 kBBSD-3-Clause
prod
sebastian/recursion-context5.0.05.15 kBBSD-3-Clause
prod

Visualizations

Frequently Asked Questions

What does phpspec/prophecy do?

As a highly opinionated PHP object mocking framework, phpspec/prophecy is incredibly flexible and can be used in virtually any testing framework with only a minimal amount of required effort. It facilitates the creation of object prophecies and "dummies", which are basic PHP objects that serve only to fulfil prophecies. It even supports the creation of "stubs" or "mocks", which are object doubles with specific environments and behaviors, and allows for the customization of method prophecies, promises, and predictions. Furthermore, phpspec/prophecy offers functionalities for defining and inspecting argument tokens and for creating and working with spies.

How do you use phpspec/prophecy?

Use of phpspec/prophecy involves the instantiation of a Prophet object, which can create object prophecies. A simple example of this would be:

$prophet = new Prophecy\Prophet;
$prophecy = $prophet->prophesize();
$prophecy->willExtend('stdClass');

You can create "dummies" and "stubs" with reveal(). For instance:

$dummy = $prophecy->reveal();

Or a stub with behavior like:

$prophecy->read('123')->willReturn('value');
$stub = $prophecy->reveal();

For more complex behaviors, you can use argument tokens and callbacks. Here's an example:

use Prophecy\Argument;
$user->setName(Argument::type('string'))->will(function ($args) {
    $this->getName()->willReturn($args[0]);
});

You can also create mocks with 'predictions':

$entityManager->flush()->shouldBeCalled();

And spies with shouldHave:

$em = $prophet->prophesize('Doctrine\ORM\EntityManager');
$controller->createUser($em->reveal());
$em->flush()->shouldHaveBeenCalled();

Check how all your predictions played out with checkPredictions() as in:

$prophet->checkPredictions();

Where are the phpspec/prophecy docs?

The documentation for phpspec/prophecy is contained within the package's README on its GitHub page, which you can access at https://github.com/phpspec/prophecy. Here, you will find thorough explanations for how to use the package, as well as sample code to illustrate major concepts and mechanics.