@@ -1091,14 +1091,16 @@ public function testReadBrokenLink()
1091
1091
{
1092
1092
$ this ->markAsSkippedIfSymlinkIsMissing ();
1093
1093
1094
- if ('\\' === \DIRECTORY_SEPARATOR ) {
1095
- $ this ->markTestSkipped ('Windows does not support creating "broken" symlinks ' );
1094
+ if ('\\' === \DIRECTORY_SEPARATOR && \ PHP_VERSION_ID < 70400 ) {
1095
+ $ this ->markTestSkipped ('Windows does not support reading "broken" symlinks in PHP < 7.4.0 ' );
1096
1096
}
1097
1097
1098
1098
$ file = $ this ->workspace .'/file ' ;
1099
1099
$ link = $ this ->workspace .'/link ' ;
1100
1100
1101
+ touch ($ file );
1101
1102
$ this ->filesystem ->symlink ($ file , $ link );
1103
+ $ this ->filesystem ->remove ($ file );
1102
1104
1103
1105
$ this ->assertEquals ($ file , $ this ->filesystem ->readlink ($ link ));
1104
1106
$ this ->assertNull ($ this ->filesystem ->readlink ($ link , true ));
@@ -1605,6 +1607,38 @@ public function testDumpFileOverwritesAnExistingFile()
1605
1607
$ this ->assertStringEqualsFile ($ filename , 'bar ' );
1606
1608
}
1607
1609
1610
+ public function testDumpFileFollowsSymlink ()
1611
+ {
1612
+ $ filename = $ this ->workspace .\DIRECTORY_SEPARATOR .'foo.txt ' ;
1613
+ file_put_contents ($ filename , 'FOO BAR ' );
1614
+ $ linknameA = $ this ->workspace .\DIRECTORY_SEPARATOR .'bar.txt ' ;
1615
+ $ linknameB = $ this ->workspace .\DIRECTORY_SEPARATOR .'baz.txt ' ;
1616
+ $ this ->filesystem ->symlink ($ filename , $ linknameA );
1617
+ $ this ->filesystem ->symlink ($ linknameA , $ linknameB );
1618
+
1619
+ $ this ->filesystem ->dumpFile ($ linknameB , 'bar ' );
1620
+
1621
+ $ this ->assertFileExists ($ filename );
1622
+ $ this ->assertFileExists ($ linknameA );
1623
+ $ this ->assertFileExists ($ linknameB );
1624
+ $ this ->assertStringEqualsFile ($ filename , 'bar ' );
1625
+ $ this ->assertStringEqualsFile ($ linknameA , 'bar ' );
1626
+ $ this ->assertStringEqualsFile ($ linknameB , 'bar ' );
1627
+
1628
+ // Windows does not support reading "broken" symlinks in PHP < 7.4.0
1629
+ if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400 ) {
1630
+ return ;
1631
+ }
1632
+
1633
+ $ this ->filesystem ->remove ($ filename );
1634
+ $ this ->filesystem ->dumpFile ($ linknameB , 'baz ' );
1635
+
1636
+ $ this ->assertFileExists ($ filename );
1637
+ $ this ->assertStringEqualsFile ($ filename , 'baz ' );
1638
+ $ this ->assertStringEqualsFile ($ linknameA , 'baz ' );
1639
+ $ this ->assertStringEqualsFile ($ linknameB , 'baz ' );
1640
+ }
1641
+
1608
1642
public function testDumpFileWithFileScheme ()
1609
1643
{
1610
1644
$ scheme = 'file:// ' ;
@@ -1678,6 +1712,35 @@ public function testAppendToFileWithResource()
1678
1712
}
1679
1713
}
1680
1714
1715
+ public function testAppendToFileFollowsSymlink ()
1716
+ {
1717
+ $ filename = $ this ->workspace .\DIRECTORY_SEPARATOR .'foo.txt ' ;
1718
+ file_put_contents ($ filename , 'foo ' );
1719
+ $ linknameA = $ this ->workspace .\DIRECTORY_SEPARATOR .'bar.txt ' ;
1720
+ $ linknameB = $ this ->workspace .\DIRECTORY_SEPARATOR .'baz.txt ' ;
1721
+ $ this ->filesystem ->symlink ($ filename , $ linknameA );
1722
+ $ this ->filesystem ->symlink ($ linknameA , $ linknameB );
1723
+
1724
+ $ this ->filesystem ->appendToFile ($ linknameA , 'bar ' );
1725
+ $ this ->filesystem ->appendToFile ($ linknameB , 'baz ' );
1726
+
1727
+ $ this ->assertFileExists ($ filename );
1728
+ $ this ->assertFileExists ($ linknameA );
1729
+ $ this ->assertFileExists ($ linknameB );
1730
+ $ this ->assertStringEqualsFile ($ filename , 'foobarbaz ' );
1731
+ $ this ->assertStringEqualsFile ($ linknameA , 'foobarbaz ' );
1732
+ $ this ->assertStringEqualsFile ($ linknameB , 'foobarbaz ' );
1733
+
1734
+ $ this ->filesystem ->remove ($ filename );
1735
+ $ this ->filesystem ->appendToFile ($ linknameB , 'foo ' );
1736
+ $ this ->filesystem ->appendToFile ($ linknameA , 'bar ' );
1737
+
1738
+ $ this ->assertFileExists ($ filename );
1739
+ $ this ->assertStringEqualsFile ($ filename , 'foobar ' );
1740
+ $ this ->assertStringEqualsFile ($ linknameA , 'foobar ' );
1741
+ $ this ->assertStringEqualsFile ($ linknameB , 'foobar ' );
1742
+ }
1743
+
1681
1744
public function testAppendToFileWithScheme ()
1682
1745
{
1683
1746
$ scheme = 'file:// ' ;
0 commit comments