webmaesther / pest-plugin-contract
Pest plugin to define contract tests
Fund package maintenance!
revolut.me/itesz
Requires
- php: ^8.3
- pestphp/pest: ^4.0.0
- pestphp/pest-plugin: ^4.0.0
Requires (Dev)
- pestphp/pest-dev-tools: ^4.0.0
- pestphp/pest-plugin-faker: ^4.0
This package is auto-updated.
Last update: 2025-09-18 18:40:07 UTC
README
This repository contains the Pest Plugin Contract.
If you want to start testing your application with Pest, visit the main Pest Repository.
Requirements
- Pest v4
Installation
composer require webmaesther/pest-plugin-contract --dev
Usage
Define your contracts anywhere in your test folder in *Contract.php
files.
contract('is string', function() { test('its type is string', function(mixed $value) { expect($value)->toBeString(); }) });
Then you can use your contracts in any of your test files.
fulfill('is string')->with(['string']);
The fullfill
function simply creates a describe block out of your contract closure, and includes it in your test file, exactly where you put it, as if you yourself would have written it. Thus, you can use any method on it that you would use on a describe block. Most notably you will need the with()
method, which you should use to parametrize your tests with any Pest compatible dataset you like.