@@ -565,6 +565,20 @@ public function testChownSymlink()
565
565
$ this ->filesystem ->chown ($ link , $ this ->getFileOwner ($ link ));
566
566
}
567
567
568
+ public function testChownLink ()
569
+ {
570
+ $ this ->markAsSkippedIfLinkIsMissing ();
571
+
572
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
573
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
574
+
575
+ touch ($ file );
576
+
577
+ $ this ->filesystem ->hardlink ($ file , $ link );
578
+
579
+ $ this ->filesystem ->chown ($ link , $ this ->getFileOwner ($ link ));
580
+ }
581
+
568
582
/**
569
583
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
570
584
*/
@@ -582,6 +596,23 @@ public function testChownSymlinkFails()
582
596
$ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
583
597
}
584
598
599
+ /**
600
+ * @expectedException \Symfony\Component\Filesystem\Exception\IOException
601
+ */
602
+ public function testChownLinkFails ()
603
+ {
604
+ $ this ->markAsSkippedIfLinkIsMissing ();
605
+
606
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
607
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
608
+
609
+ touch ($ file );
610
+
611
+ $ this ->filesystem ->hardlink ($ file , $ link );
612
+
613
+ $ this ->filesystem ->chown ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
614
+ }
615
+
585
616
/**
586
617
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
587
618
*/
@@ -631,6 +662,20 @@ public function testChgrpSymlink()
631
662
$ this ->filesystem ->chgrp ($ link , $ this ->getFileGroup ($ link ));
632
663
}
633
664
665
+ public function testChgrpLink ()
666
+ {
667
+ $ this ->markAsSkippedIfLinkIsMissing ();
668
+
669
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
670
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
671
+
672
+ touch ($ file );
673
+
674
+ $ this ->filesystem ->hardlink ($ file , $ link );
675
+
676
+ $ this ->filesystem ->chgrp ($ link , $ this ->getFileGroup ($ link ));
677
+ }
678
+
634
679
/**
635
680
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
636
681
*/
@@ -648,6 +693,23 @@ public function testChgrpSymlinkFails()
648
693
$ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
649
694
}
650
695
696
+ /**
697
+ * @expectedException \Symfony\Component\Filesystem\Exception\IOException
698
+ */
699
+ public function testChgrpLinkFails ()
700
+ {
701
+ $ this ->markAsSkippedIfLinkIsMissing ();
702
+
703
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
704
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
705
+
706
+ touch ($ file );
707
+
708
+ $ this ->filesystem ->hardlink ($ file , $ link );
709
+
710
+ $ this ->filesystem ->chgrp ($ link , 'user ' .time ().mt_rand (1000 , 9999 ));
711
+ }
712
+
651
713
/**
652
714
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
653
715
*/
@@ -799,6 +861,103 @@ public function testSymlinkCreatesTargetDirectoryIfItDoesNotExist()
799
861
$ this ->assertEquals ($ file , readlink ($ link2 ));
800
862
}
801
863
864
+ public function testLink ()
865
+ {
866
+ $ this ->markAsSkippedIfLinkIsMissing ();
867
+
868
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
869
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
870
+
871
+ touch ($ file );
872
+ $ this ->filesystem ->hardlink ($ file , $ link );
873
+
874
+ $ this ->assertTrue (is_file ($ link ));
875
+ $ this ->assertEquals (fileinode ($ file ), fileinode ($ link ));
876
+ }
877
+
878
+ /**
879
+ * @depends testLink
880
+ */
881
+ public function testRemoveLink ()
882
+ {
883
+ $ this ->markAsSkippedIfLinkIsMissing ();
884
+
885
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
886
+
887
+ $ this ->filesystem ->remove ($ link );
888
+
889
+ $ this ->assertTrue (!is_file ($ link ));
890
+ }
891
+
892
+ public function testLinkIsOverwrittenIfPointsToDifferentTarget ()
893
+ {
894
+ $ this ->markAsSkippedIfLinkIsMissing ();
895
+
896
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
897
+ $ file2 = $ this ->workspace .DIRECTORY_SEPARATOR .'file2 ' ;
898
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
899
+
900
+ touch ($ file );
901
+ touch ($ file2 );
902
+ link ($ file2 , $ link );
903
+
904
+ $ this ->filesystem ->hardlink ($ file , $ link );
905
+
906
+ $ this ->assertTrue (is_file ($ link ));
907
+ $ this ->assertEquals (fileinode ($ file ), fileinode ($ link ));
908
+ }
909
+
910
+ public function testLinkIsNotOverwrittenIfAlreadyCreated ()
911
+ {
912
+ $ this ->markAsSkippedIfLinkIsMissing ();
913
+
914
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
915
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
916
+
917
+ touch ($ file );
918
+ link ($ file , $ link );
919
+
920
+ $ this ->filesystem ->hardlink ($ file , $ link );
921
+
922
+ $ this ->assertTrue (is_file ($ link ));
923
+ $ this ->assertEquals (fileinode ($ file ), fileinode ($ link ));
924
+
925
+ }
926
+
927
+ public function testLinkWithSeveralTargets ()
928
+ {
929
+ $ this ->markAsSkippedIfLinkIsMissing ();
930
+
931
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
932
+ $ link1 = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
933
+ $ link2 = $ this ->workspace .DIRECTORY_SEPARATOR .'link2 ' ;
934
+
935
+ touch ($ file );
936
+
937
+ $ this ->filesystem ->hardlink ($ file , array ($ link1 ,$ link2 ));
938
+
939
+ $ this ->assertTrue (is_file ($ link1 ));
940
+ $ this ->assertEquals (fileinode ($ file ), fileinode ($ link1 ));
941
+ $ this ->assertTrue (is_file ($ link2 ));
942
+ $ this ->assertEquals (fileinode ($ file ), fileinode ($ link2 ));
943
+ }
944
+
945
+ public function testLinkWithSameTarget ()
946
+ {
947
+ $ this ->markAsSkippedIfLinkIsMissing ();
948
+
949
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
950
+ $ link = $ this ->workspace .DIRECTORY_SEPARATOR .'link ' ;
951
+
952
+ touch ($ file );
953
+
954
+ // practically same as testLinkIsNotOverwrittenIfAlreadyCreated
955
+ $ this ->filesystem ->hardlink ($ file , array ($ link ,$ link ));
956
+
957
+ $ this ->assertTrue (is_file ($ link ));
958
+ $ this ->assertEquals (fileinode ($ file ), fileinode ($ link ));
959
+ }
960
+
802
961
/**
803
962
* @dataProvider providePathsForMakePathRelative
804
963
*/
0 commit comments