@@ -29,9 +29,9 @@ public function it_can_create_a_snapshot_from_a_string()
2929 {
3030 $ mockTrait = $ this ->getMatchesSnapshotMock ();
3131
32- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
33-
34- $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
32+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
33+ $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
34+ } );
3535
3636 $ this ->assertSnapshotMatchesExample (
3737 'MatchesSnapshotTest__it_can_match_an_existing_string_snapshot__1.php ' ,
@@ -44,9 +44,9 @@ public function it_can_create_a_snapshot_from_xml()
4444 {
4545 $ mockTrait = $ this ->getMatchesSnapshotMock ();
4646
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+ } );
5050
5151 $ this ->assertSnapshotMatchesExample (
5252 'MatchesSnapshotTest__it_can_create_a_snapshot_from_xml__1.xml ' ,
@@ -59,9 +59,9 @@ public function it_can_create_a_snapshot_from_json()
5959 {
6060 $ mockTrait = $ this ->getMatchesSnapshotMock ();
6161
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+ } );
6565
6666 $ this ->assertSnapshotMatchesExample (
6767 'MatchesSnapshotTest__it_can_create_a_snapshot_from_json__1.json ' ,
@@ -74,9 +74,9 @@ public function it_can_create_a_snapshot_from_a_file()
7474 {
7575 $ mockTrait = $ this ->getMatchesSnapshotMock ();
7676
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+ } );
8080
8181 $ this ->assertSnapshotMatchesExample (
8282 'files/MatchesSnapshotTest__it_can_create_a_snapshot_from_a_file__1.jpg ' ,
@@ -232,9 +232,9 @@ public function it_can_update_a_string_snapshot()
232232
233233 $ mockTrait = $ this ->getMatchesSnapshotMock ();
234234
235- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
236-
237- $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
235+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
236+ $ mockTrait -> assertMatchesSnapshot ( ' Foo ' );
237+ } );
238238
239239 $ this ->assertSnapshotMatchesExample (
240240 'MatchesSnapshotTest__it_can_update_a_string_snapshot__1.php ' ,
@@ -249,9 +249,9 @@ public function it_can_update_a_xml_snapshot()
249249
250250 $ mockTrait = $ this ->getMatchesSnapshotMock ();
251251
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+ } );
255255
256256 $ this ->assertSnapshotMatchesExample (
257257 'MatchesSnapshotTest__it_can_update_a_xml_snapshot__1.xml ' ,
@@ -266,9 +266,9 @@ public function it_can_update_a_json_snapshot()
266266
267267 $ mockTrait = $ this ->getMatchesSnapshotMock ();
268268
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+ } );
272272
273273 $ this ->assertSnapshotMatchesExample (
274274 'MatchesSnapshotTest__it_can_update_a_json_snapshot__1.json ' ,
@@ -283,9 +283,9 @@ public function it_can_update_a_file_snapshot()
283283
284284 $ mockTrait = $ this ->getMatchesSnapshotMock ();
285285
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+ } );
289289
290290 $ this ->assertSnapshotMatchesExample (
291291 '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()
300300
301301 $ mockTrait = $ this ->getMatchesSnapshotMock ();
302302
303- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait );
304-
305303 $ oldSnapshot = __DIR__ .'/__snapshots__/files/MatchesSnapshotTest__it_can_update_a_file_snapshot_with_a_different_extension__1.jpg ' ;
306304
307305 $ this ->assertFileExists ($ oldSnapshot );
308306
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+ });
310310
311311 $ this ->assertSnapshotMatchesExample (
312312 '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()
316316 $ this ->assertFileNotExists ($ oldSnapshot );
317317 }
318318
319- private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
319+ private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock, callable $ assertions )
320320 {
321321 $ matchesSnapshotMock
322322 ->expects ($ this ->once ())
323323 ->method ('markTestIncomplete ' );
324+
325+ $ assertions ($ matchesSnapshotMock );
326+
327+ $ matchesSnapshotMock ->markTestIncompleteIfSnapshotsHaveChanged ();
324328 }
325329
326330 private function expectFail (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
0 commit comments