mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
tests: update help snapshot to only include Pest options
This commit is contained in:
@ -1,25 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Pest\Console\Help;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__ . '/../.snapshots/help-command.txt';
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
$outputBuffer = new BufferedOutput();
|
||||
$plugin = new Help($outputBuffer);
|
||||
|
||||
$plugin();
|
||||
|
||||
file_put_contents($snapshot, $outputBuffer->fetch());
|
||||
}
|
||||
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help', '--colors=never']));
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help']));
|
||||
|
||||
$process->run();
|
||||
|
||||
return $process->getOutput();
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
// Strip versions from start of snapshot
|
||||
$outputContent = preg_replace([
|
||||
'/Pest \s+\d+\.\d+\.\d+\s+/m',
|
||||
'/PHPUnit \d+\.\d+\.\d+\s+.*?\n/m'
|
||||
], '', $output());
|
||||
|
||||
file_put_contents($snapshot, $outputContent);
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
Reference in New Issue
Block a user