mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-11 17:38:53 +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
|
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 string $constant
|
||||||
* @param mixed $expected
|
* @param mixed $expected
|
||||||
|
Loading…
Reference in New Issue
Block a user