@@ -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,10 @@ public function it_can_update_a_string_snapshot()
232232
233233 $ mockTrait = $ this ->getMatchesSnapshotMock ();
234234
235- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait );
235+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait , function ($ mockTrait ) {
236+ $ mockTrait ->assertMatchesSnapshot ('Foo ' );
237+ });
236238
237- $ mockTrait ->assertMatchesSnapshot ('Foo ' );
238239
239240 $ this ->assertSnapshotMatchesExample (
240241 'MatchesSnapshotTest__it_can_update_a_string_snapshot__1.php ' ,
@@ -249,9 +250,9 @@ public function it_can_update_a_xml_snapshot()
249250
250251 $ mockTrait = $ this ->getMatchesSnapshotMock ();
251252
252- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
253-
254- $ mockTrait -> assertMatchesXmlSnapshot ( ' <foo><bar>Baz</bar></foo> ' );
253+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
254+ $ mockTrait -> assertMatchesXmlSnapshot ( ' <foo><bar>Baz</bar></foo> ' );
255+ } );
255256
256257 $ this ->assertSnapshotMatchesExample (
257258 'MatchesSnapshotTest__it_can_update_a_xml_snapshot__1.xml ' ,
@@ -266,9 +267,9 @@ public function it_can_update_a_json_snapshot()
266267
267268 $ mockTrait = $ this ->getMatchesSnapshotMock ();
268269
269- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
270-
271- $ mockTrait -> assertMatchesJsonSnapshot ( ' {"foo":"foo","bar":"bar","baz":"baz"} ' );
270+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
271+ $ mockTrait -> assertMatchesJsonSnapshot ( ' {"foo":"foo","bar":"bar","baz":"baz"} ' );
272+ } );
272273
273274 $ this ->assertSnapshotMatchesExample (
274275 'MatchesSnapshotTest__it_can_update_a_json_snapshot__1.json ' ,
@@ -283,9 +284,9 @@ public function it_can_update_a_file_snapshot()
283284
284285 $ mockTrait = $ this ->getMatchesSnapshotMock ();
285286
286- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait);
287-
288- $ mockTrait -> assertMatchesFileSnapshot ( __DIR__ . ' /stubs/test_files/friendly_man.jpg ' );
287+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait, function ( $ mockTrait ) {
288+ $ mockTrait -> assertMatchesFileSnapshot ( __DIR__ . ' /stubs/test_files/friendly_man.jpg ' );
289+ } );
289290
290291 $ this ->assertSnapshotMatchesExample (
291292 'files/MatchesSnapshotTest__it_can_update_a_file_snapshot__1.jpg ' ,
@@ -300,13 +301,13 @@ public function it_can_update_a_file_snapshot_with_a_different_extension()
300301
301302 $ mockTrait = $ this ->getMatchesSnapshotMock ();
302303
303- $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait );
304-
305304 $ oldSnapshot = __DIR__ .'/__snapshots__/files/MatchesSnapshotTest__it_can_update_a_file_snapshot_with_a_different_extension__1.jpg ' ;
306305
307306 $ this ->assertFileExists ($ oldSnapshot );
308307
309- $ mockTrait ->assertMatchesFileSnapshot (__DIR__ .'/stubs/test_files/no_man.png ' );
308+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait , function ($ mockTrait ) {
309+ $ mockTrait ->assertMatchesFileSnapshot (__DIR__ .'/stubs/test_files/no_man.png ' );
310+ });
310311
311312 $ this ->assertSnapshotMatchesExample (
312313 'files/MatchesSnapshotTest__it_can_update_a_file_snapshot_with_a_different_extension__1.png ' ,
@@ -316,11 +317,15 @@ public function it_can_update_a_file_snapshot_with_a_different_extension()
316317 $ this ->assertFileNotExists ($ oldSnapshot );
317318 }
318319
319- private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
320+ private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock, callable $ assertions )
320321 {
321322 $ matchesSnapshotMock
322323 ->expects ($ this ->once ())
323324 ->method ('markTestIncomplete ' );
325+
326+ $ assertions ($ matchesSnapshotMock );
327+
328+ $ matchesSnapshotMock ->markTestIncompleteIfSnapshotsHaveChanged ();
324329 }
325330
326331 private function expectFail (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
0 commit comments