mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
tests: update to use snapshot for help output
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__ . '/../.snapshots/help-command.txt';
|
||||
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help', '--colors=never']));
|
||||
|
||||
@ -9,5 +11,15 @@ test('visual snapshot of help command output', function () {
|
||||
return $process->getOutput();
|
||||
};
|
||||
|
||||
expect($output())->toContain('Pest Options:');
|
||||
});
|
||||
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