diff --git a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
index 73486a8..44e95ae 100644
--- a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
+++ b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php
@@ -70,7 +70,7 @@ public function save($name, $data) {
 
     // Write the file out to a temporary location. Prepend with a '.' to keep it
     // hidden from listings and web servers.
-    $temporary_path = tempnam($this->directory, '.');
+    $temporary_path = $this->tempnam($this->directory, '.');
     if (!$temporary_path || !@file_put_contents($temporary_path, $data)) {
       return FALSE;
     }
@@ -103,7 +103,7 @@ public function save($name, $data) {
       // iteration.
       if ($i > 0) {
         $this->unlink($temporary_path);
-        $temporary_path = tempnam($this->directory, '.');
+        $temporary_path = $this->tempnam($this->directory, '.');
         rename($full_path, $temporary_path);
         // Make sure to not loop infinitely on a hopelessly slow filesystem.
         if ($i > 10) {
@@ -184,4 +184,17 @@ protected function getUncachedMTime($directory) {
     return filemtime($directory);
   }
 
+  /**
+   * A brute force tempnam implementation supporting streams.
+   *
+   * @param $directory
+   * @param $prefix
+   * @return string
+   */
+  protected function tempnam($directory, $prefix) {
+    do {
+      $path = $directory . '/' . $prefix . substr(str_shuffle(md5(time())),0, 10);
+    } while (file_exists($path));
+    return $path;
+  }
 }
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
index 5c96fe4..0644ffb 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
@@ -96,6 +96,18 @@ public function testWriteable() {
    * @group PhpStorage
    */
   public function testDeleteAll() {
+    $php = new FileStorage($this->standardSettings);
+    $name = $this->randomMachineName() . '/' . $this->randomMachineName() . '.php';
+
+    // Find a global that doesn't exist.
+    do {
+      $random = mt_rand(10000, 100000);
+    } while (isset($GLOBALS[$random]));
+
+    // Write our the file so we can test deleting.
+    $code = "<?php\n\$GLOBALS[$random] = TRUE;";
+    $this->assertTrue($php->save($name, $code));
+
     $php_read = new FileReadOnlyStorage($this->readonlyStorage);
     $this->assertFalse($php_read->deleteAll());
 
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
index a083dd3..0e830b2 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
@@ -63,6 +63,17 @@ public function testWriteable() {
    * @group PhpStorage
    */
   public function testDeleteAll() {
+    $php = new FileStorage($this->standardSettings);
+    $name = $this->randomMachineName() . '/' . $this->randomMachineName() . '.php';
+
+    // Find a global that doesn't exist.
+    do {
+      $random = mt_rand(10000, 100000);
+    } while (isset($GLOBALS[$random]));
+
+    // Write our the file so we can test deleting.
+    $code = "<?php\n\$GLOBALS[$random] = TRUE;";
+    $this->assertTrue($php->save($name, $code));
 
     // Make sure directory exists prior to removal.
     $this->assertTrue(file_exists($this->directory . '/test'), 'File storage directory does not exist.');
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
index f3e6a4f..941ed7b 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\Tests\Component\PhpStorage;
 
 use Drupal\Tests\UnitTestCase;
+use org\bovigo\vfs\vfsStream;
 
 /**
  * Base test for PHP storages.
@@ -19,6 +20,13 @@
    *
    * @var string
    */
+  protected $root;
+
+  /**
+   * A unique per test class directory path to test php storage.
+   *
+   * @var string
+   */
   protected $directory;
 
   /**
@@ -27,6 +35,8 @@
   protected function setUp() {
     parent::setUp();
     $this->directory = sys_get_temp_dir() . '/php' . str_replace('\\','_', get_class($this));
+    $this->root = vfsStream::setup('exampleDir');
+    $this->directory = vfsStream::url('exampleDir');
   }
 
   /**
@@ -43,22 +53,22 @@ public function assertCRUD($php) {
     // Write out a PHP file and ensure it's successfully loaded.
     $code = "<?php\n\$GLOBALS[$random] = TRUE;";
     $success = $php->save($name, $code);
-    $this->assertSame($success, TRUE);
+    $this->assertTrue($success, 'Saved php file.');
     $php->load($name);
     $this->assertTrue($GLOBALS[$random]);
 
     // If the file was successfully loaded, it must also exist, but ensure the
     // exists() method returns that correctly.
-    $this->assertSame($php->exists($name), TRUE);
+    $this->assertTrue($php->exists($name));
 
     // Delete the file, and then ensure exists() returns FALSE.
     $success = $php->delete($name);
-    $this->assertSame($success, TRUE);
-    $this->assertSame($php->exists($name), FALSE);
+    $this->assertTrue($success);
+    $this->assertFalse($php->exists($name));
 
     // Ensure delete() can be called on a non-existing file. It should return
     // FALSE, but not trigger errors.
-    $this->assertSame($php->delete($name), FALSE);
+    $this->assertSame($php->delete($name), FALSE, 'here');
   }
 
 }
