Skip to content

Commit e5db984

Browse files
Delete unnecessary snapshots
1 parent 2ebb707 commit e5db984

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

tests/Integration/ComparesSnapshotFiles.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)