11
11
12
12
namespace Symfony \Component \Filesystem \Tests ;
13
13
14
+ use Symfony \Bridge \PhpUnit \ForwardCompatTestTrait ;
15
+
14
16
/**
15
17
* Test class for Filesystem.
16
18
*/
17
19
class FilesystemTest extends FilesystemTestCase
18
20
{
21
+ use ForwardCompatTestTrait;
22
+
19
23
public function testCopyCreatesNewFile ()
20
24
{
21
25
$ sourceFilePath = $ this ->workspace .\DIRECTORY_SEPARATOR .'copy_source_file ' ;
@@ -29,22 +33,18 @@ public function testCopyCreatesNewFile()
29
33
$ this ->assertStringEqualsFile ($ targetFilePath , 'SOURCE FILE ' );
30
34
}
31
35
32
- /**
33
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
34
- */
35
36
public function testCopyFails ()
36
37
{
38
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
37
39
$ sourceFilePath = $ this ->workspace .\DIRECTORY_SEPARATOR .'copy_source_file ' ;
38
40
$ targetFilePath = $ this ->workspace .\DIRECTORY_SEPARATOR .'copy_target_file ' ;
39
41
40
42
$ this ->filesystem ->copy ($ sourceFilePath , $ targetFilePath );
41
43
}
42
44
43
- /**
44
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
45
- */
46
45
public function testCopyUnreadableFileFails ()
47
46
{
47
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
48
48
// skip test on Windows; PHP can't easily set file as unreadable on Windows
49
49
if ('\\' === \DIRECTORY_SEPARATOR ) {
50
50
$ this ->markTestSkipped ('This test cannot run on Windows. ' );
@@ -118,11 +118,9 @@ public function testCopyOverridesExistingFileIfForced()
118
118
$ this ->assertStringEqualsFile ($ targetFilePath , 'SOURCE FILE ' );
119
119
}
120
120
121
- /**
122
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
123
- */
124
121
public function testCopyWithOverrideWithReadOnlyTargetFails ()
125
122
{
123
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
126
124
// skip test on Windows; PHP can't easily set file as unwritable on Windows
127
125
if ('\\' === \DIRECTORY_SEPARATOR ) {
128
126
$ this ->markTestSkipped ('This test cannot run on Windows. ' );
@@ -222,11 +220,9 @@ public function testMkdirCreatesDirectoriesFromTraversableObject()
222
220
$ this ->assertTrue (is_dir ($ basePath .'3 ' ));
223
221
}
224
222
225
- /**
226
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
227
- */
228
223
public function testMkdirCreatesDirectoriesFails ()
229
224
{
225
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
230
226
$ basePath = $ this ->workspace .\DIRECTORY_SEPARATOR ;
231
227
$ dir = $ basePath .'2 ' ;
232
228
@@ -244,11 +240,9 @@ public function testTouchCreatesEmptyFile()
244
240
$ this ->assertFileExists ($ file );
245
241
}
246
242
247
- /**
248
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
249
- */
250
243
public function testTouchFails ()
251
244
{
245
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
252
246
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'1 ' .\DIRECTORY_SEPARATOR .'2 ' ;
253
247
254
248
$ this ->filesystem ->touch ($ file );
@@ -380,11 +374,9 @@ public function testFilesExists()
380
374
$ this ->assertTrue ($ this ->filesystem ->exists ($ basePath .'folder ' ));
381
375
}
382
376
383
- /**
384
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
385
- */
386
377
public function testFilesExistsFails ()
387
378
{
379
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
388
380
if ('\\' !== \DIRECTORY_SEPARATOR ) {
389
381
$ this ->markTestSkipped ('Long file names are an issue on Windows ' );
390
382
}
@@ -613,11 +605,9 @@ public function testChownLink()
613
605
$ this ->assertSame ($ owner , $ this ->getFileOwner ($ link ));
614
606
}
615
607
616
- /**
617
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
618
- */
619
608
public function testChownSymlinkFails ()
620
609
{
610
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
621
611
$ this ->markAsSkippedIfSymlinkIsMissing ();
622
612
623
613
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -630,11 +620,9 @@ public function testChownSymlinkFails()
630
620
$ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
631
621
}
632
622
633
- /**
634
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
635
- */
636
623
public function testChownLinkFails ()
637
624
{
625
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
638
626
$ this ->markAsSkippedIfLinkIsMissing ();
639
627
640
628
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -647,11 +635,9 @@ public function testChownLinkFails()
647
635
$ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
648
636
}
649
637
650
- /**
651
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
652
- */
653
638
public function testChownFail ()
654
639
{
640
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
655
641
$ this ->markAsSkippedIfPosixIsMissing ();
656
642
657
643
$ dir = $ this ->workspace .\DIRECTORY_SEPARATOR .'dir ' ;
@@ -722,11 +708,9 @@ public function testChgrpLink()
722
708
$ this ->assertSame ($ group , $ this ->getFileGroup ($ link ));
723
709
}
724
710
725
- /**
726
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
727
- */
728
711
public function testChgrpSymlinkFails ()
729
712
{
713
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
730
714
$ this ->markAsSkippedIfSymlinkIsMissing ();
731
715
732
716
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -739,11 +723,9 @@ public function testChgrpSymlinkFails()
739
723
$ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
740
724
}
741
725
742
- /**
743
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
744
- */
745
726
public function testChgrpLinkFails ()
746
727
{
728
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
747
729
$ this ->markAsSkippedIfLinkIsMissing ();
748
730
749
731
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
@@ -756,11 +738,9 @@ public function testChgrpLinkFails()
756
738
$ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
757
739
}
758
740
759
- /**
760
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
761
- */
762
741
public function testChgrpFail ()
763
742
{
743
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
764
744
$ this ->markAsSkippedIfPosixIsMissing ();
765
745
766
746
$ dir = $ this ->workspace .\DIRECTORY_SEPARATOR .'dir ' ;
@@ -781,11 +761,9 @@ public function testRename()
781
761
$ this ->assertFileExists ($ newPath );
782
762
}
783
763
784
- /**
785
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
786
- */
787
764
public function testRenameThrowsExceptionIfTargetAlreadyExists ()
788
765
{
766
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
789
767
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .'file ' ;
790
768
$ newPath = $ this ->workspace .\DIRECTORY_SEPARATOR .'new_file ' ;
791
769
@@ -809,11 +787,9 @@ public function testRenameOverwritesTheTargetIfItAlreadyExists()
809
787
$ this ->assertFileExists ($ newPath );
810
788
}
811
789
812
- /**
813
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
814
- */
815
790
public function testRenameThrowsExceptionOnError ()
816
791
{
792
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
817
793
$ file = $ this ->workspace .\DIRECTORY_SEPARATOR .uniqid ('fs_test_ ' , true );
818
794
$ newPath = $ this ->workspace .\DIRECTORY_SEPARATOR .'new_file ' ;
819
795
@@ -1420,11 +1396,9 @@ public function testTempnamWithMockScheme()
1420
1396
$ this ->assertFileExists ($ filename );
1421
1397
}
1422
1398
1423
- /**
1424
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1425
- */
1426
1399
public function testTempnamWithZlibSchemeFails ()
1427
1400
{
1401
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
1428
1402
$ scheme = 'compress.zlib:// ' ;
1429
1403
$ dirname = $ scheme .$ this ->workspace ;
1430
1404
@@ -1445,11 +1419,9 @@ public function testTempnamWithPHPTempSchemeFails()
1445
1419
$ this ->assertFileNotExists ($ filename );
1446
1420
}
1447
1421
1448
- /**
1449
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1450
- */
1451
1422
public function testTempnamWithPharSchemeFails ()
1452
1423
{
1424
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
1453
1425
// Skip test if Phar disabled phar.readonly must be 0 in php.ini
1454
1426
if (!\Phar::canWrite ()) {
1455
1427
$ this ->markTestSkipped ('This test cannot run when phar.readonly is 1. ' );
@@ -1464,11 +1436,9 @@ public function testTempnamWithPharSchemeFails()
1464
1436
$ this ->filesystem ->tempnam ($ dirname , $ pharname .'/bar ' );
1465
1437
}
1466
1438
1467
- /**
1468
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
1469
- */
1470
1439
public function testTempnamWithHTTPSchemeFails ()
1471
1440
{
1441
+ $ this ->expectException ('Symfony\Component\Filesystem\Exception\IOException ' );
1472
1442
$ scheme = 'http:// ' ;
1473
1443
$ dirname = $ scheme .$ this ->workspace ;
1474
1444
0 commit comments