mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 02:37:22 +01:00
tests: adds more tests regarding snapshots multiple
This commit is contained in:
@ -62,6 +62,11 @@ trait Testable
|
|||||||
*/
|
*/
|
||||||
private static ?Closure $__afterAll = null;
|
private static ?Closure $__afterAll = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of snapshot changes, if any.
|
||||||
|
*/
|
||||||
|
private array $__snapshotChanges = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the test case static properties.
|
* Resets the test case static properties.
|
||||||
*/
|
*/
|
||||||
@ -331,6 +336,24 @@ trait Testable
|
|||||||
return ExceptionTrace::ensure(fn (): mixed => call_user_func_array(Closure::bind($closure, $this, $this::class), $arguments));
|
return ExceptionTrace::ensure(fn (): mixed => call_user_func_array(Closure::bind($closure, $this, $this::class), $arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @postCondition */
|
||||||
|
protected function __MarkTestIncompleteIfSnapshotHaveChanged(): void
|
||||||
|
{
|
||||||
|
if (count($this->__snapshotChanges) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->__snapshotChanges) === 1) {
|
||||||
|
$this->markTestIncomplete($this->__snapshotChanges[0]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = implode(PHP_EOL, array_map(static fn (string $message): string => '- $message', $this->__snapshotChanges));
|
||||||
|
|
||||||
|
$this->markTestIncomplete($messages);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The printable test case name.
|
* The printable test case name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -189,29 +189,7 @@ final class TestCaseFactory
|
|||||||
|
|
||||||
private static \$__filename = '$filename';
|
private static \$__filename = '$filename';
|
||||||
|
|
||||||
private array \$__snapshotChanges = [];
|
|
||||||
|
|
||||||
$methodsCode
|
$methodsCode
|
||||||
|
|
||||||
/** @postCondition */
|
|
||||||
protected function __MarkTestIncompleteIfSnapshotHaveChanged(): void
|
|
||||||
{
|
|
||||||
if (empty(\$this->__snapshotChanges)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count(\$this->__snapshotChanges) === 1) {
|
|
||||||
\$this->markTestIncomplete(\$this->__snapshotChanges[0]);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
\$formattedMessages = implode(PHP_EOL, array_map(function (string \$message) {
|
|
||||||
return "- \$message";
|
|
||||||
}, \$this->__snapshotChanges));
|
|
||||||
|
|
||||||
\$this->markTestIncomplete(\$formattedMessages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PHP;
|
PHP;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 1
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo bar 2
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.11.0.
|
Pest Testing Framework 2.12.0.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.11.0.
|
Pest Testing Framework 2.12.0.
|
||||||
|
|
||||||
|
|||||||
@ -698,6 +698,22 @@
|
|||||||
✓ failures
|
✓ failures
|
||||||
✓ failures with custom message
|
✓ failures with custom message
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
✓ multiple snapshot expectations
|
||||||
|
✓ multiple snapshot expectations with datasets with (1)
|
||||||
|
✓ multiple snapshot expectations with datasets with ('foo')
|
||||||
|
✓ multiple snapshot expectations with datasets with ('bar')
|
||||||
|
✓ multiple snapshot expectations with datasets with ('baz')
|
||||||
|
✓ describable → multiple snapshot expectations with describe
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 1 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 2 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 3 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 4 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 5 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 6 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 7 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 8 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 9 of 10
|
||||||
|
✓ multiple snapshot expectations with repeat @ repetition 10 of 10
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toStartWith
|
PASS Tests\Features\Expect\toStartWith
|
||||||
✓ pass
|
✓ pass
|
||||||
@ -1194,4 +1210,4 @@
|
|||||||
WARN Tests\Visual\Version
|
WARN Tests\Visual\Version
|
||||||
- visual snapshot of help command output
|
- visual snapshot of help command output
|
||||||
|
|
||||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 844 passed (1947 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1979 assertions)
|
||||||
@ -132,3 +132,17 @@ test('multiple snapshot expectations with datasets', function () {
|
|||||||
|
|
||||||
expect('foo bar 2')->toMatchSnapshot();
|
expect('foo bar 2')->toMatchSnapshot();
|
||||||
})->with([1, 'foo', 'bar', 'baz']);
|
})->with([1, 'foo', 'bar', 'baz']);
|
||||||
|
|
||||||
|
describe('describable', function () {
|
||||||
|
test('multiple snapshot expectations with describe', function () {
|
||||||
|
expect('foo bar 1')->toMatchSnapshot();
|
||||||
|
|
||||||
|
expect('foo bar 2')->toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('multiple snapshot expectations with repeat', function () {
|
||||||
|
expect('foo bar 1')->toMatchSnapshot();
|
||||||
|
|
||||||
|
expect('foo bar 2')->toMatchSnapshot();
|
||||||
|
})->repeat(10);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ $run = function () {
|
|||||||
|
|
||||||
test('parallel', function () use ($run) {
|
test('parallel', function () use ($run) {
|
||||||
expect($run('--exclude-group=integration'))
|
expect($run('--exclude-group=integration'))
|
||||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 833 passed (1932 assertions)')
|
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 849 passed (1964 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user