Skip to content

Commit c29e761

Browse files
KacerCZf3l1x
authored andcommitted
Fixed deleting of temporary directory
When 'newContainerForEachTest' is set then temporary directory is deleted in _after() and delete in _afterSuite() fails because directory does not exist.
1 parent 266c0b5 commit c29e761

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Module/NetteDIModule.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,33 @@ private function createContainer(): void
154154
}
155155
}
156156

157-
private function clearTempDir(): void
157+
158+
private function getTempDir(): string
158159
{
159160
$tempDir = $this->path . '/' . $this->config['tempDir'];
161+
162+
return $tempDir;
163+
}
164+
165+
166+
private function clearTempDir(): void
167+
{
168+
$this->deleteTempDir();
169+
170+
$tempDir = $this->getTempDir();
171+
FileSystem::createDir($tempDir);
172+
}
173+
174+
175+
private function deleteTempDir(): void
176+
{
177+
$tempDir = $this->getTempDir();
160178
if (is_dir($tempDir)) {
161179
FileSystem::delete(realpath($tempDir));
162180
}
163-
164-
FileSystem::createDir($tempDir);
165181
}
166182

183+
167184
private function stopContainer(): void
168185
{
169186
if ($this->container === null) {
@@ -187,7 +204,7 @@ private function stopContainer(): void
187204
// IJournal is optional
188205
}
189206

190-
FileSystem::delete(realpath($this->container->getParameters()['tempDir']));
207+
$this->deleteTempDir();
191208
}
192209

193210
}

0 commit comments

Comments
 (0)