Permalink
Browse files

adjusted behavior to always copy override on url files

  • Loading branch information...
cordoval committed Dec 26, 2013
1 parent f2e1d0c commit 69a266a260e05bd4141bed6b5b5422d6cb9cef49
Showing with 15 additions and 2 deletions.
  1. +1 −1 Filesystem.php
  2. +14 −1 Tests/FilesystemTest.php
View
@@ -41,7 +41,7 @@ public function copy($originFile, $targetFile, $override = false)
$this->mkdir(dirname($targetFile));
- if (!$override && is_file($targetFile)) {
+ if (!$override && is_file($targetFile) && null == parse_url($originFile, PHP_URL_HOST)) {
$doCopy = filemtime($originFile) > filemtime($targetFile);
} else {
$doCopy = true;
View
@@ -167,6 +167,19 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
}
+ public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToNotCopy()
+ {
+ $sourceFilePath = 'http://symfony.com/images/common/logo/logo_symfony_header.png';
+ $targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
+
+ file_put_contents($targetFilePath, 'TARGET FILE');
+
+ $this->filesystem->copy($sourceFilePath, $targetFilePath, false);
+
+ $this->assertFileExists($targetFilePath);
+ $this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath));
+ }
+
public function testMkdirCreatesDirectoriesRecursively()
{
$directory = $this->workspace
@@ -336,7 +349,7 @@ public function testRemoveCleansInvalidLinks()
mkdir($basePath);
mkdir($basePath.'dir');
- // create symlink to unexisting file
+ // create symlink to nonexistent file
@symlink($basePath.'file', $basePath.'link');
$this->filesystem->remove($basePath);

0 comments on commit 69a266a

Please sign in to comment.