Files
pest/tests/Visual/Parallel.php
T
Owen Voke d534cb2c40 fix: avoid passing an object when invoking static methods via reflection (#1988)
* fix: avoid passing an object when invoking static methods via reflection

PHP 8.6 deprecates passing an object to `ReflectionMethod::invoke()` for
static methods, which breaks higher-order assertions such as
`it('...')->assertTrue(true)` since `Assert::assertTrue()` is static.

* test: update visual snapshots for new reflection tests
2026-10-23 22:05:56 +05:30

59 lines
2.3 KiB
PHP

<?php
use Symfony\Component\Process\Process;
$run = function (): ?string {
$process = new Process(
array_merge(['php', 'bin/pest', '--parallel', '--processes=3'], func_get_args()),
dirname(__DIR__, 2),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'],
);
$process->setTimeout(300.0);
$process->run();
return removeAnsiEscapeSequences($process->getOutput());
};
test('parallel', function () use ($run): void {
$output = $run('--exclude-group=integration');
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1593 passed (3460 assertions)';
expect($output)
->toContain("Tests: {$expected}")
->toContain('Parallel: 3 processes');
})->skipOnWindows();
test('a parallel test can extend another test with same name', function () use ($run): void {
expect($run('tests/Fixtures/Inheritance'))->toContain('Tests: 1 skipped, 1 passed (1 assertions)');
})->skipOnWindows();
test('parallel reports invalid datasets as failures', function () use ($run): void {
expect($run('tests/Fixtures/Suites/ParallelInvalidDataset'))
->toContain("A dataset named [missing.dataset] does not exist. You may create one using `dataset('missing.dataset', ['a', 'b']);`.")
->toContain('Tests: 1 failed, 1 passed (1 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();
test('parallel can have multiple exclude-groups', function () use ($run): void {
$singleExclude = $run('--exclude-group=integration');
$doubleExclude = $run('--exclude-group=integration', '--exclude-group=container');
preg_match('/(\d+) passed/', (string) $singleExclude, $singleMatch);
preg_match('/(\d+) passed/', (string) $doubleExclude, $doubleMatch);
expect((int) $doubleMatch[1])->toBeLessThan((int) $singleMatch[1])
->and($doubleExclude)->toContain('Parallel: 3 processes');
})->skipOnWindows();
test('parallel can have multiple groups', function () use ($run): void {
$output = $run('tests/Fixtures/Suites/MultipleGroups', '--group=one', '--group=two');
expect($output)
->toContain('Tests: 2 passed (2 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();