Skip to content

Commit 59bf96a

Browse files
committed
Refactor filesystem usage in EncryptionGenerateKeysCommandTest
1 parent 95573c2 commit 59bf96a

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

tests/UnitTests/Command/EncryptionGenerateKeysCommandTest.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,27 @@
99
use Symfony\Component\Console\Output\BufferedOutput;
1010
use Symfony\Component\Console\Output\NullOutput;
1111
use Symfony\Component\Filesystem\Filesystem;
12-
use Symfony\Component\Finder\Finder;
1312

1413
class EncryptionGenerateKeysCommandTest extends KernelTestCase
1514
{
16-
private string $privateKeyPath = __DIR__ . '/keys/private.key';
17-
private string $publicKeyPath = __DIR__ . '/keys/public.key';
18-
15+
private string $storagePath;
16+
private string $privateKeyPath;
17+
private string $publicKeyPath;
1918
private Filesystem $filesystem;
2019

20+
#[\Override]
2121
protected function setUp(): void
2222
{
23+
$this->storagePath = sys_get_temp_dir() . '/dirigent-encryption-keys-' . uniqid();
24+
$this->privateKeyPath = "$this->storagePath/private.key";
25+
$this->publicKeyPath = "$this->storagePath/public.key";
2326
$this->filesystem = new Filesystem();
24-
25-
$this->clearKeys();
2627
}
2728

2829
#[\Override]
2930
protected function tearDown(): void
3031
{
31-
$this->clearKeys();
32-
}
33-
34-
private function clearKeys(): void
35-
{
36-
$files = Finder::create()
37-
->files()
38-
->in(__DIR__ . '/keys')
39-
->name('*.key');
40-
41-
foreach ($files as $file) {
42-
$this->filesystem->remove($file->getRealPath());
43-
}
32+
(new Filesystem())->remove($this->storagePath);
4433
}
4534

4635
public function testGenerateNewKeys(): void

tests/UnitTests/Command/keys/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)