Merge branch '4.x' into 5.x

This commit is contained in:
nuno maduro
2026-03-10 21:21:24 +00:00
36 changed files with 98 additions and 57 deletions

View File

@ -44,7 +44,6 @@
--filter [pattern] ............................... Filter which tests to run
--exclude-filter [pattern] .. Exclude tests for the specified filter pattern
--test-suffix [suffixes] Only search for test in files with specified suffix(es). Default: Test.php,.phpt
--test-files-file [file] Only run test files listed in file (one file by line)
EXECUTION OPTIONS:
--parallel ........................................... Run tests in parallel

View File

@ -1,5 +1,7 @@
<?php
use Pest\Plugin;
trait PluginTrait
{
public function assertPluginTraitGotRegistered(): void
@ -16,8 +18,8 @@ trait SecondPluginTrait
}
}
Pest\Plugin::uses(PluginTrait::class);
Pest\Plugin::uses(SecondPluginTrait::class);
Plugin::uses(PluginTrait::class);
Plugin::uses(SecondPluginTrait::class);
function _assertThat()
{

View File

@ -1,6 +1,6 @@
<?php
$foo = new \stdClass;
$foo = new stdClass;
$foo->bar = 0;
beforeAll(function () use ($foo) {

View File

@ -17,7 +17,7 @@ it('adds coverage if --coverage exist', function () {
$arguments = $plugin->handleArguments(['--coverage']);
expect($arguments)->toEqual(['--coverage-php', Coverage::getPath()])
->and($plugin->coverage)->toBeTrue();
})->skip(! \Pest\Support\Coverage::isAvailable() || ! function_exists('xdebug_info') || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
})->skip(! Coverage::isAvailable() || ! function_exists('xdebug_info') || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
it('adds coverage if --min exist', function () {
$plugin = new CoveragePlugin(new ConsoleOutput);

View File

@ -39,7 +39,7 @@ it('allows to call underlying protected/private methods', function () {
it('throws error if method do not exist', function () {
test()->foo();
})->throws(\ReflectionException::class, 'Call to undefined method PHPUnit\Framework\TestCase::foo()');
})->throws(ReflectionException::class, 'Call to undefined method PHPUnit\Framework\TestCase::foo()');
it('can forward unexpected calls to any global function')->_assertThat();

View File

@ -1,7 +1,9 @@
<?php
use PHPUnit\Framework\TestCase;
/**
* @return \PHPUnit\Framework\TestCase
* @return TestCase
*/
function myAssertTrue($value)
{

View File

@ -1,8 +1,9 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class MyCustomClassTest extends PHPUnit\Framework\TestCase
class MyCustomClassTest extends TestCase
{
public function assertTrueIsTrue()
{

View File

@ -1,6 +1,8 @@
<?php
pest()->use(Tests\CustomTestCase\CustomTestCase::class)->in(__DIR__);
use Tests\CustomTestCase\CustomTestCase;
pest()->use(CustomTestCase::class)->in(__DIR__);
test('closure was bound to CustomTestCase', function () {
$this->assertCustomTrue();

View File

@ -1,5 +1,7 @@
<?php
use PHPUnit\Framework\TestCase;
trait MyCustomTrait
{
public function assertFalseIsFalse()
@ -8,7 +10,7 @@ trait MyCustomTrait
}
}
abstract class MyCustomClass extends PHPUnit\Framework\TestCase
abstract class MyCustomClass extends TestCase
{
public function assertTrueIsTrue()
{

View File

@ -1,7 +1,9 @@
<?php
use Pest\Configuration\Printer;
it('creates a printer instance', function () {
$theme = pest()->printer();
expect($theme)->toBeInstanceOf(Pest\Configuration\Printer::class);
expect($theme)->toBeInstanceOf(Printer::class);
});

View File

@ -1,8 +1,10 @@
<?php
use Symfony\Component\Process\Process;
test('collision', function (array $arguments) {
$output = function () use ($arguments) {
$process = (new Symfony\Component\Process\Process(
$process = (new Process(
array_merge(['php', 'bin/pest', 'tests/Fixtures/CollisionTest.php'], $arguments),
null,
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'COLLISION_TEST' => true]

View File

@ -1,8 +1,10 @@
<?php
use Symfony\Component\Process\Process;
test('visual snapshot of help command output', function () {
$output = function () {
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
$process = (new Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
$process->run();

View File

@ -1,5 +1,7 @@
<?php
use Symfony\Component\Process\Process;
test('visual snapshot of test suite on success', function () {
$testsPath = dirname(__DIR__);
$snapshot = implode(DIRECTORY_SEPARATOR, [
@ -9,7 +11,7 @@ test('visual snapshot of test suite on success', function () {
]);
$output = function () use ($testsPath) {
$process = (new Symfony\Component\Process\Process(
$process = (new Process(
['php', 'bin/pest'],
dirname($testsPath),
['EXCLUDE' => 'integration', '--exclude-group' => 'integration', 'REBUILD_SNAPSHOTS' => false, 'PARATEST' => 0, 'COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],

View File

@ -1,5 +1,7 @@
<?php
use Symfony\Component\Process\Process;
function normalize_windows_os_output(string $text): string
{
$text = str_replace('\r', '', $text);
@ -17,7 +19,7 @@ test('visual snapshot of team city', function (string $testFile) {
]);
$output = function () use ($testsPath) {
$process = (new Symfony\Component\Process\Process(
$process = (new Process(
['php', 'bin/pest', '--teamcity', $testsPath],
dirname(__DIR__, levels: 2),
[

View File

@ -1,8 +1,10 @@
<?php
use Symfony\Component\Process\Process;
test('visual snapshot of help command output', function () {
$output = function () {
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--version'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
$process = (new Process(['php', 'bin/pest', '--version'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
$process->run();