Skip to content

Commit 8f1f881

Browse files
committed
Only create and remove tmp dir when actually used
1 parent d92bd28 commit 8f1f881

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/TestCase.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ protected function setUp(): void
4646
DIRECTORY_SEPARATOR;
4747
;
4848

49-
\mkdir($this->tmpDir, 0777, true);
5049
$this->tmpNamespace = \uniqid('PACTN');
5150
}
5251

5352
protected function tearDown(): void
5453
{
5554
parent::tearDown();
56-
$this->rmdir($this->baseTmpDir);
55+
56+
if (\file_exists($this->baseTmpDir)) {
57+
$this->rmdir($this->baseTmpDir);
58+
}
5759
}
5860

5961
/**
@@ -110,6 +112,10 @@ protected function rmdir(string $dir): void
110112
*/
111113
protected function getTmpDir(): string
112114
{
115+
if (!\file_exists($this->tmpDir)) {
116+
\mkdir($this->tmpDir, 0777, true);
117+
}
118+
113119
return $this->tmpDir;
114120
}
115121

0 commit comments

Comments
 (0)