From 8b0d752103c41253e231820ae665ba4536fac8fa Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 1 Feb 2017 21:22:18 -0800 Subject: [PATCH] remove space from microtime --- src/TemporaryDirectory.php | 2 +- tests/TemporaryDirectoryTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/TemporaryDirectory.php b/src/TemporaryDirectory.php index a391341..01c6486 100644 --- a/src/TemporaryDirectory.php +++ b/src/TemporaryDirectory.php @@ -29,7 +29,7 @@ public function create() } if (empty($this->name)) { - $this->name = microtime(); + $this->name = str_replace(' ', '', microtime()); } if ($this->forceCreate && file_exists($this->getFullPath())) { diff --git a/tests/TemporaryDirectoryTest.php b/tests/TemporaryDirectoryTest.php index 59e52c8..5d19c72 100644 --- a/tests/TemporaryDirectoryTest.php +++ b/tests/TemporaryDirectoryTest.php @@ -45,6 +45,14 @@ public function it_can_create_a_temporary_directory_with_a_name() $this->assertDirectoryExists($this->temporaryDirectoryFullPath); } + /** @test */ + public function it_does_not_generate_spaces_in_directory_path() + { + $temporaryDirectory = (new TemporaryDirectory())->create(); + + $this->assertEquals(0, substr_count($temporaryDirectory->path(), ' ')); + } + /** @test */ public function it_can_create_a_temporary_directory_in_a_custom_location() {