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 }
@@ -613,11 +605,9 @@ public function testChownLink()
613605 $ this ->assertSame ($ owner , $ this ->getFileOwner ($ link ));
614606 }
615607
616- /**
617- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
618- */
619608 public function testChownSymlinkFails ()
620609 {
610+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
621611 $ this ->markAsSkippedIfSymlinkIsMissing ();
622612
623613 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -630,11 +620,9 @@ public function testChownSymlinkFails()
630620 $ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
631621 }
632622
633- /**
634- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
635- */
636623 public function testChownLinkFails ()
637624 {
625+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
638626 $ this ->markAsSkippedIfLinkIsMissing ();
639627
640628 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -647,11 +635,9 @@ public function testChownLinkFails()
647635 $ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
648636 }
649637
650- /**
651- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
652- */
653638 public function testChownFail ()
654639 {
640+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
655641 $ this ->markAsSkippedIfPosixIsMissing ();
656642
657643 $ dir = $ this ->workspace .\DIRECTORY_SEPARATOR .'dir ' ;
@@ -722,11 +708,9 @@ public function testChgrpLink()
722708 $ this ->assertSame ($ group , $ this ->getFileGroup ($ link ));
723709 }
724710
725- /**
726- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
727- */
728711 public function testChgrpSymlinkFails ()
729712 {
713+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
730714 $ this ->markAsSkippedIfSymlinkIsMissing ();
731715
732716 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -739,11 +723,9 @@ public function testChgrpSymlinkFails()
739723 $ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
740724 }
741725
742- /**
743- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
744- */
745726 public function testChgrpLinkFails ()
746727 {
728+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
747729 $ this ->markAsSkippedIfLinkIsMissing ();
748730
749731 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -756,11 +738,9 @@ public function testChgrpLinkFails()
756738 $ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
757739 }
758740
759- /**
760- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
761- */
762741 public function testChgrpFail ()
763742 {
743+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
764744 $ this ->markAsSkippedIfPosixIsMissing ();
765745
766746 $ dir = $ this ->workspace .\DIRECTORY_SEPARATOR .'dir ' ;
@@ -781,11 +761,9 @@ public function testRename()
781761 $ this ->assertFileExists ($ newPath );
782762 }
783763
784- /**
785- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
786- */
787764 public function testRenameThrowsExceptionIfTargetAlreadyExists ()
788765 {
766+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
789767 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
790768 $ newPath = $ this ->workspace .\DIRECTORY_SEPARATOR .'new_file ' ;
791769
@@ -809,11 +787,9 @@ public function testRenameOverwritesTheTargetIfItAlreadyExists()
809787 $ this ->assertFileExists ($ newPath );
810788 }
811789
812- /**
813- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
814- */
815790 public function testRenameThrowsExceptionOnError ()
816791 {
792+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
817793 $ file = $ this ->workspace .\DIRECTORY_SEPARATOR .uniqid ('fs_test_ ' , true );
818794 $ newPath = $ this ->workspace .\DIRECTORY_SEPARATOR .'new_file ' ;
819795
@@ -1420,11 +1396,9 @@ public function testTempnamWithMockScheme()
14201396 $ this ->assertFileExists ($ filename );
14211397 }
14221398
1423- /**
1424- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1425- */
14261399 public function testTempnamWithZlibSchemeFails ()
14271400 {
1401+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
14281402 $ scheme = 'compress.zlib:// ' ;
14291403 $ dirname = $ scheme .$ this ->workspace ;
14301404
@@ -1445,11 +1419,9 @@ public function testTempnamWithPHPTempSchemeFails()
14451419 $ this ->assertFileNotExists ($ filename );
14461420 }
14471421
1448- /**
1449- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1450- */
14511422 public function testTempnamWithPharSchemeFails ()
14521423 {
1424+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
14531425 // Skip test if Phar disabled phar.readonly must be 0 in php.ini
14541426 if (!\Phar::canWrite ()) {
14551427 $ this ->markTestSkipped ('This test cannot run when phar.readonly is 1. ' );
@@ -1464,11 +1436,9 @@ public function testTempnamWithPharSchemeFails()
14641436 $ this ->filesystem ->tempnam ($ dirname , $ pharname .'/bar ' );
14651437 }
14661438
1467- /**
1468- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1469- */
14701439 public function testTempnamWithHTTPSchemeFails ()
14711440 {
1441+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
14721442 $ scheme = 'http:// ' ;
14731443 $ dirname = $ scheme .$ this ->workspace ;
14741444
0 commit comments