Add pear modules, mail and net_smtp via composer (#93)
Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
@@ -26,7 +26,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->copy($sourceFilePath, $targetFilePath);
|
||||
|
||||
$this->assertFileExists($targetFilePath);
|
||||
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
|
||||
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->copy($sourceFilePath, $targetFilePath);
|
||||
|
||||
$this->assertFileExists($targetFilePath);
|
||||
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
|
||||
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
||||
}
|
||||
|
||||
public function testCopyDoesNotOverrideExistingFileByDefault()
|
||||
@@ -92,7 +92,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->copy($sourceFilePath, $targetFilePath);
|
||||
|
||||
$this->assertFileExists($targetFilePath);
|
||||
$this->assertEquals('TARGET FILE', file_get_contents($targetFilePath));
|
||||
$this->assertStringEqualsFile($targetFilePath, 'TARGET FILE');
|
||||
}
|
||||
|
||||
public function testCopyOverridesExistingFileIfForced()
|
||||
@@ -111,7 +111,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->copy($sourceFilePath, $targetFilePath, true);
|
||||
|
||||
$this->assertFileExists($targetFilePath);
|
||||
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
|
||||
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,9 +153,12 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->assertTrue(is_dir($targetFileDirectory));
|
||||
$this->assertFileExists($targetFilePath);
|
||||
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
|
||||
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group network
|
||||
*/
|
||||
public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
|
||||
{
|
||||
$sourceFilePath = 'http://symfony.com/images/common/logo/logo_symfony_header.png';
|
||||
@@ -372,15 +375,15 @@ class FilesystemTest extends FilesystemTestCase
|
||||
public function testFilesExistsFails()
|
||||
{
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Test covers edge case on Windows only.');
|
||||
$this->markTestSkipped('Long file names are an issue on Windows');
|
||||
}
|
||||
|
||||
$basePath = $this->workspace.'\\directory\\';
|
||||
$maxPathLength = PHP_MAXPATHLEN - 2;
|
||||
|
||||
$oldPath = getcwd();
|
||||
mkdir($basePath);
|
||||
chdir($basePath);
|
||||
$file = str_repeat('T', 259 - strlen($basePath));
|
||||
$file = str_repeat('T', $maxPathLength - strlen($basePath) + 1);
|
||||
$path = $basePath.$file;
|
||||
exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation
|
||||
$this->longPathNamesWindows[] = $path; // save this so we can clean up later
|
||||
@@ -442,14 +445,22 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertFilePermissions(400, $file);
|
||||
}
|
||||
|
||||
public function testChmodWrongMod()
|
||||
public function testChmodWithWrongModLeavesPreviousPermissionsUntouched()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('chmod() changes permissions even when passing invalid modes on HHVM');
|
||||
}
|
||||
|
||||
$dir = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
touch($dir);
|
||||
|
||||
$permissions = fileperms($dir);
|
||||
|
||||
$this->filesystem->chmod($dir, 'Wrongmode');
|
||||
|
||||
$this->assertSame($permissions, fileperms($dir));
|
||||
}
|
||||
|
||||
public function testChmodRecursive()
|
||||
@@ -536,7 +547,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$dir = $this->workspace.DIRECTORY_SEPARATOR.'dir';
|
||||
mkdir($dir);
|
||||
|
||||
$this->filesystem->chown($dir, $this->getFileOwner($dir));
|
||||
$owner = $this->getFileOwner($dir);
|
||||
$this->filesystem->chown($dir, $owner);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($dir));
|
||||
}
|
||||
|
||||
public function testChownRecursive()
|
||||
@@ -548,7 +562,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$file = $dir.DIRECTORY_SEPARATOR.'file';
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->chown($dir, $this->getFileOwner($dir), true);
|
||||
$owner = $this->getFileOwner($dir);
|
||||
$this->filesystem->chown($dir, $owner, true);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($file));
|
||||
}
|
||||
|
||||
public function testChownSymlink()
|
||||
@@ -562,7 +579,27 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->symlink($file, $link);
|
||||
|
||||
$this->filesystem->chown($link, $this->getFileOwner($link));
|
||||
$owner = $this->getFileOwner($link);
|
||||
$this->filesystem->chown($link, $owner);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($link));
|
||||
}
|
||||
|
||||
public function testChownLink()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$owner = $this->getFileOwner($link);
|
||||
$this->filesystem->chown($link, $owner);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($link));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -582,6 +619,23 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->chown($link, 'user'.time().mt_rand(1000, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
|
||||
*/
|
||||
public function testChownLinkFails()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$this->filesystem->chown($link, 'user'.time().mt_rand(1000, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
|
||||
*/
|
||||
@@ -602,7 +656,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$dir = $this->workspace.DIRECTORY_SEPARATOR.'dir';
|
||||
mkdir($dir);
|
||||
|
||||
$this->filesystem->chgrp($dir, $this->getFileGroup($dir));
|
||||
$group = $this->getFileGroup($dir);
|
||||
$this->filesystem->chgrp($dir, $group);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($dir));
|
||||
}
|
||||
|
||||
public function testChgrpRecursive()
|
||||
@@ -614,7 +671,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$file = $dir.DIRECTORY_SEPARATOR.'file';
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->chgrp($dir, $this->getFileGroup($dir), true);
|
||||
$group = $this->getFileGroup($dir);
|
||||
$this->filesystem->chgrp($dir, $group, true);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($file));
|
||||
}
|
||||
|
||||
public function testChgrpSymlink()
|
||||
@@ -628,7 +688,27 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->symlink($file, $link);
|
||||
|
||||
$this->filesystem->chgrp($link, $this->getFileGroup($link));
|
||||
$group = $this->getFileGroup($link);
|
||||
$this->filesystem->chgrp($link, $group);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($link));
|
||||
}
|
||||
|
||||
public function testChgrpLink()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$group = $this->getFileGroup($link);
|
||||
$this->filesystem->chgrp($link, $group);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($link));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,6 +728,23 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->chgrp($link, 'user'.time().mt_rand(1000, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
|
||||
*/
|
||||
public function testChgrpLinkFails()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$this->filesystem->chgrp($link, 'user'.time().mt_rand(1000, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
|
||||
*/
|
||||
@@ -743,9 +840,9 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->remove($link);
|
||||
|
||||
$this->assertTrue(!is_link($link));
|
||||
$this->assertTrue(!is_file($link));
|
||||
$this->assertTrue(!is_dir($link));
|
||||
$this->assertFalse(is_link($link));
|
||||
$this->assertFalse(is_file($link));
|
||||
$this->assertFalse(is_dir($link));
|
||||
}
|
||||
|
||||
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
|
||||
@@ -799,6 +896,193 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertEquals($file, readlink($link2));
|
||||
}
|
||||
|
||||
public function testLink()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$this->assertTrue(is_file($link));
|
||||
$this->assertEquals(fileinode($file), fileinode($link));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testLink
|
||||
*/
|
||||
public function testRemoveLink()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
$this->filesystem->remove($link);
|
||||
|
||||
$this->assertTrue(!is_file($link));
|
||||
}
|
||||
|
||||
public function testLinkIsOverwrittenIfPointsToDifferentTarget()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$file2 = $this->workspace.DIRECTORY_SEPARATOR.'file2';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
touch($file2);
|
||||
link($file2, $link);
|
||||
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$this->assertTrue(is_file($link));
|
||||
$this->assertEquals(fileinode($file), fileinode($link));
|
||||
}
|
||||
|
||||
public function testLinkIsNotOverwrittenIfAlreadyCreated()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
link($file, $link);
|
||||
|
||||
$this->filesystem->hardlink($file, $link);
|
||||
|
||||
$this->assertTrue(is_file($link));
|
||||
$this->assertEquals(fileinode($file), fileinode($link));
|
||||
}
|
||||
|
||||
public function testLinkWithSeveralTargets()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link1 = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
$link2 = $this->workspace.DIRECTORY_SEPARATOR.'link2';
|
||||
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->hardlink($file, array($link1, $link2));
|
||||
|
||||
$this->assertTrue(is_file($link1));
|
||||
$this->assertEquals(fileinode($file), fileinode($link1));
|
||||
$this->assertTrue(is_file($link2));
|
||||
$this->assertEquals(fileinode($file), fileinode($link2));
|
||||
}
|
||||
|
||||
public function testLinkWithSameTarget()
|
||||
{
|
||||
$this->markAsSkippedIfLinkIsMissing();
|
||||
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||
|
||||
touch($file);
|
||||
|
||||
// practically same as testLinkIsNotOverwrittenIfAlreadyCreated
|
||||
$this->filesystem->hardlink($file, array($link, $link));
|
||||
|
||||
$this->assertTrue(is_file($link));
|
||||
$this->assertEquals(fileinode($file), fileinode($link));
|
||||
}
|
||||
|
||||
public function testReadRelativeLink()
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Relative symbolic links are not supported on Windows');
|
||||
}
|
||||
|
||||
$file = $this->workspace.'/file';
|
||||
$link1 = $this->workspace.'/dir/link';
|
||||
$link2 = $this->workspace.'/dir/link2';
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->symlink('../file', $link1);
|
||||
$this->filesystem->symlink('link', $link2);
|
||||
|
||||
$this->assertEquals($this->normalize('../file'), $this->filesystem->readlink($link1));
|
||||
$this->assertEquals('link', $this->filesystem->readlink($link2));
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link1, true));
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link2, true));
|
||||
$this->assertEquals($file, $this->filesystem->readlink($file, true));
|
||||
}
|
||||
|
||||
public function testReadAbsoluteLink()
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->normalize($this->workspace.'/file');
|
||||
$link1 = $this->normalize($this->workspace.'/dir/link');
|
||||
$link2 = $this->normalize($this->workspace.'/dir/link2');
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->symlink($file, $link1);
|
||||
$this->filesystem->symlink($link1, $link2);
|
||||
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link1));
|
||||
$this->assertEquals($link1, $this->filesystem->readlink($link2));
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link1, true));
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link2, true));
|
||||
$this->assertEquals($file, $this->filesystem->readlink($file, true));
|
||||
}
|
||||
|
||||
public function testReadBrokenLink()
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support creating "broken" symlinks');
|
||||
}
|
||||
|
||||
$file = $this->workspace.'/file';
|
||||
$link = $this->workspace.'/link';
|
||||
|
||||
$this->filesystem->symlink($file, $link);
|
||||
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link));
|
||||
$this->assertNull($this->filesystem->readlink($link, true));
|
||||
|
||||
touch($file);
|
||||
$this->assertEquals($file, $this->filesystem->readlink($link, true));
|
||||
}
|
||||
|
||||
public function testReadLinkDefaultPathDoesNotExist()
|
||||
{
|
||||
$this->assertNull($this->filesystem->readlink($this->normalize($this->workspace.'/invalid')));
|
||||
}
|
||||
|
||||
public function testReadLinkDefaultPathNotLink()
|
||||
{
|
||||
$file = $this->normalize($this->workspace.'/file');
|
||||
touch($file);
|
||||
|
||||
$this->assertNull($this->filesystem->readlink($file));
|
||||
}
|
||||
|
||||
public function testReadLinkCanonicalizePath()
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->normalize($this->workspace.'/file');
|
||||
mkdir($this->normalize($this->workspace.'/dir'));
|
||||
touch($file);
|
||||
|
||||
$this->assertEquals($file, $this->filesystem->readlink($this->normalize($this->workspace.'/dir/../file'), true));
|
||||
}
|
||||
|
||||
public function testReadLinkCanonicalizedPathDoesNotExist()
|
||||
{
|
||||
$this->assertNull($this->filesystem->readlink($this->normalize($this->workspace.'invalid'), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePathsForMakePathRelative
|
||||
*/
|
||||
@@ -809,9 +1093,6 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertEquals($expectedPath, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providePathsForMakePathRelative()
|
||||
{
|
||||
$paths = array(
|
||||
@@ -819,7 +1100,6 @@ class FilesystemTest extends FilesystemTestCase
|
||||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component/', '../'),
|
||||
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component', '../'),
|
||||
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component/', '../'),
|
||||
array('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../'),
|
||||
array('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
|
||||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', 'src/Symfony/'),
|
||||
array('/aa/bb', '/aa/bb', './'),
|
||||
@@ -842,6 +1122,16 @@ class FilesystemTest extends FilesystemTestCase
|
||||
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
|
||||
array('/aab/bb', '/aa', '../aab/bb/'),
|
||||
array('/aab', '/aa', '../aab/'),
|
||||
array('/aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
|
||||
array('/aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
|
||||
array('/aa/bb/../../cc', '/aa/../dd/..', 'cc/'),
|
||||
array('/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
|
||||
array('/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
|
||||
array('C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
|
||||
array('c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'),
|
||||
array('C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'),
|
||||
array('C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
|
||||
array('C:/../../aa/../bb/cc', 'C:/aa/dd/..', '../bb/cc/'),
|
||||
);
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
@@ -851,6 +1141,36 @@ class FilesystemTest extends FilesystemTestCase
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider provideLegacyPathsForMakePathRelativeWithRelativePaths
|
||||
* @expectedDeprecation Support for passing relative paths to Symfony\Component\Filesystem\Filesystem::makePathRelative() is deprecated since Symfony 3.4 and will be removed in 4.0.
|
||||
*/
|
||||
public function testMakePathRelativeWithRelativePaths($endPath, $startPath, $expectedPath)
|
||||
{
|
||||
$path = $this->filesystem->makePathRelative($endPath, $startPath);
|
||||
|
||||
$this->assertEquals($expectedPath, $path);
|
||||
}
|
||||
|
||||
public function provideLegacyPathsForMakePathRelativeWithRelativePaths()
|
||||
{
|
||||
return array(
|
||||
array('usr/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
|
||||
array('aa/bb', 'aa/cc', '../bb/'),
|
||||
array('aa/cc', 'bb/cc', '../../aa/cc/'),
|
||||
array('aa/bb', 'aa/./cc', '../bb/'),
|
||||
array('aa/./bb', 'aa/cc', '../bb/'),
|
||||
array('aa/./bb', 'aa/./cc', '../bb/'),
|
||||
array('../../', '../../', './'),
|
||||
array('../aa/bb/', 'aa/bb/', '../../../aa/bb/'),
|
||||
array('../../../', '../../', '../'),
|
||||
array('', '', './'),
|
||||
array('', 'aa/', '../'),
|
||||
array('aa/', '', 'aa/'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testMirrorCopiesFilesAndDirectoriesRecursively()
|
||||
{
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
@@ -970,6 +1290,53 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertEquals('\\' === DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||
}
|
||||
|
||||
public function testMirrorContentsWithSameNameAsSourceOrTargetWithoutDeleteOption()
|
||||
{
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
|
||||
mkdir($sourcePath);
|
||||
touch($sourcePath.'source');
|
||||
touch($sourcePath.'target');
|
||||
|
||||
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
|
||||
|
||||
$oldPath = getcwd();
|
||||
chdir($this->workspace);
|
||||
|
||||
$this->filesystem->mirror('source', $targetPath);
|
||||
|
||||
chdir($oldPath);
|
||||
|
||||
$this->assertTrue(is_dir($targetPath));
|
||||
$this->assertFileExists($targetPath.'source');
|
||||
$this->assertFileExists($targetPath.'target');
|
||||
}
|
||||
|
||||
public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption()
|
||||
{
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
|
||||
mkdir($sourcePath);
|
||||
touch($sourcePath.'source');
|
||||
|
||||
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
|
||||
|
||||
mkdir($targetPath);
|
||||
touch($targetPath.'source');
|
||||
touch($targetPath.'target');
|
||||
|
||||
$oldPath = getcwd();
|
||||
chdir($this->workspace);
|
||||
|
||||
$this->filesystem->mirror('source', 'target', null, array('delete' => true));
|
||||
|
||||
chdir($oldPath);
|
||||
|
||||
$this->assertTrue(is_dir($targetPath));
|
||||
$this->assertFileExists($targetPath.'source');
|
||||
$this->assertFileNotExists($targetPath.'target');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePathsForIsAbsolutePath
|
||||
*/
|
||||
@@ -980,9 +1347,6 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providePathsForIsAbsolutePath()
|
||||
{
|
||||
return array(
|
||||
@@ -1110,7 +1474,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->dumpFile($filename, 'bar');
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertSame('bar', file_get_contents($filename));
|
||||
$this->assertStringEqualsFile($filename, 'bar');
|
||||
|
||||
// skip mode check on Windows
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
@@ -1127,7 +1491,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->filesystem->dumpFile($filename, 'bar');
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertSame('bar', file_get_contents($filename));
|
||||
$this->assertStringEqualsFile($filename, 'bar');
|
||||
}
|
||||
|
||||
public function testDumpFileWithFileScheme()
|
||||
@@ -1139,10 +1503,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$scheme = 'file://';
|
||||
$filename = $scheme.$this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
|
||||
|
||||
$this->filesystem->dumpFile($filename, 'bar', null);
|
||||
$this->filesystem->dumpFile($filename, 'bar');
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertSame('bar', file_get_contents($filename));
|
||||
$this->assertStringEqualsFile($filename, 'bar');
|
||||
}
|
||||
|
||||
public function testDumpFileWithZlibScheme()
|
||||
@@ -1150,11 +1514,99 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$scheme = 'compress.zlib://';
|
||||
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
|
||||
|
||||
$this->filesystem->dumpFile($filename, 'bar', null);
|
||||
$this->filesystem->dumpFile($filename, 'bar');
|
||||
|
||||
// Zlib stat uses file:// wrapper so remove scheme
|
||||
$this->assertFileExists(str_replace($scheme, '', $filename));
|
||||
$this->assertSame('bar', file_get_contents($filename));
|
||||
$this->assertStringEqualsFile($filename, 'bar');
|
||||
}
|
||||
|
||||
public function testAppendToFile()
|
||||
{
|
||||
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.txt';
|
||||
|
||||
// skip mode check on Windows
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
$oldMask = umask(0002);
|
||||
}
|
||||
|
||||
$this->filesystem->dumpFile($filename, 'foo');
|
||||
|
||||
$this->filesystem->appendToFile($filename, 'bar');
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertStringEqualsFile($filename, 'foobar');
|
||||
|
||||
// skip mode check on Windows
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
$this->assertFilePermissions(664, $filename);
|
||||
umask($oldMask);
|
||||
}
|
||||
}
|
||||
|
||||
public function testAppendToFileWithScheme()
|
||||
{
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM does not handle the file:// scheme correctly');
|
||||
}
|
||||
|
||||
$scheme = 'file://';
|
||||
$filename = $scheme.$this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
|
||||
$this->filesystem->dumpFile($filename, 'foo');
|
||||
|
||||
$this->filesystem->appendToFile($filename, 'bar');
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertStringEqualsFile($filename, 'foobar');
|
||||
}
|
||||
|
||||
public function testAppendToFileWithZlibScheme()
|
||||
{
|
||||
$scheme = 'compress.zlib://';
|
||||
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
|
||||
$this->filesystem->dumpFile($filename, 'foo');
|
||||
|
||||
// Zlib stat uses file:// wrapper so remove it
|
||||
$this->assertStringEqualsFile(str_replace($scheme, '', $filename), 'foo');
|
||||
|
||||
$this->filesystem->appendToFile($filename, 'bar');
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertStringEqualsFile($filename, 'foobar');
|
||||
}
|
||||
|
||||
public function testAppendToFileCreateTheFileIfNotExists()
|
||||
{
|
||||
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.txt';
|
||||
|
||||
// skip mode check on Windows
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
$oldMask = umask(0002);
|
||||
}
|
||||
|
||||
$this->filesystem->appendToFile($filename, 'bar');
|
||||
|
||||
// skip mode check on Windows
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
$this->assertFilePermissions(664, $filename);
|
||||
umask($oldMask);
|
||||
}
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertStringEqualsFile($filename, 'bar');
|
||||
}
|
||||
|
||||
public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';
|
||||
file_put_contents($filename, 'FOO BAR');
|
||||
chmod($filename, 0745);
|
||||
|
||||
$this->filesystem->dumpFile($filename, 'bar', null);
|
||||
|
||||
$this->assertFilePermissions(745, $filename);
|
||||
}
|
||||
|
||||
public function testCopyShouldKeepExecutionPermission()
|
||||
@@ -1171,4 +1623,16 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->assertFilePermissions(767, $targetFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the given path (transform each blackslash into a real directory separator).
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function normalize($path)
|
||||
{
|
||||
return str_replace('/', DIRECTORY_SEPARATOR, $path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user