Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c417d7a

Browse files
[Filesystem] Cleanup/sync with 2.3
1 parent 81c50d6 commit c417d7a

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public function testRemoveCleansInvalidLinks()
347347

348348
// create symlink to nonexistent dir
349349
rmdir($basePath.'dir');
350-
$this->assertFalse(is_dir($basePath.'dir-link'));
350+
$this->assertFalse('\\' === DIRECTORY_SEPARATOR ? @readlink($basePath.'dir-link') : is_dir($basePath.'dir-link'));
351351

352352
$this->filesystem->remove($basePath);
353353

@@ -383,7 +383,7 @@ public function testFilesExistsFails()
383383
$file = str_repeat('T', 259 - strlen($basePath));
384384
$path = $basePath.$file;
385385
exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation
386-
self::$longPathNamesWindows[] = $path; // save this so we can clean up later
386+
$this->longPathNamesWindows[] = $path; // save this so we can clean up later
387387
chdir($oldPath);
388388
$this->filesystem->exists($path);
389389
}

src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
1717
{
1818
private $umask;
1919

20-
static protected $longPathNamesWindows = array();
20+
protected $longPathNamesWindows = array();
2121

2222
/**
2323
* @var \Symfony\Component\Filesystem\Filesystem
@@ -33,12 +33,6 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
3333

3434
public static function setUpBeforeClass()
3535
{
36-
if (!empty(self::$longPathNamesWindows)) {
37-
foreach (self::$longPathNamesWindows as $path) {
38-
exec('DEL '.$path);
39-
}
40-
}
41-
4236
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
4337
$target = tempnam(sys_get_temp_dir(), 'sl');
4438
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
@@ -52,14 +46,21 @@ public static function setUpBeforeClass()
5246
protected function setUp()
5347
{
5448
$this->umask = umask(0);
49+
$this->filesystem = new Filesystem();
5550
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
5651
mkdir($this->workspace, 0777, true);
5752
$this->workspace = realpath($this->workspace);
58-
$this->filesystem = new Filesystem();
5953
}
6054

6155
protected function tearDown()
6256
{
57+
if (!empty($this->longPathNamesWindows)) {
58+
foreach ($this->longPathNamesWindows as $path) {
59+
exec('DEL '.$path);
60+
}
61+
$this->longPathNamesWindows = array();
62+
}
63+
6364
$this->filesystem->remove($this->workspace);
6465
umask($this->umask);
6566
}
@@ -102,10 +103,6 @@ protected function getFileGroup($filepath)
102103

103104
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
104105
{
105-
if (!function_exists('symlink')) {
106-
$this->markTestSkipped('Function symlink is required.');
107-
}
108-
109106
if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
110107
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
111108
}

0 commit comments

Comments
 (0)