1111
1212namespace Symfony \Component \Filesystem \Tests ;
1313
14+ use Symfony \Bridge \PhpUnit \ForwardCompatTestTrait ;
15+
1416/**
1517 * Test class for Filesystem.
1618 */
1719class FilesystemTest extends FilesystemTestCase
1820{
21+ use ForwardCompatTestTrait;
22+
1923 public function testCopyCreatesNewFile ()
2024 {
2125 $ sourceFilePath = $ this ->workspace .\DIRECTORY_SEPARATOR .'copy_source_file ' ;
@@ -29,22 +33,18 @@ public function testCopyCreatesNewFile()
2933 $ this ->assertStringEqualsFile ($ targetFilePath , 'SOURCE FILE ' );
3034 }
3135
32- /**
33- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
34- */
3536 public function testCopyFails ()
3637 {
38+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
3739 $ sourceFilePath = $ this ->workspace .\DIRECTORY_SEPARATOR .'copy_source_file ' ;
3840 $ targetFilePath = $ this ->workspace .\DIRECTORY_SEPARATOR .'copy_target_file ' ;
3941
4042 $ this ->filesystem ->copy ($ sourceFilePath , $ targetFilePath );
4143 }
4244
43- /**
44- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
45- */
4645 public function testCopyUnreadableFileFails ()
4746 {
47+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
4848 // skip test on Windows; PHP can't easily set file as unreadable on Windows
4949 if ('\\' === \DIRECTORY_SEPARATOR ) {
5050 $ this ->markTestSkipped ('This test cannot run on Windows. ' );
@@ -118,11 +118,9 @@ public function testCopyOverridesExistingFileIfForced()
118118 $ this ->assertStringEqualsFile ($ targetFilePath , 'SOURCE FILE ' );
119119 }
120120
121- /**
122- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
123- */
124121 public function testCopyWithOverrideWithReadOnlyTargetFails ()
125122 {
123+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
126124 // skip test on Windows; PHP can't easily set file as unwritable on Windows
127125 if ('\\' === \DIRECTORY_SEPARATOR ) {
128126 $ this ->markTestSkipped ('This test cannot run on Windows. ' );
@@ -222,11 +220,9 @@ public function testMkdirCreatesDirectoriesFromTraversableObject()
222220 $ this ->assertTrue (is_dir ($ basePath .'3 ' ));
223221 }
224222
225- /**
226- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
227- */
228223 public function testMkdirCreatesDirectoriesFails ()
229224 {
225+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
230226 $ basePath = $ this ->workspace .\DIRECTORY_SEPARATOR ;
231227 $ dir = $ basePath .'2 ' ;
232228
@@ -244,11 +240,9 @@ public function testTouchCreatesEmptyFile()
244240 $ this ->assertFileExists ($ file );
245241 }
246242
247- /**
248- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
249- */
250243 public function testTouchFails ()
251244 {
245+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
252246 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'1 ' .\DIRECTORY_SEPARATOR .'2 ' ;
253247
254248 $ this ->filesystem ->touch ($ file );
@@ -380,11 +374,9 @@ public function testFilesExists()
380374 $ this ->assertTrue ($ this ->filesystem ->exists ($ basePath .'folder ' ));
381375 }
382376
383- /**
384- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
385- */
386377 public function testFilesExistsFails ()
387378 {
379+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
388380 if ('\\' !== \DIRECTORY_SEPARATOR ) {
389381 $ this ->markTestSkipped ('Long file names are an issue on Windows ' );
390382 }
@@ -595,11 +587,9 @@ public function testChownLink()
595587 $ this ->assertSame ($ owner , $ this ->getFileOwner ($ link ));
596588 }
597589
598- /**
599- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
600- */
601590 public function testChownSymlinkFails ()
602591 {
592+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
603593 $ this ->markAsSkippedIfSymlinkIsMissing ();
604594
605595 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -612,11 +602,9 @@ public function testChownSymlinkFails()
612602 $ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
613603 }
614604
615- /**
616- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
617- */
618605 public function testChownLinkFails ()
619606 {
607+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
620608 $ this ->markAsSkippedIfLinkIsMissing ();
621609
622610 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -629,11 +617,9 @@ public function testChownLinkFails()
629617 $ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
630618 }
631619
632- /**
633- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
634- */
635620 public function testChownFail ()
636621 {
622+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
637623 $ this ->markAsSkippedIfPosixIsMissing ();
638624
639625 $ dir = $ this ->workspace .\DIRECTORY_SEPARATOR .'dir ' ;
@@ -704,11 +690,9 @@ public function testChgrpLink()
704690 $ this ->assertSame ($ group , $ this ->getFileGroup ($ link ));
705691 }
706692
707- /**
708- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
709- */
710693 public function testChgrpSymlinkFails ()
711694 {
695+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
712696 $ this ->markAsSkippedIfSymlinkIsMissing ();
713697
714698 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -721,11 +705,9 @@ public function testChgrpSymlinkFails()
721705 $ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
722706 }
723707
724- /**
725- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
726- */
727708 public function testChgrpLinkFails ()
728709 {
710+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
729711 $ this ->markAsSkippedIfLinkIsMissing ();
730712
731713 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -738,11 +720,9 @@ public function testChgrpLinkFails()
738720 $ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
739721 }
740722
741- /**
742- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
743- */
744723 public function testChgrpFail ()
745724 {
725+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
746726 $ this ->markAsSkippedIfPosixIsMissing ();
747727
748728 $ dir = $ this ->workspace .\DIRECTORY_SEPARATOR .'dir ' ;
@@ -763,11 +743,9 @@ public function testRename()
763743 $ this ->assertFileExists ($ newPath );
764744 }
765745
766- /**
767- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
768- */
769746 public function testRenameThrowsExceptionIfTargetAlreadyExists ()
770747 {
748+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
771749 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
772750 $ newPath = $ this ->workspace .\DIRECTORY_SEPARATOR .'new_file ' ;
773751
@@ -791,11 +769,9 @@ public function testRenameOverwritesTheTargetIfItAlreadyExists()
791769 $ this ->assertFileExists ($ newPath );
792770 }
793771
794- /**
795- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
796- */
797772 public function testRenameThrowsExceptionOnError ()
798773 {
774+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
799775 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .uniqid ('fs_test_ ' , true );
800776 $ newPath = $ this ->workspace .\DIRECTORY_SEPARATOR .'new_file ' ;
801777
@@ -1134,21 +1110,17 @@ public function providePathsForMakePathRelative()
11341110 return $ paths ;
11351111 }
11361112
1137- /**
1138- * @expectedException \Symfony\Component\Filesystem\Exception\InvalidArgumentException
1139- * @expectedExceptionMessage The start path "var/lib/symfony/src/Symfony/Component" is not absolute.
1140- */
11411113 public function testMakePathRelativeWithRelativeStartPath ()
11421114 {
1115+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\InvalidArgumentException ' );
1116+ $ this ->expectExceptionMessage ('The start path "var/lib/symfony/src/Symfony/Component" is not absolute. ' );
11431117 $ this ->assertSame ('../../../ ' , $ this ->filesystem ->makePathRelative ('/var/lib/symfony/ ' , 'var/lib/symfony/src/Symfony/Component ' ));
11441118 }
11451119
1146- /**
1147- * @expectedException \Symfony\Component\Filesystem\Exception\InvalidArgumentException
1148- * @expectedExceptionMessage The end path "var/lib/symfony/" is not absolute.
1149- */
11501120 public function testMakePathRelativeWithRelativeEndPath ()
11511121 {
1122+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\InvalidArgumentException ' );
1123+ $ this ->expectExceptionMessage ('The end path "var/lib/symfony/" is not absolute. ' );
11521124 $ this ->assertSame ('../../../ ' , $ this ->filesystem ->makePathRelative ('var/lib/symfony/ ' , '/var/lib/symfony/src/Symfony/Component ' ));
11531125 }
11541126
@@ -1419,11 +1391,9 @@ public function testTempnamWithMockScheme()
14191391 $ this ->assertFileExists ($ filename );
14201392 }
14211393
1422- /**
1423- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1424- */
14251394 public function testTempnamWithZlibSchemeFails ()
14261395 {
1396+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
14271397 $ scheme = 'compress.zlib:// ' ;
14281398 $ dirname = $ scheme .$ this ->workspace ;
14291399
@@ -1444,11 +1414,9 @@ public function testTempnamWithPHPTempSchemeFails()
14441414 $ this ->assertFileNotExists ($ filename );
14451415 }
14461416
1447- /**
1448- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1449- */
14501417 public function testTempnamWithPharSchemeFails ()
14511418 {
1419+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
14521420 // Skip test if Phar disabled phar.readonly must be 0 in php.ini
14531421 if (!\Phar::canWrite ()) {
14541422 $ this ->markTestSkipped ('This test cannot run when phar.readonly is 1. ' );
@@ -1463,11 +1431,9 @@ public function testTempnamWithPharSchemeFails()
14631431 $ this ->filesystem ->tempnam ($ dirname , $ pharname .'/bar ' );
14641432 }
14651433
1466- /**
1467- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1468- */
14691434 public function testTempnamWithHTTPSchemeFails ()
14701435 {
1436+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
14711437 $ scheme = 'http:// ' ;
14721438 $ dirname = $ scheme .$ this ->workspace ;
14731439
0 commit comments