PHPackages                             codetetic/pest-plugin-prophecy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. codetetic/pest-plugin-prophecy

ActiveLibrary[Testing &amp; Quality](/categories/testing)

codetetic/pest-plugin-prophecy
==============================

Pest Prophecy Plugin

0.0.2(12mo ago)00MITPHPPHP ^8.1.0

Since May 19Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/codetetic/pest-plugin-prophecy)[ Packagist](https://packagist.org/packages/codetetic/pest-plugin-prophecy)[ RSS](/packages/codetetic-pest-plugin-prophecy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (4)Used By (0)

Pest Prophecy Plugin
====================

[](#pest-prophecy-plugin)

This project is a Pest Prophecy Plugin that provides additional assertion capabilities for testing in PHP using the Prophecy library.

Prerequisites
-------------

[](#prerequisites)

- PHP 8.1 or higher
- PestPHP 2.36 or higher
- Prophecy 1.22 or higher
- Composer

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require --dev codetetic/pest-plugin-prophecy
```

Usage
-----

[](#usage)

This plugin provides a set of functions to enhance the Pest testing framework with Prophecy capabilities.

### Setup

[](#setup)

```
// Pest.php

uses(Pest\Prophecy\ProphecyTrait::class)->in('Unit');
```

### Example Tests

[](#example-tests)

Below are some example tests that demonstrate the features of this plugin:

#### Basic Example

[](#basic-example)

```
use function Pest\Prophecy\prophesize;
use function Pest\Prophecy\reveal;

class Example
{
}

it('can be accessed as a function', function (): void {
    $prophecy = prophesize(Example::class);

    expect($prophecy)
        ->toBeInstanceOf(Prophecy\Prophecy\ObjectProphecy::class);

    expect($prophecy->reveal())
        ->toBeInstanceOf(Example::class);
});

it('can be accessed as a function and use reveal helper', function (): void {
    expect(prophesize(Example::class))
        ->toBeInstanceOf(Prophecy\Prophecy\ObjectProphecy::class);

    expect(reveal(Example::class))
        ->toBeInstanceOf(Example::class);
});
```

#### Autowire Example

[](#autowire-example)

```
use function Pest\Prophecy\argument;
use function Pest\Prophecy\autowire;
use function Pest\Prophecy\exact;

class ExampleAutowire
{
    public function __construct(
        public string $string,
    ) {
    }

    public function string(string $string): string
    {
        return $string;
    }
}

final class ExampleAutowireWrapper
{
    public function __construct(
        public ExampleAutowire $object,
    ) {
    }

    public function string(string $string): string
    {
        return $this->object->string($string);
    }
}

it('can be autowired', function (): void {
    $object = autowire(ExampleAutowireWrapper::class);

    expect(argument('object'))
        ->toBeInstanceOf(Prophecy\Prophecy\ObjectProphecy::class);

    argument('object')
        ->string(exact('format'))
        ->shouldBeCalled()
        ->willReturn('result');

    expect($object)
        ->toBeInstanceOf(ExampleAutowireWrapper::class);

    expect($object->object)
        ->toBeInstanceOf(ExampleAutowire::class);

    expect($object->string('format'))
        ->toBe('result');
});
```

#### Argument Tests

[](#argument-tests)

```
use function Pest\Prophecy\prophesize;
use function Pest\Prophecy\reveal;
use function Pest\Prophecy\allOf;
use function Pest\Prophecy\exact;
use function Pest\Prophecy\type;

class Example
{
    public function __construct(
        public string $string,
    ) {
    }

    public function string(string $string): string
    {
        return $string;
    }
}

it('can be asserted with allOf()', function (): void {
    prophesize(Example::class)
        ->string(allOf(exact('format'), type('string')))
        ->shouldBeCalled()
        ->willReturn('result');

    expect(reveal(Example::class)->string('format'))
        ->toBe('result');
});

it('can be asserted with allOf()', function (): void {
    prophesize(Example::class)
        ->string(allOf(exact('format'), type('string')))
        ->shouldBeCalled()
        ->willReturn('result');

    expect(reveal(Example::class)->string('format'))
        ->toBe('result');
});

// More tests demonstrating the use of different argument tokens like `any`, `exact`, `in`, `notIn`, `size`, `withEntry`, etc.
```

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE.md file for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or create an issue for any bugs or feature requests.

Contact
-------

[](#contact)

For any inquiries, please contact Peter Measham at .

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance61

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

364d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd89f242d3eb9590beed04e6f32c51aac0e7a562fbc0e400a24c12b9433fc0f1?d=identicon)[codetetic](/maintainers/codetetic)

---

Top Contributors

[![codetetic](https://avatars.githubusercontent.com/u/121065313?v=4)](https://github.com/codetetic "codetetic (39 commits)")

###  Code Quality

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/codetetic-pest-plugin-prophecy/health.svg)

```
[![Health](https://phpackages.com/badges/codetetic-pest-plugin-prophecy/health.svg)](https://phpackages.com/packages/codetetic-pest-plugin-prophecy)
```

###  Alternatives

[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2021.0M277](/packages/drupal-core-dev)[phpspec/prophecy-phpunit

Integrating the Prophecy mocking library in PHPUnit test cases

19454.9M1.4k](/packages/phpspec-prophecy-phpunit)[spatie/pest-plugin-snapshots

A package for snapshot testing in Pest

381.7M157](/packages/spatie-pest-plugin-snapshots)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
