mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Merge pull request #51 from Jibbarth/feature/support-colors-never
Feature/support colors never
This commit is contained in:
@ -21,7 +21,7 @@ final class AddsDefaults
|
||||
public static function to(array $arguments): array
|
||||
{
|
||||
if (!array_key_exists('printer', $arguments)) {
|
||||
$arguments['printer'] = new Printer();
|
||||
$arguments['printer'] = new Printer(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? 'always');
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
|
||||
@ -124,9 +124,11 @@
|
||||
PASS Tests\Visual\SingleTestOrDirectory
|
||||
✓ allows to run a single test
|
||||
✓ allows to run a directory
|
||||
✓ it has ascii chars (decorated printer)
|
||||
✓ it disable decorating printer when colors is set to never
|
||||
|
||||
WARN Tests\Visual\Success
|
||||
s visual snapshot of test suite on success
|
||||
|
||||
Tests: 6 skipped, 67 passed
|
||||
Time: 2.67s
|
||||
Tests: 6 skipped, 69 passed
|
||||
Time: 2.34s
|
||||
|
||||
@ -30,3 +30,37 @@ test('allows to run a directory', function () use ($run) {
|
||||
Tests: 2 passed
|
||||
EOF, $run('tests/Fixtures'));
|
||||
});
|
||||
|
||||
it('has ascii chars (decorated printer)', function () {
|
||||
$process = new Process([
|
||||
'./bin/pest',
|
||||
'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
||||
], dirname(__DIR__, 2));
|
||||
|
||||
$process->run();
|
||||
$output = $process->getOutput();
|
||||
assertStringContainsString(<<<EOF
|
||||
\e[30;42;1m PASS \e[39;49;22m\e[39m Tests\Fixtures\DirectoryWithTests\ExampleTest\e[39m
|
||||
\e[32;1m✓\e[39;22m\e[39m \e[2mit example\e[22m\e[39m
|
||||
|
||||
\e[37;1mTests: \e[39;22m\e[32;1m1 passed\e[39;22m
|
||||
EOF, $output);
|
||||
});
|
||||
|
||||
it('disable decorating printer when colors is set to never', function () {
|
||||
$process = new Process([
|
||||
'./bin/pest',
|
||||
'--colors=never',
|
||||
'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
||||
], dirname(__DIR__, 2));
|
||||
$process->run();
|
||||
$output = $process->getOutput();
|
||||
|
||||
assertStringContainsString(<<<EOF
|
||||
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
||||
✓ \e[2mit example\e[22m
|
||||
|
||||
Tests: 1 passed
|
||||
EOF, $output);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user