minor #18055 [Filesystem] Cleanup/sync with 2.3 (nicolas-grekas)
This PR was merged into the 2.7 branch.
Discussion
----------
[Filesystem] Cleanup/sync with 2.3
| Q | A
| ------------- | ---
| Branch | 2.7
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Sibling of #18054 to keep code in sync
Commits
-------
c417d7a
[Filesystem] Cleanup/sync with 2.3
This commit is contained in:
commit
9d22b24e31
@ -347,7 +347,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
// create symlink to nonexistent dir
|
// create symlink to nonexistent dir
|
||||||
rmdir($basePath.'dir');
|
rmdir($basePath.'dir');
|
||||||
$this->assertFalse(is_dir($basePath.'dir-link'));
|
$this->assertFalse('\\' === DIRECTORY_SEPARATOR ? @readlink($basePath.'dir-link') : is_dir($basePath.'dir-link'));
|
||||||
|
|
||||||
$this->filesystem->remove($basePath);
|
$this->filesystem->remove($basePath);
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$file = str_repeat('T', 259 - strlen($basePath));
|
$file = str_repeat('T', 259 - strlen($basePath));
|
||||||
$path = $basePath.$file;
|
$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
|
exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation
|
||||||
self::$longPathNamesWindows[] = $path; // save this so we can clean up later
|
$this->longPathNamesWindows[] = $path; // save this so we can clean up later
|
||||||
chdir($oldPath);
|
chdir($oldPath);
|
||||||
$this->filesystem->exists($path);
|
$this->filesystem->exists($path);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
private $umask;
|
private $umask;
|
||||||
|
|
||||||
static protected $longPathNamesWindows = array();
|
protected $longPathNamesWindows = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Component\Filesystem\Filesystem
|
* @var \Symfony\Component\Filesystem\Filesystem
|
||||||
@ -33,12 +33,6 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
if (!empty(self::$longPathNamesWindows)) {
|
|
||||||
foreach (self::$longPathNamesWindows as $path) {
|
|
||||||
exec('DEL '.$path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
|
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
|
||||||
$target = tempnam(sys_get_temp_dir(), 'sl');
|
$target = tempnam(sys_get_temp_dir(), 'sl');
|
||||||
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
|
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
|
||||||
@ -52,14 +46,21 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->umask = umask(0);
|
$this->umask = umask(0);
|
||||||
|
$this->filesystem = new Filesystem();
|
||||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
|
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
|
||||||
mkdir($this->workspace, 0777, true);
|
mkdir($this->workspace, 0777, true);
|
||||||
$this->workspace = realpath($this->workspace);
|
$this->workspace = realpath($this->workspace);
|
||||||
$this->filesystem = new Filesystem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
|
if (!empty($this->longPathNamesWindows)) {
|
||||||
|
foreach ($this->longPathNamesWindows as $path) {
|
||||||
|
exec('DEL '.$path);
|
||||||
|
}
|
||||||
|
$this->longPathNamesWindows = array();
|
||||||
|
}
|
||||||
|
|
||||||
$this->filesystem->remove($this->workspace);
|
$this->filesystem->remove($this->workspace);
|
||||||
umask($this->umask);
|
umask($this->umask);
|
||||||
}
|
}
|
||||||
@ -102,10 +103,6 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
|
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
|
||||||
{
|
{
|
||||||
if (!function_exists('symlink')) {
|
|
||||||
$this->markTestSkipped('Function symlink is required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
|
if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
|
||||||
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
|
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user