2008-01-27 05:31:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test harness that sets up a filesystem sandbox for file-emulation
|
|
|
|
* functions to safely unit test in.
|
|
|
|
*
|
|
|
|
* @todo Make an automatic FSTools mock or something
|
|
|
|
*/
|
|
|
|
class FSTools_FileSystemHarness extends UnitTestCase
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-27 05:31:06 +00:00
|
|
|
protected $dir, $oldDir;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2008-04-21 15:24:18 +00:00
|
|
|
parent::__construct();
|
2008-01-27 05:31:06 +00:00
|
|
|
$this->dir = 'tmp/' . md5(uniqid(rand(), true)) . '/';
|
|
|
|
mkdir($this->dir);
|
|
|
|
$this->oldDir = getcwd();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-27 05:31:06 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function __destruct()
|
|
|
|
{
|
2008-01-27 05:31:06 +00:00
|
|
|
FSTools::singleton()->rmdirr($this->dir);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setup()
|
|
|
|
{
|
2008-01-27 05:31:06 +00:00
|
|
|
chdir($this->dir);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function tearDown()
|
|
|
|
{
|
2008-01-27 05:31:06 +00:00
|
|
|
chdir($this->oldDir);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-27 05:31:06 +00:00
|
|
|
}
|
2008-12-06 09:24:59 +00:00
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|