feat: add Pest helper functions for testing

This commit introduces helper functions for running tests in Pest,
including `afterEach`, `beforeEach`, `test`, and `it`.
This commit is contained in:
Jérémy Munsch 2026-09-20 13:25:30 +02:00
parent d1a4f83feb
commit ec6c1cf9f0
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4

View file

@ -0,0 +1,55 @@
<?php
namespace {
/**
* Runs the given closure after each test in the current file.
*
* @param-closure-this \Tests\TestCase $closure
*/
function afterEach(?Closure $closure = null): \Pest\PendingCalls\AfterEachCall {}
/**
* Runs the given closure before each test in the current file.
*
* @param-closure-this \Tests\TestCase $closure
*/
function beforeEach(?Closure $closure = null): \Pest\PendingCalls\BeforeEachCall {}
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
* a closure that contains the test expectations.
*
* @param-closure-this \Tests\TestCase $closure
*
* @return ($description is string ? TestCall : HigherOrderTapProxy|TestCall)
*/
function test(?string $description = null, ?Closure $closure = null): \Pest\Support\HigherOrderTapProxy|\Pest\PendingCalls\TestCall {}
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
* a closure that contains the test expectations.
*
* @param-closure-this \Tests\TestCase $closure
*/
function it(string $description, ?Closure $closure = null): \Pest\PendingCalls\TestCall {}
}
namespace Pest {
class Expectation {
public function toBeOne(): self {}
}
}
namespace Pest\Expectations {
class OppositeExpectation {
public function toBeOne(): self {}
}
}