Skip to content

Commit 48a66c1

Browse files
committed
Test recursive symlinks
1 parent c2ffd53 commit 48a66c1

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,22 +1609,27 @@ public function testDumpFileFollowsSymlink()
16091609
{
16101610
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo.txt';
16111611
file_put_contents($filename, 'FOO BAR');
1612-
$linkname = $this->workspace.\DIRECTORY_SEPARATOR.'bar.txt';
1613-
$this->filesystem->symlink($filename, $linkname);
1612+
$linknameA = $this->workspace.\DIRECTORY_SEPARATOR.'bar.txt';
1613+
$linknameB = $this->workspace.\DIRECTORY_SEPARATOR.'baz.txt';
1614+
$this->filesystem->symlink($filename, $linknameA);
1615+
$this->filesystem->symlink($linknameA, $linknameB);
16141616

1615-
$this->filesystem->dumpFile($linkname, 'bar');
1617+
$this->filesystem->dumpFile($linknameB, 'bar');
16161618

16171619
$this->assertFileExists($filename);
1618-
$this->assertFileExists($linkname);
1620+
$this->assertFileExists($linknameA);
1621+
$this->assertFileExists($linknameB);
16191622
$this->assertStringEqualsFile($filename, 'bar');
1620-
$this->assertStringEqualsFile($linkname, 'bar');
1623+
$this->assertStringEqualsFile($linknameA, 'bar');
1624+
$this->assertStringEqualsFile($linknameB, 'bar');
16211625

16221626
$this->filesystem->remove($filename);
1623-
$this->filesystem->dumpFile($linkname, 'baz');
1627+
$this->filesystem->dumpFile($linknameB, 'baz');
16241628

16251629
$this->assertFileExists($filename);
16261630
$this->assertStringEqualsFile($filename, 'baz');
1627-
$this->assertStringEqualsFile($linkname, 'baz');
1631+
$this->assertStringEqualsFile($linknameA, 'baz');
1632+
$this->assertStringEqualsFile($linknameB, 'baz');
16281633
}
16291634

16301635
public function testDumpFileWithFileScheme()
@@ -1704,22 +1709,29 @@ public function testAppendToFileFollowsSymlink()
17041709
{
17051710
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo.txt';
17061711
file_put_contents($filename, 'foo');
1707-
$linkname = $this->workspace.\DIRECTORY_SEPARATOR.'bar.txt';
1708-
$this->filesystem->symlink($filename, $linkname);
1712+
$linknameA = $this->workspace.\DIRECTORY_SEPARATOR.'bar.txt';
1713+
$linknameB = $this->workspace.\DIRECTORY_SEPARATOR.'baz.txt';
1714+
$this->filesystem->symlink($filename, $linknameA);
1715+
$this->filesystem->symlink($linknameA, $linknameB);
17091716

1710-
$this->filesystem->appendToFile($linkname, 'bar');
1717+
$this->filesystem->appendToFile($linknameA, 'bar');
1718+
$this->filesystem->appendToFile($linknameB, 'baz');
17111719

17121720
$this->assertFileExists($filename);
1713-
$this->assertFileExists($linkname);
1714-
$this->assertStringEqualsFile($filename, 'foobar');
1715-
$this->assertStringEqualsFile($linkname, 'foobar');
1721+
$this->assertFileExists($linknameA);
1722+
$this->assertFileExists($linknameB);
1723+
$this->assertStringEqualsFile($filename, 'foobarbaz');
1724+
$this->assertStringEqualsFile($linknameA, 'foobarbaz');
1725+
$this->assertStringEqualsFile($linknameB, 'foobarbaz');
17161726

17171727
$this->filesystem->remove($filename);
1718-
$this->filesystem->appendToFile($linkname, 'baz');
1728+
$this->filesystem->appendToFile($linknameB, 'foo');
1729+
$this->filesystem->appendToFile($linknameA, 'bar');
17191730

17201731
$this->assertFileExists($filename);
1721-
$this->assertStringEqualsFile($filename, 'baz');
1722-
$this->assertStringEqualsFile($linkname, 'baz');
1732+
$this->assertStringEqualsFile($filename, 'foobar');
1733+
$this->assertStringEqualsFile($linknameA, 'foobar');
1734+
$this->assertStringEqualsFile($linknameB, 'foobar');
17231735
}
17241736

17251737
public function testAppendToFileWithScheme()

0 commit comments

Comments
 (0)