From a27af3baa56c66d37d066e27d4b11ae6b3d51c3b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 11 Jan 2021 09:47:58 +0100 Subject: [PATCH] Use ::class keyword when possible --- Tests/FilesystemTest.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Tests/FilesystemTest.php b/Tests/FilesystemTest.php index b697d7f47..a0de640d0 100644 --- a/Tests/FilesystemTest.php +++ b/Tests/FilesystemTest.php @@ -33,7 +33,7 @@ public function testCopyCreatesNewFile() public function testCopyFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file'; $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; @@ -42,7 +42,7 @@ public function testCopyFails() public function testCopyUnreadableFileFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); // skip test on Windows; PHP can't easily set file as unreadable on Windows if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test cannot run on Windows.'); @@ -118,7 +118,7 @@ public function testCopyOverridesExistingFileIfForced() public function testCopyWithOverrideWithReadOnlyTargetFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); // skip test on Windows; PHP can't easily set file as unwritable on Windows if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test cannot run on Windows.'); @@ -220,7 +220,7 @@ public function testMkdirCreatesDirectoriesFromTraversableObject() public function testMkdirCreatesDirectoriesFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $basePath = $this->workspace.\DIRECTORY_SEPARATOR; $dir = $basePath.'2'; @@ -240,7 +240,7 @@ public function testTouchCreatesEmptyFile() public function testTouchFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $file = $this->workspace.\DIRECTORY_SEPARATOR.'1'.\DIRECTORY_SEPARATOR.'2'; $this->filesystem->touch($file); @@ -396,7 +396,7 @@ public function testFilesExists() public function testFilesExistsFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); if ('\\' !== \DIRECTORY_SEPARATOR) { $this->markTestSkipped('Long file names are an issue on Windows'); } @@ -623,7 +623,7 @@ public function testChownLink() public function testChownSymlinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfSymlinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -638,7 +638,7 @@ public function testChownSymlinkFails() public function testChownLinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfLinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -653,7 +653,7 @@ public function testChownLinkFails() public function testChownFail() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfPosixIsMissing(); $dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir'; @@ -726,7 +726,7 @@ public function testChgrpLink() public function testChgrpSymlinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfSymlinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -741,7 +741,7 @@ public function testChgrpSymlinkFails() public function testChgrpLinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfLinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -756,7 +756,7 @@ public function testChgrpLinkFails() public function testChgrpFail() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfPosixIsMissing(); $dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir'; @@ -779,7 +779,7 @@ public function testRename() public function testRenameThrowsExceptionIfTargetAlreadyExists() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; $newPath = $this->workspace.\DIRECTORY_SEPARATOR.'new_file'; @@ -805,7 +805,7 @@ public function testRenameOverwritesTheTargetIfItAlreadyExists() public function testRenameThrowsExceptionOnError() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $file = $this->workspace.\DIRECTORY_SEPARATOR.uniqid('fs_test_', true); $newPath = $this->workspace.\DIRECTORY_SEPARATOR.'new_file'; @@ -1150,14 +1150,14 @@ public function providePathsForMakePathRelative() public function testMakePathRelativeWithRelativeStartPath() { - $this->expectException('Symfony\Component\Filesystem\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Filesystem\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The start path "var/lib/symfony/src/Symfony/Component" is not absolute.'); $this->assertSame('../../../', $this->filesystem->makePathRelative('/var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component')); } public function testMakePathRelativeWithRelativeEndPath() { - $this->expectException('Symfony\Component\Filesystem\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Filesystem\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The end path "var/lib/symfony/" is not absolute.'); $this->assertSame('../../../', $this->filesystem->makePathRelative('var/lib/symfony/', '/var/lib/symfony/src/Symfony/Component')); } @@ -1440,7 +1440,7 @@ public function testTempnamWithMockScheme() public function testTempnamWithZlibSchemeFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $scheme = 'compress.zlib://'; $dirname = $scheme.$this->workspace; @@ -1463,7 +1463,7 @@ public function testTempnamWithPHPTempSchemeFails() public function testTempnamWithPharSchemeFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); // Skip test if Phar disabled phar.readonly must be 0 in php.ini if (!\Phar::canWrite()) { $this->markTestSkipped('This test cannot run when phar.readonly is 1.'); @@ -1480,7 +1480,7 @@ public function testTempnamWithPharSchemeFails() public function testTempnamWithHTTPSchemeFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $scheme = 'http://'; $dirname = $scheme.$this->workspace;