@@ -12,7 +12,7 @@ trait ComparesSnapshotFiles
1212
1313 protected function setUpComparesSnapshotFiles ()
1414 {
15- $ this ->deleteDirectory ($ this ->snapshotsDir );
15+ $ this ->emptyDirectory ($ this ->snapshotsDir );
1616
1717 $ this ->copyDirectory ($ this ->snapshotStubsDir , $ this ->snapshotsDir );
1818 }
@@ -26,7 +26,7 @@ protected function assertSnapshotMatchesExample($snapshotPath, $examplePath)
2626 $ this ->assertFileEquals ($ example , $ snapshot );
2727 }
2828
29- protected function deleteDirectory (string $ path ): bool
29+ protected function emptyDirectory (string $ path )
3030 {
3131 if (! file_exists ($ path )) {
3232 return true ;
@@ -35,20 +35,20 @@ protected function deleteDirectory(string $path): bool
3535 return unlink ($ path );
3636 }
3737 foreach (scandir ($ path ) as $ item ) {
38- if ($ item == '. ' || $ item == '.. ' ) {
38+ if ($ item == '. ' || $ item == '.. ' || $ item == ' .gitignore ' ) {
3939 continue ;
4040 }
41- if (! $ this ->deleteDirectory ($ path .'/ ' .$ item )) {
41+ if (! $ this ->emptyDirectory ($ path .'/ ' .$ item )) {
4242 return false ;
4343 }
4444 }
45-
46- return rmdir ($ path );
4745 }
4846
4947 protected function copyDirectory (string $ sourcePath , string $ destinationPath )
5048 {
51- mkdir ($ destinationPath );
49+ if (! file_exists ($ destinationPath )) {
50+ mkdir ($ destinationPath );
51+ }
5252
5353 $ sourceDirectory = opendir ($ sourcePath );
5454
0 commit comments