This commit is contained in:
Nuno Maduro
2020-05-11 18:38:30 +02:00
commit de2929077b
112 changed files with 6211 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
use Symfony\Component\Process\Process;
$run = function (string $target) {
$process = new Process(['./bin/pest', $target], dirname(__DIR__, 2));
$process->run();
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
};
test('allows to run a single test', function () use ($run) {
assertStringContainsString(<<<EOF
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
it example
Tests: 1 passed
EOF, $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'));
});
test('allows to run a directory', function () use ($run) {
assertStringContainsString(<<<EOF
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
it example
PASS Tests\Fixtures\ExampleTest
it example
Tests: 2 passed
EOF, $run('tests/Fixtures'));
});

27
tests/Visual/Success.php Normal file
View File

@ -0,0 +1,27 @@
<?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(['./bin/pest'], dirname($testsPath), ['EXCLUDE' => 'integration', 'REBUILD_SNAPSHOTS' => false]));
$process->run();
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
};
if (getenv('REBUILD_SNAPSHOTS')) {
file_put_contents($snapshot, $output());
} elseif (!getenv('EXCLUDE')) {
$output = explode("\n", $output());
array_pop($output);
array_pop($output);
assertStringContainsString(implode("\n", $output), file_get_contents($snapshot));
}
})->skip(!getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'));