pickles/tests/classes/FileTest.php
Joshua Sherman faaefc1b82 Getting coverage to 100% on these classes
Also found a bug in the Form class that would bork phone numbers with dashes in
them. Even though the Form class is going to go away eventually I wanted to fix
the issue.
2014-01-12 13:56:52 -05:00

62 lines
1.2 KiB
PHP

<?php
class FileTest extends PHPUnit_Framework_TestCase
{
public static function setUpBeforeClass()
{
// Using actual filesystem because you can't chdir with vfs://
$directory = '/tmp/pickles-fs/filetest/test/test';
if (!file_exists($directory))
{
mkdir($directory, 0777, true);
}
}
public static function tearDownAfterClass()
{
File::removeDirectory('/tmp/pickles-fs');
}
public function testRemoveDirectory()
{
$directory = '/tmp/pickles-fs/filetest/';
touch($directory . 'ing');
touch($directory . 'test/ing');
touch($directory . 'test/test/ing');
File::removeDirectory($directory);
$this->assertFalse(file_exists($directory));
}
public function testMissingTrailingSlash()
{
$directory = SITE_PATH . 'missing';
mkdir($directory, 0777, true);
touch(SITE_PATH . 'missing/slash');
File::removeDirectory($directory);
$this->assertFalse(file_exists($directory));
}
public function testRemoveFileNotDirectory()
{
$directory = SITE_PATH . 'dir';
$file = SITE_PATH . 'dir/file';
mkdir($directory, 0777, true);
touch($file);
File::removeDirectory($file);
$this->assertFalse(file_exists($file));
File::removeDirectory($directory);
}
}
?>