Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[cs-fixer] Use PhpUnit native assertions in filsystem checks #32924

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
Aug 5, 2019
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
Use PHPunit assertion
  • Loading branch information
jderusse committed Aug 4, 2019
commit 226bdd18fb2e4735b59a6e15ca2b2572e342d001
2 changes: 1 addition & 1 deletion 2 .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ return PhpCsFixer\Config::create()
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit75Migration:risky' => true,
'php_unit_dedicate_assert' => ['target' => '3.5'],
'php_unit_dedicate_assert' => ['target' => '5.6'],
jderusse marked this conversation as resolved.
Show resolved Hide resolved
'phpdoc_no_empty_return' => false, // triggers almost always false positive
'array_syntax' => ['syntax' => 'short'],
'fopen_flags' => false,
Expand Down
36 changes: 18 additions & 18 deletions 36 src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()

$this->filesystem->copy($sourceFilePath, $targetFilePath);

$this->assertTrue(is_dir($targetFileDirectory));
$this->assertDirectoryExists($targetFileDirectory);
$this->assertFileExists($targetFilePath);
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public function testMkdirCreatesDirectoriesRecursively()

$this->filesystem->mkdir($directory);

$this->assertTrue(is_dir($directory));
$this->assertDirectoryExists($directory);
}

public function testMkdirCreatesDirectoriesFromArray()
Expand All @@ -197,9 +197,9 @@ public function testMkdirCreatesDirectoriesFromArray()

$this->filesystem->mkdir($directories);

$this->assertTrue(is_dir($basePath.'1'));
$this->assertTrue(is_dir($basePath.'2'));
$this->assertTrue(is_dir($basePath.'3'));
$this->assertDirectoryExists($basePath.'1');
$this->assertDirectoryExists($basePath.'2');
$this->assertDirectoryExists($basePath.'3');
}

public function testMkdirCreatesDirectoriesFromTraversableObject()
Expand All @@ -211,9 +211,9 @@ public function testMkdirCreatesDirectoriesFromTraversableObject()

$this->filesystem->mkdir($directories);

$this->assertTrue(is_dir($basePath.'1'));
$this->assertTrue(is_dir($basePath.'2'));
$this->assertTrue(is_dir($basePath.'3'));
$this->assertDirectoryExists($basePath.'1');
$this->assertDirectoryExists($basePath.'2');
$this->assertDirectoryExists($basePath.'3');
}

public function testMkdirCreatesDirectoriesFails()
Expand Down Expand Up @@ -347,7 +347,7 @@ public function testRemoveCleansInvalidLinks()

// create symlink to dir using trailing forward slash
$this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
$this->assertTrue(is_dir($basePath.'dir-link'));
$this->assertDirectoryExists($basePath.'dir-link');

// create symlink to nonexistent dir
rmdir($basePath.'dir');
Expand Down Expand Up @@ -825,7 +825,7 @@ public function testRemoveSymlink()

$this->assertFalse(is_link($link));
$this->assertFalse(is_file($link));
$this->assertFalse(is_dir($link));
$this->assertDirectoryNotExists($link);
}

public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
Expand Down Expand Up @@ -1170,8 +1170,8 @@ public function testMirrorCopiesFilesAndDirectoriesRecursively()

$this->filesystem->mirror($sourcePath, $targetPath);

$this->assertTrue(is_dir($targetPath));
$this->assertTrue(is_dir($targetPath.'directory'));
$this->assertDirectoryExists($targetPath);
$this->assertDirectoryExists($targetPath.'directory');
$this->assertFileEquals($file1, $targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1');
$this->assertFileEquals($file2, $targetPath.'file2');

Expand Down Expand Up @@ -1204,7 +1204,7 @@ public function testMirrorCreatesEmptyDirectory()

$this->filesystem->mirror($sourcePath, $targetPath);

$this->assertTrue(is_dir($targetPath));
$this->assertDirectoryExists($targetPath);

$this->filesystem->remove($sourcePath);
}
Expand All @@ -1223,7 +1223,7 @@ public function testMirrorCopiesLinks()

$this->filesystem->mirror($sourcePath, $targetPath);

$this->assertTrue(is_dir($targetPath));
$this->assertDirectoryExists($targetPath);
$this->assertFileEquals($sourcePath.'file1', $targetPath.'link1');
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
}
Expand All @@ -1243,7 +1243,7 @@ public function testMirrorCopiesLinkedDirectoryContents()

$this->filesystem->mirror($sourcePath, $targetPath);

$this->assertTrue(is_dir($targetPath));
$this->assertDirectoryExists($targetPath);
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
}
Expand All @@ -1267,7 +1267,7 @@ public function testMirrorCopiesRelativeLinkedContents()

$this->filesystem->mirror($sourcePath, $targetPath);

$this->assertTrue(is_dir($targetPath));
$this->assertDirectoryExists($targetPath);
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
$this->assertEquals('\\' === \DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.\DIRECTORY_SEPARATOR.'link1'));
Expand All @@ -1290,7 +1290,7 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithoutDeleteOptio

chdir($oldPath);

$this->assertTrue(is_dir($targetPath));
$this->assertDirectoryExists($targetPath);
$this->assertFileExists($targetPath.'source');
$this->assertFileExists($targetPath.'target');
}
Expand All @@ -1315,7 +1315,7 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption()

chdir($oldPath);

$this->assertTrue(is_dir($targetPath));
$this->assertDirectoryExists($targetPath);
$this->assertFileExists($targetPath.'source');
$this->assertFileNotExists($targetPath.'target');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testConstructSavePath($savePath, $expectedSavePath, $path)
{
$handler = new NativeFileSessionHandler($savePath);
$this->assertEquals($expectedSavePath, ini_get('session.save_path'));
$this->assertTrue(is_dir(realpath($path)));
$this->assertDirectoryExists(realpath($path));

rmdir($path);
}
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Intl/Tests/IntlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testGetIcuStubVersionReadsTheVersionOfBundledStubs()

public function testGetDataDirectoryReturnsThePathToIcuData()
{
$this->assertTrue(is_dir(Intl::getDataDirectory()));
$this->assertDirectoryExists(Intl::getDataDirectory());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testItClonesTheRepository()
$git = GitRepository::download(self::REPO_URL, $this->targetDir);

$this->assertInstanceOf(GitRepository::class, $git);
$this->assertTrue(is_dir($this->targetDir.'/.git'));
$this->assertDirectoryExists($this->targetDir.'/.git');
$this->assertSame($this->targetDir, $git->getPath());
$this->assertSame(self::REPO_URL, $git->getUrl());
$this->assertRegExp('#^[0-9a-z]{40}$#', $git->getLastCommitHash());
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.