@@ -29,9 +29,9 @@ public function it_can_create_a_snapshot_from_a_string()
29
29
{
30
30
$ mockTrait = $ this ->getMatchesSnapshotMock ();
31
31
32
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
33
-
34
- $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
32
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
33
+ $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
34
+ } );
35
35
36
36
$ this ->assertSnapshotMatchesExample (
37
37
'MatchesSnapshotTest__it_can_match_an_existing_string_snapshot__1.php ' ,
@@ -44,9 +44,9 @@ public function it_can_create_a_snapshot_from_xml()
44
44
{
45
45
$ mockTrait = $ this ->getMatchesSnapshotMock ();
46
46
47
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
48
-
49
- $ mockTrait -> assertMatchesXmlSnapshot ( ' <foo><bar>Baz</bar></foo> ' );
47
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
48
+ $ mockTrait -> assertMatchesXmlSnapshot ( ' <foo><bar>Baz</bar></foo> ' );
49
+ } );
50
50
51
51
$ this ->assertSnapshotMatchesExample (
52
52
'MatchesSnapshotTest__it_can_create_a_snapshot_from_xml__1.xml ' ,
@@ -59,9 +59,9 @@ public function it_can_create_a_snapshot_from_json()
59
59
{
60
60
$ mockTrait = $ this ->getMatchesSnapshotMock ();
61
61
62
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
63
-
64
- $ mockTrait -> assertMatchesJsonSnapshot ( ' {"foo":"foo","bar":"bar","baz":"baz"} ' );
62
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
63
+ $ mockTrait -> assertMatchesJsonSnapshot ( ' {"foo":"foo","bar":"bar","baz":"baz"} ' );
64
+ } );
65
65
66
66
$ this ->assertSnapshotMatchesExample (
67
67
'MatchesSnapshotTest__it_can_create_a_snapshot_from_json__1.json ' ,
@@ -74,9 +74,9 @@ public function it_can_create_a_snapshot_from_a_file()
74
74
{
75
75
$ mockTrait = $ this ->getMatchesSnapshotMock ();
76
76
77
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
78
-
79
- $ mockTrait -> assertMatchesFileSnapshot ( __DIR__ . ' /stubs/test_files/friendly_man.jpg ' );
77
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
78
+ $ mockTrait -> assertMatchesFileSnapshot ( __DIR__ . ' /stubs/test_files/friendly_man.jpg ' );
79
+ } );
80
80
81
81
$ this ->assertSnapshotMatchesExample (
82
82
'files/MatchesSnapshotTest__it_can_create_a_snapshot_from_a_file__1.jpg ' ,
@@ -232,9 +232,9 @@ public function it_can_update_a_string_snapshot()
232
232
233
233
$ mockTrait = $ this ->getMatchesSnapshotMock ();
234
234
235
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
236
-
237
- $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
235
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
236
+ $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
237
+ } );
238
238
239
239
$ this ->assertSnapshotMatchesExample (
240
240
'MatchesSnapshotTest__it_can_update_a_string_snapshot__1.php ' ,
@@ -249,9 +249,9 @@ public function it_can_update_a_xml_snapshot()
249
249
250
250
$ mockTrait = $ this ->getMatchesSnapshotMock ();
251
251
252
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
253
-
254
- $ mockTrait -> assertMatchesXmlSnapshot ( ' <foo><bar>Baz</bar></foo> ' );
252
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
253
+ $ mockTrait -> assertMatchesXmlSnapshot ( ' <foo><bar>Baz</bar></foo> ' );
254
+ } );
255
255
256
256
$ this ->assertSnapshotMatchesExample (
257
257
'MatchesSnapshotTest__it_can_update_a_xml_snapshot__1.xml ' ,
@@ -266,9 +266,9 @@ public function it_can_update_a_json_snapshot()
266
266
267
267
$ mockTrait = $ this ->getMatchesSnapshotMock ();
268
268
269
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
270
-
271
- $ mockTrait -> assertMatchesJsonSnapshot ( ' {"foo":"foo","bar":"bar","baz":"baz"} ' );
269
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
270
+ $ mockTrait -> assertMatchesJsonSnapshot ( ' {"foo":"foo","bar":"bar","baz":"baz"} ' );
271
+ } );
272
272
273
273
$ this ->assertSnapshotMatchesExample (
274
274
'MatchesSnapshotTest__it_can_update_a_json_snapshot__1.json ' ,
@@ -283,9 +283,9 @@ public function it_can_update_a_file_snapshot()
283
283
284
284
$ mockTrait = $ this ->getMatchesSnapshotMock ();
285
285
286
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
287
-
288
- $ mockTrait -> assertMatchesFileSnapshot ( __DIR__ . ' /stubs/test_files/friendly_man.jpg ' );
286
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
287
+ $ mockTrait -> assertMatchesFileSnapshot ( __DIR__ . ' /stubs/test_files/friendly_man.jpg ' );
288
+ } );
289
289
290
290
$ this ->assertSnapshotMatchesExample (
291
291
'files/MatchesSnapshotTest__it_can_update_a_file_snapshot__1.jpg ' ,
@@ -300,13 +300,13 @@ public function it_can_update_a_file_snapshot_with_a_different_extension()
300
300
301
301
$ mockTrait = $ this ->getMatchesSnapshotMock ();
302
302
303
- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait );
304
-
305
303
$ oldSnapshot = __DIR__ .'/__snapshots__/files/MatchesSnapshotTest__it_can_update_a_file_snapshot_with_a_different_extension__1.jpg ' ;
306
304
307
305
$ this ->assertFileExists ($ oldSnapshot );
308
306
309
- $ mockTrait ->assertMatchesFileSnapshot (__DIR__ .'/stubs/test_files/no_man.png ' );
307
+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait , function ($ mockTrait ) {
308
+ $ mockTrait ->assertMatchesFileSnapshot (__DIR__ .'/stubs/test_files/no_man.png ' );
309
+ });
310
310
311
311
$ this ->assertSnapshotMatchesExample (
312
312
'files/MatchesSnapshotTest__it_can_update_a_file_snapshot_with_a_different_extension__1.png ' ,
@@ -316,11 +316,15 @@ public function it_can_update_a_file_snapshot_with_a_different_extension()
316
316
$ this ->assertFileNotExists ($ oldSnapshot );
317
317
}
318
318
319
- private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
319
+ private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock, callable $ assertions )
320
320
{
321
321
$ matchesSnapshotMock
322
322
->expects ($ this ->once ())
323
323
->method ('markTestIncomplete ' );
324
+
325
+ $ assertions ($ matchesSnapshotMock );
326
+
327
+ $ matchesSnapshotMock ->markTestIncompleteIfSnapshotsHaveChanged ();
324
328
}
325
329
326
330
private function expectFail (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
0 commit comments