Skip to content

Commit 7978523

Browse files
committed
test: improve collision resistance of temporary directories
1 parent c225e63 commit 7978523

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/ProgramSaverTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ final class ProgramSaverTest extends TestCase
2727
protected function setUp(): void
2828
{
2929
parent::setUp();
30-
$this->tempDir = sys_get_temp_dir() . '/program_saver_test_' . uniqid();
31-
mkdir($this->tempDir, 0755, true);
30+
$this->tempDir = sys_get_temp_dir() . '/program_saver_test_' . bin2hex(random_bytes(8));
31+
if (!mkdir($this->tempDir, 0755, true) && !is_dir($this->tempDir)) {
32+
$this->fail('Failed to create temp dir: ' . $this->tempDir);
33+
}
3234
}
3335

3436
/**

0 commit comments

Comments
 (0)