Skip to content

Commit

Permalink
[Filesystem] Added unit tests for rename method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Apr 6, 2012
1 parent 8071859 commit a041feb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -342,6 +342,32 @@ public function testChmodChangesModeOfTraversableFileObject()
$this->assertEquals(753, $this->getFilePermisions($directory));
}

public function testRename()
{
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
$newPath = $this->workspace.DIRECTORY_SEPARATOR.'new_file';
touch($file);

$this->filesystem->rename($file, $newPath);

$this->assertFileNotExists($file);
$this->assertFileExists($newPath);
}

/**
* @expectedException \RuntimeException
*/
public function testRenameThrowsExceptionIfTargetAlreadyExists()
{
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
$newPath = $this->workspace.DIRECTORY_SEPARATOR.'new_file';

touch($file);
touch($newPath);

$this->filesystem->rename($file, $newPath);
}

/**
* Returns file permissions as three digits (i.e. 755)
*
Expand Down

0 comments on commit a041feb

Please sign in to comment.