mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-24 02:55:30 +00:00
Infrastructure for obtaining temporary files.
This commit is contained in:
parent
630a71bee6
commit
4dc6179207
@ -7,6 +7,32 @@
|
||||
|
||||
abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $tempFilesToUnlinkOnTearDown = array();
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
foreach ($this->tempFilesToUnlinkOnTearDown as $filename) {
|
||||
if (!file_exists($filename) || unlink($filename)) {
|
||||
unset($this->tempFilesToUnlinkOnTearDown[$filename]);
|
||||
}
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a temporary file on the local filesystem and returns its path.
|
||||
* All files created using this method will be deleted from the filesystem
|
||||
* on tearDown(), i.e. after each test method was run.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createTempFile()
|
||||
{
|
||||
$filename = tempnam(sys_get_temp_dir(), 'phpseclib-test-');
|
||||
$this->tempFilesToUnlinkOnTearDown[] = $filename;
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $constant
|
||||
* @param mixed $expected
|
||||
|
Loading…
Reference in New Issue
Block a user