<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Spatie\Snapshots\MatchesSnapshots;
class SnapshotTest extends TestCase
{
use MatchesSnapshots;
public static function dataProvider(): Generator
{
yield [1];
yield [2];
}
/** @dataProvider dataProvider */
public function testSomething(int $value): void
{
$this->assertMatchesSnapshot($value);
}
}
Result for 4.2.16 (expected)
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.
II 2 / 2 (100%)
Time: 00:00.005, Memory: 6.00 MB
OK, but incomplete, skipped, or risky tests!
Tests: 2, Assertions: 2, Incomplete: 2.
Result for 5.0.0 (actual)
PHPUnit 10.0.7 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.1
.F 2 / 2 (100%)
Time: 00:00.045, Memory: 8.00 MB
There was 1 failure:
1) SnapshotTest::testSomething with data set #1
Failed asserting that two strings are equal.
Snapshots can be updated by passing `-d --update-snapshots` through PHPUnit's CLI arguments.
--- Expected
+++ Actual
@@ @@
-'1'
+'2'
[redacted]
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
Generating (and asserting) snapshots is broken for tests that use dataproviders in 5.0.0:
PHP 8.2.1 phpunit/phpunit:10.0.7 spatie/phpunit-snapshot-assertions:5.0.0
Testcase
Result for 4.2.16 (expected)
Result for 5.0.0 (actual)