first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected $dir, $oldDir;
|
||||
|
||||
|
||||
|
||||
function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->dir = 'tmp/' . md5(uniqid(rand(), true)) . '/';
|
||||
|
||||
mkdir($this->dir);
|
||||
|
||||
$this->oldDir = getcwd();
|
||||
|
||||
46
customerportal/include/htmlpurify/tests/FSTools/FileTest.php
Normal file
46
customerportal/include/htmlpurify/tests/FSTools/FileTest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
require_once 'FSTools/FileSystemHarness.php';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* These are not really unit tests, just sanity checks of basic functionality.
|
||||
|
||||
*/
|
||||
|
||||
class FSTools_FileTest extends FSTools_FileSystemHarness
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
function test() {
|
||||
|
||||
$name = 'test.txt';
|
||||
|
||||
$file = new FSTools_File($name);
|
||||
|
||||
$this->assertFalse($file->exists());
|
||||
|
||||
$file->write('foobar');
|
||||
|
||||
$this->assertTrue($file->exists());
|
||||
|
||||
$this->assertEqual($file->get(), 'foobar');
|
||||
|
||||
$file->delete();
|
||||
|
||||
$this->assertFalse($file->exists());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function testGetNonExistent() {
|
||||
|
||||
$name = 'notfound.txt';
|
||||
|
||||
Reference in New Issue
Block a user