diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php
index 72dda26..6b9a41e 100644
--- a/tests/SchemaTest.php
+++ b/tests/SchemaTest.php
@@ -127,8 +127,8 @@ public function testConstructFromInvalidResource()
 
     public function testDifferentValidDescriptorSources()
     {
-        $simpleFile = tempnam(sys_get_temp_dir(), 'tableschema-php-tests');
-        $fullFile = tempnam(sys_get_temp_dir(), 'tableschema-php-tests');
+        $simpleFile = $this->getTempFile();
+        $fullFile = $this->getTempFile();
         file_put_contents($simpleFile, json_encode($this->simpleDescriptor));
         file_put_contents($fullFile, json_encode($this->fullDescriptor));
         $descriptors = [
@@ -504,7 +504,7 @@ public function testSchemaToEditableSchema()
     public function testSave()
     {
         $schema = new Schema($this->minDescriptorJson);
-        $filename = tempnam(sys_get_temp_dir(), 'tableschema-php-tests');
+        $filename = $this->getTempFile();
         $schema->save($filename);
         $this->assertEquals($schema->fullDescriptor(), json_decode(file_get_contents($filename)));
     }
@@ -532,6 +532,17 @@ public function testSpecsUriFormat()
         ]], $validator->getErrors());
     }
 
+    public function tearDown()
+    {
+        foreach ($this->tempFiles as $tempFile) {
+            if (file_exists($tempFile)) {
+                unlink($tempFile);
+            }
+        }
+    }
+
+    protected $tempFiles = [];
+
     protected function assertValidationErrors($expectedValidationErrors, $descriptor)
     {
         $this->assertEquals(
@@ -570,4 +581,12 @@ protected function assertCastRowException($expectedError, $descriptor, $inputRow
             $this->assertEquals($expectedError, $e->getMessage());
         }
     }
+
+    protected function getTempFile()
+    {
+        $file = tempnam(sys_get_temp_dir(), 'tableschema-php-tests');
+        $this->tempFiles[] = $file;
+
+        return $file;
+    }
 }