@@ -1334,21 +1334,21 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption()
1334
1334
1335
1335
public function testMirrorWithCustomIterator ()
1336
1336
{
1337
- $ sourcePath = $ this ->workspace .DIRECTORY_SEPARATOR .'source ' .DIRECTORY_SEPARATOR ;
1337
+ $ sourcePath = $ this ->workspace .\ DIRECTORY_SEPARATOR .'source ' .\ DIRECTORY_SEPARATOR ;
1338
1338
mkdir ($ sourcePath );
1339
1339
1340
- $ file = $ sourcePath .DIRECTORY_SEPARATOR .'file ' ;
1340
+ $ file = $ sourcePath .\ DIRECTORY_SEPARATOR .'file ' ;
1341
1341
file_put_contents ($ file , 'FILE ' );
1342
1342
1343
- $ targetPath = $ this ->workspace .DIRECTORY_SEPARATOR .'target ' .DIRECTORY_SEPARATOR ;
1343
+ $ targetPath = $ this ->workspace .\ DIRECTORY_SEPARATOR .'target ' .\ DIRECTORY_SEPARATOR ;
1344
1344
1345
1345
$ splFile = new \SplFileInfo ($ file );
1346
1346
$ iterator = new \ArrayObject (array ($ splFile ));
1347
1347
1348
1348
$ this ->filesystem ->mirror ($ sourcePath , $ targetPath , $ iterator );
1349
1349
1350
1350
$ this ->assertTrue (is_dir ($ targetPath ));
1351
- $ this ->assertFileEquals ($ file , $ targetPath .DIRECTORY_SEPARATOR .'file ' );
1351
+ $ this ->assertFileEquals ($ file , $ targetPath .\ DIRECTORY_SEPARATOR .'file ' );
1352
1352
}
1353
1353
1354
1354
/**
@@ -1357,14 +1357,14 @@ public function testMirrorWithCustomIterator()
1357
1357
*/
1358
1358
public function testMirrorWithCustomIteratorWithRelativePath ()
1359
1359
{
1360
- $ sourcePath = $ this ->workspace .DIRECTORY_SEPARATOR .'source ' .DIRECTORY_SEPARATOR .'.. ' .DIRECTORY_SEPARATOR .'source ' .DIRECTORY_SEPARATOR ;
1361
- $ realSourcePath = $ this ->workspace .DIRECTORY_SEPARATOR .'source ' .DIRECTORY_SEPARATOR ;
1360
+ $ sourcePath = $ this ->workspace .\ DIRECTORY_SEPARATOR .'source ' .\ DIRECTORY_SEPARATOR .'.. ' .\ DIRECTORY_SEPARATOR .'source ' .\ DIRECTORY_SEPARATOR ;
1361
+ $ realSourcePath = $ this ->workspace .\ DIRECTORY_SEPARATOR .'source ' .\ DIRECTORY_SEPARATOR ;
1362
1362
mkdir ($ realSourcePath );
1363
1363
1364
1364
$ file = $ realSourcePath .'file ' ;
1365
1365
file_put_contents ($ file , 'FILE ' );
1366
1366
1367
- $ targetPath = $ this ->workspace .DIRECTORY_SEPARATOR .'target ' .DIRECTORY_SEPARATOR .'.. ' .DIRECTORY_SEPARATOR .'target ' .DIRECTORY_SEPARATOR ;
1367
+ $ targetPath = $ this ->workspace .\ DIRECTORY_SEPARATOR .'target ' .\ DIRECTORY_SEPARATOR .'.. ' .\ DIRECTORY_SEPARATOR .'target ' .\ DIRECTORY_SEPARATOR ;
1368
1368
1369
1369
$ splFile = new \SplFileInfo ($ file );
1370
1370
$ iterator = new \ArrayObject (array ($ splFile ));
@@ -1518,6 +1518,10 @@ public function testDumpFile()
1518
1518
}
1519
1519
}
1520
1520
1521
+ /**
1522
+ * @group legacy
1523
+ * @expectedDeprecation Calling "Symfony\Component\Filesystem\Filesystem::dumpFile()" with an array in the $content argument is deprecated since Symfony 4.3.
1524
+ */
1521
1525
public function testDumpFileWithArray ()
1522
1526
{
1523
1527
$ filename = $ this ->workspace .\DIRECTORY_SEPARATOR .'foo ' .\DIRECTORY_SEPARATOR .'baz.txt ' ;
@@ -1600,6 +1604,60 @@ public function testAppendToFile()
1600
1604
}
1601
1605
}
1602
1606
1607
+ /**
1608
+ * @group legacy
1609
+ * @expectedDeprecation Calling "Symfony\Component\Filesystem\Filesystem::appendToFile()" with an array in the $content argument is deprecated since Symfony 4.3.
1610
+ */
1611
+ public function testAppendToFileWithArray ()
1612
+ {
1613
+ $ filename = $ this ->workspace .\DIRECTORY_SEPARATOR .'foo ' .\DIRECTORY_SEPARATOR .'bar.txt ' ;
1614
+
1615
+ // skip mode check on Windows
1616
+ if ('\\' !== \DIRECTORY_SEPARATOR ) {
1617
+ $ oldMask = umask (0002 );
1618
+ }
1619
+
1620
+ $ this ->filesystem ->dumpFile ($ filename , 'foo ' );
1621
+
1622
+ $ this ->filesystem ->appendToFile ($ filename , array ('bar ' ));
1623
+
1624
+ $ this ->assertFileExists ($ filename );
1625
+ $ this ->assertStringEqualsFile ($ filename , 'foobar ' );
1626
+
1627
+ // skip mode check on Windows
1628
+ if ('\\' !== \DIRECTORY_SEPARATOR ) {
1629
+ $ this ->assertFilePermissions (664 , $ filename );
1630
+ umask ($ oldMask );
1631
+ }
1632
+ }
1633
+
1634
+ public function testAppendToFileWithResource ()
1635
+ {
1636
+ $ filename = $ this ->workspace .\DIRECTORY_SEPARATOR .'foo ' .\DIRECTORY_SEPARATOR .'bar.txt ' ;
1637
+
1638
+ // skip mode check on Windows
1639
+ if ('\\' !== \DIRECTORY_SEPARATOR ) {
1640
+ $ oldMask = umask (0002 );
1641
+ }
1642
+
1643
+ $ this ->filesystem ->dumpFile ($ filename , 'foo ' );
1644
+
1645
+ $ resource = fopen ('php://memory ' , 'rw ' );
1646
+ fwrite ($ resource , 'bar ' );
1647
+ fseek ($ resource , 0 );
1648
+
1649
+ $ this ->filesystem ->appendToFile ($ filename , $ resource );
1650
+
1651
+ $ this ->assertFileExists ($ filename );
1652
+ $ this ->assertStringEqualsFile ($ filename , 'foobar ' );
1653
+
1654
+ // skip mode check on Windows
1655
+ if ('\\' !== \DIRECTORY_SEPARATOR ) {
1656
+ $ this ->assertFilePermissions (664 , $ filename );
1657
+ umask ($ oldMask );
1658
+ }
1659
+ }
1660
+
1603
1661
public function testAppendToFileWithScheme ()
1604
1662
{
1605
1663
$ scheme = 'file:// ' ;
0 commit comments