Prophecy VS phpunit-injector

Compare Prophecy vs phpunit-injector and see what are their differences.

Prophecy

Highly opinionated mocking framework for PHP 5.3+ (by phpspec)

phpunit-injector

Injects services from a PSR-11 dependency injection container to PHPUnit test cases (by jakzal)
Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
Prophecy phpunit-injector
2 1
8,530 61
-0.0% -
6.5 4.0
20 days ago 3 months ago
PHP PHP
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

Prophecy

Posts with mentions or reviews of Prophecy. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2021-03-18.
  • Test doubles
    3 projects | dev.to | 18 Mar 2021
    Prophecy is a framework for creating test doubles that was initially built for the requirements of phpspec, but it can be used with any other PHP testing framework. Since PHPUnit 4.5 it bundles Prophecy within PHPUnit itself, but as of PHPUnit 9.x this bundling is deprecated and set to be removed in PHPUnit 10.
  • Testing with immutable PSR-7 objects and Prophecy
    3 projects | dev.to | 4 Mar 2021
    Recently I have been working a lot with PSR-15 and PSR-18 and one of the characteristics of these recommendations is that it uses the immutable objects specified in PSR-7. Soon after we introduced PSR-18 in our codebase a colleague implemented a client including a unit test that was passing. And yet the code was failing when run in the browser. The cause of this was that the fact that RequestInterface objects are immutable by specification was overlooked. Due to the use of Prophecy and prophesized objects we were struggling to properly test it. Until another colleague introduced me to Argument::that() that is.

phpunit-injector

Posts with mentions or reviews of phpunit-injector. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2021-03-04.
  • Testing with immutable PSR-7 objects and Prophecy
    3 projects | dev.to | 4 Mar 2021
    This unit test will fail when ran against the implementation from earlier. And in this situation a failing test is a good thing. But for this specific situation another "issue" has made it's way into the testcase; the unit test is now depending on the implementation that is being used for PSR-7. When working in a large codebase - like I currently am - one might have more than just a few usages of these interfaces and thus unit tests. Using the suggested approach, instantiating value objects instead of prophesizing, will lead to a large amount of object instantiations. And this will make switching to another implementation more work. Ideally this instantiating is centralized as much as possible. This is exactly why PSR-17 - HTTP Factories - was introduced. Typically dependencies - like these factories - are injected. For unit tests this is not feasible without plugins. My solution is a bit less fancy; a trait:

What are some alternatives?

When comparing Prophecy and phpunit-injector you can also consider the following projects:

Mockery - Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL).

doctrine-test-bundle - Symfony bundle to isolate your app's doctrine database tests and improve the test performance

Codeception - Full-stack testing PHP framework

Symfony DI - Allows you to standardize and centralize the way objects are constructed in your application

PHPUnit - The PHP Unit Testing framework.

php-ddd-example - 🐘🎯 Hexagonal Architecture + DDD + CQRS in PHP using Symfony 6

Phake - PHP Mocking Framework

AspectMock - The most powerful and flexible mocking framework for PHPUnit / Codeception.

BrainMonkey - Mocking utility for PHP functions and WordPress plugin API

Behat - BDD in PHP

phpunit-architecture-test - PHPUnit Application Architecture Test. For architecture tests