-
-
Notifications
You must be signed in to change notification settings - Fork 312
/
SingleTestOrDirectory.php
43 lines (34 loc) · 1.49 KB
/
SingleTestOrDirectory.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
<?php
use Symfony\Component\Process\Process;
$run = function (string $target, $decorated = false) {
$process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
);
$process->run();
return $decorated ? $process->getOutput() : removeAnsiEscapeSequences($process->getOutput());
};
$snapshot = function ($name) {
$testsPath = dirname(__DIR__);
return file_get_contents(implode(DIRECTORY_SEPARATOR, [
$testsPath,
'.snapshots',
"$name.txt",
]));
};
test('allows to run a single test', function () use ($run, $snapshot) {
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'))->toContain($snapshot('allows-to-run-a-single-test'));
})->skipOnWindows();
test('allows to run a directory', function () use ($run, $snapshot) {
expect($run('tests/Fixtures'))->toContain($snapshot('allows-to-run-a-directory'));
})->skipOnWindows();
it('disable decorating printer when colors is set to never', function () use ($snapshot) {
$process = new Process([
'php',
'./bin/pest',
'--colors=never',
'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']);
$process->run();
$output = $process->getOutput();
expect($output)->toContain($snapshot('disable-decorating-printer'));
})->skipOnWindows();