Skip to content

Commit 6d06429

Browse files
authored
Merge pull request #187 from simonhammes/phpunit-11
Use PHPUnit attributes
2 parents 04bab93 + 2d4c036 commit 6d06429

12 files changed

+102
-92
lines changed

src/MatchesSnapshots.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Spatie\Snapshots;
44

5+
use PHPUnit\Framework\Attributes\Before;
6+
use PHPUnit\Framework\Attributes\PostCondition;
57
use PHPUnit\Framework\ExpectationFailedException;
68
use ReflectionObject;
79
use Spatie\Snapshots\Concerns\SnapshotDirectoryAware;
@@ -23,13 +25,13 @@ trait MatchesSnapshots
2325

2426
protected array $snapshotChanges = [];
2527

26-
/** @before */
28+
#[Before]
2729
public function setUpSnapshotIncrementor()
2830
{
2931
$this->snapshotIncrementor = 0;
3032
}
3133

32-
/** @postCondition */
34+
#[PostCondition]
3335
public function markTestIncompleteIfSnapshotsHaveChanged()
3436
{
3537
if (empty($this->snapshotChanges)) {

tests/Integration/AssertionTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Spatie\Snapshots\Test\Integration;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use PHPUnit\Framework\TestCase;
67
use Spatie\Snapshots\MatchesSnapshots;
78

@@ -17,63 +18,63 @@ public function setUp(): void
1718
$this->setUpComparesSnapshotFiles();
1819
}
1920

20-
/** @test */
21+
#[Test]
2122
public function can_match_a_string_snapshot()
2223
{
2324
$data = 'Foo';
2425

2526
$this->assertMatchesSnapshot($data);
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function can_match_an_html_snapshot()
3031
{
3132
$data = '<!doctype html><html lang="en"><head></head><body><h1>Hello, world!</h1></body></html>';
3233

3334
$this->assertMatchesHtmlSnapshot($data);
3435
}
3536

36-
/** @test */
37+
#[Test]
3738
public function can_match_an_xml_snapshot()
3839
{
3940
$data = '<foo><bar>Baz</bar></foo>';
4041

4142
$this->assertMatchesXmlSnapshot($data);
4243
}
4344

44-
/** @test */
45+
#[Test]
4546
public function can_match_a_json_snapshot()
4647
{
4748
$data = '{"foo":"foo","bar":"bar","baz":"baz"}';
4849

4950
$this->assertMatchesJsonSnapshot($data);
5051
}
5152

52-
/** @test */
53+
#[Test]
5354
public function can_match_an_array_snapshot()
5455
{
5556
$data = ['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'];
5657

5758
$this->assertMatchesJsonSnapshot($data);
5859
}
5960

60-
/** @test */
61+
#[Test]
6162
public function can_match_a_file_hash_snapshot()
6263
{
6364
$filePath = __DIR__.'/stubs/example_snapshots/snapshot.json';
6465

6566
$this->assertMatchesFileHashSnapshot($filePath);
6667
}
6768

68-
/** @test */
69+
#[Test]
6970
public function can_match_a_file_snapshot()
7071
{
7172
$filePath = __DIR__.'/stubs/test_files/friendly_man.jpg';
7273

7374
$this->assertMatchesFileSnapshot($filePath);
7475
}
7576

76-
/** @test */
77+
#[Test]
7778
public function can_do_multiple_snapshot_assertions()
7879
{
7980
$this->assertMatchesSnapshot('Foo');

0 commit comments

Comments
 (0)