-
-
Notifications
You must be signed in to change notification settings - Fork 375
/
Copy pathSuccess.php
44 lines (37 loc) · 1.39 KB
/
Success.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
test('visual snapshot of test suite on success', function () {
$testsPath = dirname(__DIR__);
$snapshot = implode(DIRECTORY_SEPARATOR, [
$testsPath,
'.snapshots',
'success.txt',
]);
$output = function () use ($testsPath) {
$process = (new Symfony\Component\Process\Process(
['php', 'bin/pest'],
dirname($testsPath),
['EXCLUDE' => 'integration', 'REBUILD_SNAPSHOTS' => false, 'PARATEST' => 0, 'COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
));
$process->run();
return preg_replace([
'#\\x1b[[][^A-Za-z]*[A-Za-z]#',
'/(Tests\\\PHPUnit\\\CustomAffixes\\\InvalidTestName)([A-Za-z0-9]*)/',
], [
'',
'$1',
], $process->getOutput());
};
if (getenv('REBUILD_SNAPSHOTS')) {
$outputContent = explode("\n", $output());
array_pop($outputContent);
array_pop($outputContent);
array_pop($outputContent);
file_put_contents($snapshot, implode("\n", $outputContent));
} elseif (! getenv('EXCLUDE')) {
$output = explode("\n", $output());
array_pop($output);
array_pop($output);
expect(implode("\n", $output))->toContain(file_get_contents($snapshot));
}
})->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
->skipOnWindows();