PHPackages                             rasuvaeff/understudy-testo - 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. rasuvaeff/understudy-testo

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

rasuvaeff/understudy-testo
==========================

Testo adapter for the understudy test double library: automatic verification and cleanup after every test

v0.1.0(today)019↑2584.2%BSD-3-ClausePHPPHP 8.3 - 8.5CI passing

Since Aug 25Pushed todayCompare

[ Source](https://github.com/rasuvaeff/understudy-testo)[ Packagist](https://packagist.org/packages/rasuvaeff/understudy-testo)[ Docs](https://github.com/rasuvaeff/understudy-testo)[ RSS](/packages/rasuvaeff-understudy-testo/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

rasuvaeff/understudy-testo
==========================

[](#rasuvaeffunderstudy-testo)

[![Latest Stable Version](https://camo.githubusercontent.com/fdc5cf6a303aeb7596a541e0cb8cddf0cfbb747bf64c5513d18eeb0afbad6ee8/68747470733a2f2f706f7365722e707567782e6f72672f7261737576616566662f756e64657273747564792d746573746f2f76)](https://packagist.org/packages/rasuvaeff/understudy-testo)[![Total Downloads](https://camo.githubusercontent.com/02736cf00eaf80dafeccb57d906a8bb9689313faab2be2cba92fc798a6f00952/68747470733a2f2f706f7365722e707567782e6f72672f7261737576616566662f756e64657273747564792d746573746f2f646f776e6c6f616473)](https://packagist.org/packages/rasuvaeff/understudy-testo)[![Build](https://github.com/rasuvaeff/understudy-testo/actions/workflows/build.yml/badge.svg)](https://github.com/rasuvaeff/understudy-testo/actions/workflows/build.yml)[![Static analysis](https://github.com/rasuvaeff/understudy-testo/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/rasuvaeff/understudy-testo/actions/workflows/static-analysis.yml)[![Psalm level](https://camo.githubusercontent.com/68f7f31799f2b93c710b14ba3877072e7fe07ec9d7cee3fdf67e14beab3e1b6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7073616c6d2d6c6576656c5f312d626c75652e737667)](https://github.com/rasuvaeff/understudy-testo/actions/workflows/static-analysis.yml)[![PHP](https://camo.githubusercontent.com/f92b502309d690807f48efa8760d0b3f6207991fca0226595d9872d105c68cd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7261737576616566662f756e64657273747564792d746573746f2f706870)](https://packagist.org/packages/rasuvaeff/understudy-testo)[![License](https://camo.githubusercontent.com/6cb285b57819f8de0acfb34923298f4f569f962544e8fe35331da2d163f4e485/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d626c75652e737667)](LICENSE.md)[Русская версия](README.ru.md)

Testo adapter for [rasuvaeff/understudy](https://github.com/rasuvaeff/understudy) — a test double library where a configured call is a real call: `when(fn () => $repo->find(123))->returns($book)`.

The plugin ends every plain Testo test with understudy's own bookkeeping done for you:

- **verify after success** — after a passing body, every `expect()` is checked. An expectation the code under test never fulfilled turns the pass into a failure;
- **original failure wins** — after a failing or skipped body nothing is verified, so the adapter can never mask the error that actually happened;
- **reset always** — the context is dropped after every test, in `finally`. One test can never leak a double, an expectation or a stub into the next.

Verification is for plain `#[Test]` tests. `#[TestInline]` cases and benchmarks are not verified — an inline case is meant to be a pure, deterministic table-driven check with no setup to answer for, and a benchmark would pay for verification on every iteration. Keep doubles in plain tests. The reset is not scoped that way: whatever the kind of test, its doubles are dropped when it ends, so an inline case cannot hand a leftover to the test after it.

> Using an AI coding assistant? [llms.txt](llms.txt) is a compact API reference it can load instead of guessing.

Requirements
------------

[](#requirements)

- PHP 8.3 – 8.5
- `rasuvaeff/understudy` (`^0.1`)
- `testo/testo` (`^0.10.42`)

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

[](#installation)

```
composer require --dev rasuvaeff/understudy-testo
```

Usage
-----

[](#usage)

Register the plugin on the suites that use doubles:

```
// testo.php
use Rasuvaeff\Understudy\Testo\UnderstudyPlugin;
use Testo\Application\Config\ApplicationConfig;
use Testo\Application\Config\SuiteConfig;

return new ApplicationConfig(
    src: ['src'],
    suites: [
        new SuiteConfig(
            name: 'Unit',
            location: ['tests'],
            plugins: [new UnderstudyPlugin()],
        ),
    ],
);
```

Then write tests as the core package documents them — no manual cleanup:

```
