mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat(expect): updates test suite to use expectation api
This commit is contained in:
@ -10,7 +10,7 @@ $run = function (string $target, $decorated = false) {
|
||||
return $decorated ? $process->getOutput() : preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
$snapshot = function ($name) {
|
||||
$snapshot = function ($name) {
|
||||
$testsPath = dirname(__DIR__);
|
||||
|
||||
return file_get_contents(implode(DIRECTORY_SEPARATOR, [
|
||||
@ -21,23 +21,15 @@ $snapshot = function ($name) {
|
||||
};
|
||||
|
||||
test('allows to run a single test', function () use ($run, $snapshot) {
|
||||
assertStringContainsString(
|
||||
$snapshot('allows-to-run-a-single-test'),
|
||||
$run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'));
|
||||
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'))->toContain($snapshot('allows-to-run-a-single-test'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
test('allows to run a directory', function () use ($run, $snapshot) {
|
||||
assertStringContainsString(
|
||||
$snapshot('allows-to-run-a-directory'),
|
||||
$run('tests/Fixtures')
|
||||
);
|
||||
expect($run('tests/Fixtures'))->toContain($snapshot('allows-to-run-a-directory'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
it('has ascii chars', function () use ($run, $snapshot) {
|
||||
assertStringContainsString(
|
||||
$snapshot('has-ascii-chars'),
|
||||
$run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true)
|
||||
);
|
||||
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true))->toContain($snapshot('has-ascii-chars'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
it('disable decorating printer when colors is set to never', function () use ($snapshot) {
|
||||
@ -49,9 +41,5 @@ it('disable decorating printer when colors is set to never', function () use ($s
|
||||
], dirname(__DIR__, 2));
|
||||
$process->run();
|
||||
$output = $process->getOutput();
|
||||
|
||||
assertStringContainsString(
|
||||
$snapshot('disable-decorating-printer'),
|
||||
$output
|
||||
);
|
||||
expect($output)->toContain($snapshot('disable-decorating-printer'));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
@ -22,7 +22,7 @@ test('visual snapshot of test suite on success', function () {
|
||||
$output = explode("\n", $output());
|
||||
array_pop($output);
|
||||
array_pop($output);
|
||||
assertStringContainsString(implode("\n", $output), file_get_contents($snapshot));
|
||||
expect(file_get_contents($snapshot))->toContain(implode("\n", $output));
|
||||
}
|
||||
})->skip(!getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
|
||||
->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
Reference in New Issue
Block a user