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 Shim Laravel Package

weirdan/prophecy-shim

Lightweight shim around Prophecy for PHPUnit, helping keep legacy Prophecy-based tests running on newer PHPUnit/Laravel stacks. Provides compatibility glue with minimal changes so you can upgrade tooling without rewriting your mocks.

View on GitHub
Deep Wiki
Context7

Prophecy Shim

Compatibility shim to be able to use ProphecyTrait with older PHPUnit versions.

Motivation

Starting with PHPUnit 9.1 Prophecy integration that used to be provided by PHPUnit itself is deprecated and is scheduled to be removed in PHPUnit 10. There is phpspec/prophecy-phpunit package providing the integration now, but what do you do if you need to run your tests with older PHPUnit versions like 7.x?

This package solves this by providing empty ProphecyTrait for those older versions that you can import into your tests. For PHPUnit 9.1+ it just requires phpspec/prophecy-phpunit that provides the same trait. As a result, you can import the trait into your tests and it will work regardless of the PHPUnit version.

Installation

composer require --dev weirdan/prophecy-shim:'^1.0 || ^2.0'

Usage

<?php

namespace Your\Tests;

use PHPUnit\Framework\TestCase;

// The following trait is provided either by the shim or by phpspec/prophecy-phpunit
use Prophecy\PhpUnit\ProphecyTrait;

class YourTest extends TestCase
{
    use ProphecyTrait;

    public function testSomething(): void
    {
        // this won't throw warnings anymore in PHPUnit 9.1+
        $objectProphecy = $this->prophesize(SomeClass::class);
    }
}
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai