Skip to content

Commit

Permalink
[Filesystem] Added unit tests for touch method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Apr 6, 2012
1 parent 7e297db commit a91e200
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -193,4 +193,59 @@ public function testMkdirCreatesDirectoriesEvenIfItFailsToCreateOneOfThem()
unlink($basePath.'2');
rmdir($basePath.'3');
}

public function testTouchCreatesEmptyFile()
{
$basePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.time();
$file = $basePath.'1';

$filesystem = new Filesystem();
$filesystem->touch($file);

$this->assertFileExists($basePath.'1');

unlink($basePath.'1');
}

public function testTouchCreatesEmptyFilesFromArray()
{
$basePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.time();
$files = array(
$basePath.'1', $basePath.'2', $basePath.'3'
);
mkdir($basePath);

$filesystem = new Filesystem();
$filesystem->touch($files);

$this->assertFileExists($basePath.'1');
$this->assertFileExists($basePath.'2');
$this->assertFileExists($basePath.'3');

unlink($basePath.'1');
unlink($basePath.'2');
unlink($basePath.'3');
rmdir($basePath);
}

public function testTouchCreatesEmptyFilesFromTraversableObject()
{
$basePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.time();
$files = new \ArrayObject(array(
$basePath.'1', $basePath.'2', $basePath.'3'
));
mkdir($basePath);

$filesystem = new Filesystem();
$filesystem->touch($files);

$this->assertFileExists($basePath.'1');
$this->assertFileExists($basePath.'2');
$this->assertFileExists($basePath.'3');

unlink($basePath.'1');
unlink($basePath.'2');
unlink($basePath.'3');
rmdir($basePath);
}
}

0 comments on commit a91e200

Please sign in to comment.