@@ -12,7 +12,7 @@ trait ComparesSnapshotFiles
12
12
13
13
protected function setUpComparesSnapshotFiles ()
14
14
{
15
- $ this ->deleteDirectory ($ this ->snapshotsDir );
15
+ $ this ->emptyDirectory ($ this ->snapshotsDir );
16
16
17
17
$ this ->copyDirectory ($ this ->snapshotStubsDir , $ this ->snapshotsDir );
18
18
}
@@ -26,7 +26,7 @@ protected function assertSnapshotMatchesExample($snapshotPath, $examplePath)
26
26
$ this ->assertFileEquals ($ example , $ snapshot );
27
27
}
28
28
29
- protected function deleteDirectory (string $ path ): bool
29
+ protected function emptyDirectory (string $ path )
30
30
{
31
31
if (! file_exists ($ path )) {
32
32
return true ;
@@ -35,20 +35,20 @@ protected function deleteDirectory(string $path): bool
35
35
return unlink ($ path );
36
36
}
37
37
foreach (scandir ($ path ) as $ item ) {
38
- if ($ item == '. ' || $ item == '.. ' ) {
38
+ if ($ item == '. ' || $ item == '.. ' || $ item == ' .gitignore ' ) {
39
39
continue ;
40
40
}
41
- if (! $ this ->deleteDirectory ($ path .'/ ' .$ item )) {
41
+ if (! $ this ->emptyDirectory ($ path .'/ ' .$ item )) {
42
42
return false ;
43
43
}
44
44
}
45
-
46
- return rmdir ($ path );
47
45
}
48
46
49
47
protected function copyDirectory (string $ sourcePath , string $ destinationPath )
50
48
{
51
- mkdir ($ destinationPath );
49
+ if (! file_exists ($ destinationPath )) {
50
+ mkdir ($ destinationPath );
51
+ }
52
52
53
53
$ sourceDirectory = opendir ($ sourcePath );
54
54
0 commit comments