Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Prophecy Phpunit Laravel Package

phpspec/prophecy-phpunit

Integrates the Prophecy mocking library with PHPUnit for simpler, cleaner test doubles. Install via Composer and use the ProphecyTrait to call prophesize() inside your TestCase, set method predictions/returns, and reveal mocks for injection.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: This package integrates seamlessly with Laravel's default testing stack (PHPUnit) as a dev-only dependency. It replaces PHPUnit's native mocking with Prophecy's more expressive syntax, aligning perfectly with Laravel's test-driven development culture where precise mock interactions are critical for unit tests. The trait-based approach avoids inheritance conflicts with Laravel's TestCase base class.

Integration feasibility: Extremely high. Requires only a Composer require command and trait addition to test classes. No configuration changes needed for Laravel's test environment. The package has explicit version constraints for PHPUnit/PHP that match Laravel's supported ranges (e.g., Laravel 10+ uses PHPUnit 10+ which requires prophecy-phpunit ≥v2.1.0).

Technical risk: Low. The package has consistent release activity (6 releases in 2023-2024), MIT license, and is a thin wrapper around mature Prophecy library (3.6k stars). "Dependents: 0" is expected for this integration layer. Primary risk is version misalignment if Laravel upgrades PHPUnit without updating this package's constraints.

Key questions:

  • How does it interact with Laravel's Mockery-based test helpers (e.g., fake() for facades)?
  • What's the migration path for existing tests using PHPUnit's createMock()?
  • Does it support Laravel's TestResponse assertions when mocking HTTP clients?

Integration Approach

Stack fit: Ideal for Laravel's unit tests where Prophecy's argument constraints (Argument::type(), Argument::that()) and precise expectation syntax improve test readability over PHPUnit's native mocks. Works alongside Laravel's HTTP test tools (e.g., TestResponse) since it only affects unit test mocking.

Migration path:

  1. Add package: composer require --dev phpspec/prophecy-phpunit
  2. Replace use PHPUnit\Framework\TestCase with use Prophecy\PhpUnit\ProphecyTrait in test classes
  3. Convert existing mocks:
    // Before
    $mock = $this->createMock(Service::class);
    // After
    $mock = $this->prophesize(Service::class);
    
  4. Gradually refactor expectations to use Prophecy syntax (e.g., $mock->method()->shouldBeCalled() instead of `expects()->
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle