mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
chore: uses snapshot testing in some visual testing
This commit is contained in:
@ -1,12 +1,6 @@
|
||||
<?php
|
||||
|
||||
test('collision', function (array $arguments) {
|
||||
$snapshot = __DIR__.'/../.snapshots/collision.txt';
|
||||
|
||||
if (in_array('--parallel', $arguments)) {
|
||||
$snapshot = __DIR__.'/../.snapshots/collision-parallel.txt';
|
||||
}
|
||||
|
||||
$output = function () use ($arguments) {
|
||||
$process = (new Symfony\Component\Process\Process(
|
||||
array_merge(['php', 'bin/pest', 'tests/Fixtures/CollisionTest.php'], $arguments),
|
||||
@ -19,23 +13,17 @@ test('collision', function (array $arguments) {
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
$outputContent = explode("\n", $output());
|
||||
$outputContent = explode("\n", $output());
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
|
||||
if (in_array('--parallel', $arguments)) {
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
|
||||
if (in_array('--parallel', $arguments)) {
|
||||
array_pop($outputContent);
|
||||
array_pop($outputContent);
|
||||
}
|
||||
|
||||
file_put_contents($snapshot, implode("\n", $outputContent));
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
expect(implode("\n", $outputContent))->toMatchSnapshot();
|
||||
})->with([
|
||||
[['']],
|
||||
[['--parallel']],
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<?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'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||
|
||||
@ -11,11 +9,5 @@ test('visual snapshot of help command output', function () {
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
file_put_contents($snapshot, $output());
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
expect($output())->toMatchSnapshot();
|
||||
})->skipOnWindows();
|
||||
|
||||
@ -11,8 +11,6 @@ $run = function () {
|
||||
|
||||
$process->run();
|
||||
|
||||
// expect($process->getExitCode())->toBe(0);
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user