Skip to content

Commit 8e79d91

Browse files
committed
Remove useless uniqid in tempnam calls
1 parent d23b29d commit 8e79d91

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ class ConfigBuilderCacheWarmerTest extends TestCase
3737

3838
protected function setUp(): void
3939
{
40-
$this->varDir = sys_get_temp_dir().'/'.uniqid();
4140
$fs = new Filesystem();
41+
$this->varDir = tempnam(sys_get_temp_dir(), 'sf_var_');
42+
$fs->remove($this->varDir);
4243
$fs->mkdir($this->varDir);
4344
}
4445

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public function testDebugDefaultRootDirectory()
8282
{
8383
$this->fs->remove($this->translationDir);
8484
$this->fs = new Filesystem();
85-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
85+
$this->translationDir = tempnam(sys_get_temp_dir(), 'sf_translation_');
86+
$this->fs->remove($this->translationDir);
8687
$this->fs->mkdir($this->translationDir.'/translations');
8788
$this->fs->mkdir($this->translationDir.'/templates');
8889

@@ -150,7 +151,8 @@ public function testNoErrorWithOnlyUnusedOptionAndNoResults()
150151
protected function setUp(): void
151152
{
152153
$this->fs = new Filesystem();
153-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
154+
$this->translationDir = tempnam(sys_get_temp_dir(), 'sf_translation_');
155+
$this->fs->remove($this->translationDir);
154156
$this->fs->mkdir($this->translationDir.'/translations');
155157
$this->fs->mkdir($this->translationDir.'/templates');
156158
}

Tests/Command/TranslationUpdateCommandCompletionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public static function provideCompletionSuggestions(): iterable
5757
protected function setUp(): void
5858
{
5959
$this->fs = new Filesystem();
60-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
60+
$this->translationDir = tempnam(sys_get_temp_dir(), 'sf_translation_');
61+
$this->fs->remove($this->translationDir);
6162
$this->fs->mkdir($this->translationDir.'/translations');
6263
$this->fs->mkdir($this->translationDir.'/templates');
6364
}

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ public function testDumpWrongSortAndClean()
7878

7979
public function testDumpMessagesAndCleanInRootDirectory()
8080
{
81-
$this->fs->remove($this->translationDir);
82-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
83-
$this->fs->mkdir($this->translationDir.'/translations');
84-
$this->fs->mkdir($this->translationDir.'/templates');
85-
8681
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']], [], null, [$this->translationDir.'/trans'], [$this->translationDir.'/views']);
8782
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', '--dump-messages' => true, '--clean' => true]);
8883
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
@@ -115,11 +110,6 @@ public function testWriteMessages()
115110

116111
public function testWriteMessagesInRootDirectory()
117112
{
118-
$this->fs->remove($this->translationDir);
119-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
120-
$this->fs->mkdir($this->translationDir.'/translations');
121-
$this->fs->mkdir($this->translationDir.'/templates');
122-
123113
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
124114
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', '--force' => true]);
125115
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
@@ -174,7 +164,8 @@ public function testFilterDuplicateTransPaths()
174164
protected function setUp(): void
175165
{
176166
$this->fs = new Filesystem();
177-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
167+
$this->translationDir = tempnam(sys_get_temp_dir(), 'sf_translation_');
168+
$this->fs->remove($this->translationDir);
178169
$this->fs->mkdir($this->translationDir.'/translations');
179170
$this->fs->mkdir($this->translationDir.'/templates');
180171
}

Tests/Functional/BundlePathsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ class BundlePathsTest extends AbstractWebTestCase
2323
public function testBundlePublicDir()
2424
{
2525
$kernel = static::bootKernel(['test_case' => 'BundlePaths']);
26-
$projectDir = sys_get_temp_dir().'/'.uniqid('sf_bundle_paths', true);
26+
$projectDir = tempnam(sys_get_temp_dir(), 'sf_bundle_paths_');
2727

2828
$fs = new Filesystem();
29+
$fs->remove($projectDir);
2930
$fs->mkdir($projectDir.'/public');
3031
$command = (new Application($kernel))->add(new AssetsInstallCommand($fs, $projectDir));
3132
$exitCode = (new CommandTester($command))->execute(['target' => $projectDir.'/public']);

Tests/Routing/RouterTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,9 @@ public static function getNonStringValues()
530530
*/
531531
public function testCacheValidityWithContainerParameters($parameter)
532532
{
533-
$cacheDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('router_', true);
533+
$cacheDir = tempnam(sys_get_temp_dir(), 'sf_router_');
534+
unlink($cacheDir);
535+
mkdir($cacheDir);
534536

535537
try {
536538
$container = new Container();

0 commit comments

Comments
 (0)