tempFilename = tempnam(sys_get_temp_dir(), 'Slim_Http_UploadedFileTest_'); if (!$this->tempFilename) { throw new \RuntimeException("Unable to create temporary file"); } file_put_contents($this->tempFilename, '12345'); return new UploadedFile( $this->tempFilename, basename($this->tempFilename), 'text/plain', (int)filesize($this->tempFilename) ); } protected function tearDown(): void { if (is_file($this->tempFilename)) { unlink($this->tempFilename); } } }