Fixing most of the File test case issues with phpunit.

This commit is contained in:
mark_story 2010-05-30 22:46:42 -04:00
parent 713e6e6287
commit 22e942c2a3

View file

@ -35,6 +35,28 @@ class FileTest extends CakeTestCase {
*/
public $File = null;
/**
* setup the test case
*
* @return void
*/
function setUp() {
parent::setUp();
$file = __FILE__;
$this->File = new File($file);
}
/**
* tear down for test.
*
* @return void
*/
function teardown() {
parent::teardown();
$this->File->close();
unset($this->File);
}
/**
* testBasic method
*
@ -43,7 +65,6 @@ class FileTest extends CakeTestCase {
*/
function testBasic() {
$file = __FILE__;
$this->File =& new File($file);
$result = $this->File->pwd();
$expecting = $file;
@ -210,7 +231,7 @@ class FileTest extends CakeTestCase {
*/
function testCreate() {
$tmpFile = TMP.'tests'.DS.'cakephp.file.test.tmp';
$File =& new File($tmpFile, true, 0777);
$File = new File($tmpFile, true, 0777);
$this->assertTrue($File->exists());
}
@ -221,7 +242,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testOpeningNonExistantFileCreatesIt() {
$someFile =& new File(TMP . 'some_file.txt', false);
$someFile = new File(TMP . 'some_file.txt', false);
$this->assertTrue($someFile->open());
$this->assertEqual($someFile->read(), '');
$someFile->close();
@ -256,7 +277,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testReadable() {
$someFile =& new File(TMP . 'some_file.txt', false);
$someFile = new File(TMP . 'some_file.txt', false);
$this->assertTrue($someFile->open());
$this->assertTrue($someFile->readable());
$someFile->close();
@ -270,7 +291,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testWritable() {
$someFile =& new File(TMP . 'some_file.txt', false);
$someFile = new File(TMP . 'some_file.txt', false);
$this->assertTrue($someFile->open());
$this->assertTrue($someFile->writable());
$someFile->close();
@ -284,7 +305,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testExecutable() {
$someFile =& new File(TMP . 'some_file.txt', false);
$someFile = new File(TMP . 'some_file.txt', false);
$this->assertTrue($someFile->open());
$this->assertFalse($someFile->executable());
$someFile->close();
@ -298,7 +319,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testLastAccess() {
$someFile =& new File(TMP . 'some_file.txt', false);
$someFile = new File(TMP . 'some_file.txt', false);
$this->assertFalse($someFile->lastAccess());
$this->assertTrue($someFile->open());
$this->assertEqual($someFile->lastAccess(), time());
@ -313,7 +334,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testLastChange() {
$someFile =& new File(TMP . 'some_file.txt', false);
$someFile = new File(TMP . 'some_file.txt', false);
$this->assertFalse($someFile->lastChange());
$this->assertTrue($someFile->open('r+'));
$this->assertEqual($someFile->lastChange(), time());
@ -337,7 +358,7 @@ class FileTest extends CakeTestCase {
unlink($tmpFile);
}
$TmpFile =& new File($tmpFile);
$TmpFile = new File($tmpFile);
$this->assertFalse(file_exists($tmpFile));
$this->assertFalse(is_resource($TmpFile->handle));
@ -368,7 +389,7 @@ class FileTest extends CakeTestCase {
unlink($tmpFile);
}
$TmpFile =& new File($tmpFile);
$TmpFile = new File($tmpFile);
$this->assertFalse(file_exists($tmpFile));
$fragments = array('CakePHP\'s', ' test suite', ' was here ...', '');
@ -397,13 +418,13 @@ class FileTest extends CakeTestCase {
if (!file_exists($tmpFile)) {
touch($tmpFile);
}
$TmpFile =& new File($tmpFile);
$TmpFile = new File($tmpFile);
$this->assertTrue(file_exists($tmpFile));
$result = $TmpFile->delete();
$this->assertTrue($result);
$this->assertFalse(file_exists($tmpFile));
$TmpFile =& new File('/this/does/not/exist');
$TmpFile = new File('/this/does/not/exist');
$result = $TmpFile->delete();
$this->assertFalse($result);
}
@ -417,7 +438,7 @@ class FileTest extends CakeTestCase {
function testCopy() {
$dest = TMP . 'tests' . DS . 'cakephp.file.test.tmp';
$file = __FILE__;
$this->File =& new File($file);
$this->File = new File($file);
$result = $this->File->copy($dest);
$this->assertTrue($result);
@ -430,7 +451,7 @@ class FileTest extends CakeTestCase {
$this->File->close();
unlink($dest);
$TmpFile =& new File('/this/does/not/exist');
$TmpFile = new File('/this/does/not/exist');
$result = $TmpFile->copy($dest);
$this->assertFalse($result);