Skip to content

[Filesystem] Cleanup/sync with 2.3 #18055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function testRemoveCleansInvalidLinks()

// create symlink to nonexistent 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);

Expand Down Expand Up @@ -383,7 +383,7 @@ public function testFilesExistsFails()
$file = str_repeat('T', 259 - strlen($basePath));
$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
self::$longPathNamesWindows[] = $path; // save this so we can clean up later
$this->longPathNamesWindows[] = $path; // save this so we can clean up later
chdir($oldPath);
$this->filesystem->exists($path);
}
Expand Down
21 changes: 9 additions & 12 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
{
private $umask;

static protected $longPathNamesWindows = array();
protected $longPathNamesWindows = array();

/**
* @var \Symfony\Component\Filesystem\Filesystem
Expand All @@ -33,12 +33,6 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase

public static function setUpBeforeClass()
{
if (!empty(self::$longPathNamesWindows)) {
foreach (self::$longPathNamesWindows as $path) {
exec('DEL '.$path);
}
}

if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
$target = tempnam(sys_get_temp_dir(), 'sl');
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
Expand All @@ -52,14 +46,21 @@ public static function setUpBeforeClass()
protected function setUp()
{
$this->umask = umask(0);
$this->filesystem = new Filesystem();
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
mkdir($this->workspace, 0777, true);
$this->workspace = realpath($this->workspace);
$this->filesystem = new Filesystem();
}

protected function tearDown()
{
if (!empty($this->longPathNamesWindows)) {
foreach ($this->longPathNamesWindows as $path) {
exec('DEL '.$path);
}
$this->longPathNamesWindows = array();
}

$this->filesystem->remove($this->workspace);
umask($this->umask);
}
Expand Down Expand Up @@ -102,10 +103,6 @@ protected function getFileGroup($filepath)

protected function markAsSkippedIfSymlinkIsMissing($relative = false)
{
if (!function_exists('symlink')) {
$this->markTestSkipped('Function symlink is required.');
}

if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
}
Expand Down