@@ -597,6 +597,37 @@ public static function provideSlice()
597597 ['awesome ' , 'Symfony is awesome ' , 11 , 7 ],
598598 ['awesome ' , 'Symfony is awesome ' , -7 , null ],
599599 ['awe ' , 'Symfony is awesome ' , -7 , -4 ],
600+ ['S ' , 'Symfony is awesome ' , -42 , 1 ],
601+ ['' , 'Symfony is awesome ' , 42 , 1 ],
602+ ['' , 'Symfony is awesome ' , 0 , -42 ],
603+ ];
604+ }
605+
606+ /**
607+ * @dataProvider provideSplice
608+ */
609+ public function testSplice (string $ expected , int $ start , int $ length = null )
610+ {
611+ $ this ->assertEquals (
612+ static ::createFromString ($ expected ),
613+ static ::createFromString ('Symfony is awesome ' )->splice ('X ' , $ start , $ length )
614+ );
615+ }
616+
617+ public static function provideSplice ()
618+ {
619+ return [
620+ ['X is awesome ' , 0 , 7 ],
621+ ['SymfonyXis awesome ' , 7 , 1 ],
622+ ['Symfony X awesome ' , 8 , 2 ],
623+ ['Symfony X ' , 8 , null ],
624+ ['Symfony isXawesome ' , 10 , 1 ],
625+ ['Symfony is X ' , 11 , 7 ],
626+ ['Symfony is X ' , -7 , null ],
627+ ['Symfony is Xsome ' , -7 , -4 ],
628+ ['Xymfony is awesome ' , -42 , 1 ],
629+ ['Symfony is awesomeX ' , 42 , 1 ],
630+ ['XSymfony is awesome ' , 0 , -42 ],
600631 ];
601632 }
602633
@@ -766,12 +797,12 @@ public function testBeforeAfter(string $expected, string $needle, string $origin
766797 public static function provideBeforeAfter ()
767798 {
768799 return [
769- ['' , '' , 'hello world ' , 0 , true ],
770- ['' , '' , 'hello world ' , 0 , false ],
771- ['' , 'w ' , 'hello World ' , 0 , true ],
772- ['' , 'w ' , 'hello World ' , 0 , false ],
773- ['' , 'o ' , 'hello world ' , 10 , true ],
774- ['' , 'o ' , 'hello world ' , 10 , false ],
800+ ['hello world ' , '' , 'hello world ' , 0 , true ],
801+ ['hello world ' , '' , 'hello world ' , 0 , false ],
802+ ['hello World ' , 'w ' , 'hello World ' , 0 , true ],
803+ ['hello World ' , 'w ' , 'hello World ' , 0 , false ],
804+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
805+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
775806 ['hello ' , 'w ' , 'hello world ' , 0 , true ],
776807 ['world ' , 'w ' , 'hello world ' , 0 , false ],
777808 ['hello W ' , 'O ' , 'hello WORLD ' , 0 , true ],
@@ -794,12 +825,12 @@ public function testBeforeAfterIgnoreCase(string $expected, string $needle, stri
794825 public static function provideBeforeAfterIgnoreCase ()
795826 {
796827 return [
797- ['' , '' , 'hello world ' , 0 , true ],
798- ['' , '' , 'hello world ' , 0 , false ],
799- ['' , 'foo ' , 'hello world ' , 0 , true ],
800- ['' , 'foo ' , 'hello world ' , 0 , false ],
801- ['' , 'o ' , 'hello world ' , 10 , true ],
802- ['' , 'o ' , 'hello world ' , 10 , false ],
828+ ['hello world ' , '' , 'hello world ' , 0 , true ],
829+ ['hello world ' , '' , 'hello world ' , 0 , false ],
830+ ['hello world ' , 'foo ' , 'hello world ' , 0 , true ],
831+ ['hello world ' , 'foo ' , 'hello world ' , 0 , false ],
832+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
833+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
803834 ['hello ' , 'w ' , 'hello world ' , 0 , true ],
804835 ['world ' , 'w ' , 'hello world ' , 0 , false ],
805836 ['hello ' , 'W ' , 'hello world ' , 0 , true ],
@@ -822,12 +853,12 @@ public function testBeforeAfterLast(string $expected, string $needle, string $or
822853 public static function provideBeforeAfterLast ()
823854 {
824855 return [
825- ['' , '' , 'hello world ' , 0 , true ],
826- ['' , '' , 'hello world ' , 0 , false ],
827- ['' , 'L ' , 'hello world ' , 0 , true ],
828- ['' , 'L ' , 'hello world ' , 0 , false ],
829- ['' , 'o ' , 'hello world ' , 10 , true ],
830- ['' , 'o ' , 'hello world ' , 10 , false ],
856+ ['hello world ' , '' , 'hello world ' , 0 , true ],
857+ ['hello world ' , '' , 'hello world ' , 0 , false ],
858+ ['hello world ' , 'L ' , 'hello world ' , 0 , true ],
859+ ['hello world ' , 'L ' , 'hello world ' , 0 , false ],
860+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
861+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
831862 ['hello wor ' , 'l ' , 'hello world ' , 0 , true ],
832863 ['ld ' , 'l ' , 'hello world ' , 0 , false ],
833864 ['hello w ' , 'o ' , 'hello world ' , 0 , true ],
@@ -851,12 +882,12 @@ public function testBeforeAfterLastIgnoreCase(string $expected, string $needle,
851882 public static function provideBeforeAfterLastIgnoreCase ()
852883 {
853884 return [
854- ['' , '' , 'hello world ' , 0 , true ],
855- ['' , '' , 'hello world ' , 0 , false ],
856- ['' , 'FOO ' , 'hello world ' , 0 , true ],
857- ['' , 'FOO ' , 'hello world ' , 0 , false ],
858- ['' , 'o ' , 'hello world ' , 10 , true ],
859- ['' , 'o ' , 'hello world ' , 10 , false ],
885+ ['hello world ' , '' , 'hello world ' , 0 , true ],
886+ ['hello world ' , '' , 'hello world ' , 0 , false ],
887+ ['hello world ' , 'FOO ' , 'hello world ' , 0 , true ],
888+ ['hello world ' , 'FOO ' , 'hello world ' , 0 , false ],
889+ ['hello world ' , 'o ' , 'hello world ' , 10 , true ],
890+ ['hello world ' , 'o ' , 'hello world ' , 10 , false ],
860891 ['hello wor ' , 'l ' , 'hello world ' , 0 , true ],
861892 ['ld ' , 'l ' , 'hello world ' , 0 , false ],
862893 ['hello wor ' , 'L ' , 'hello world ' , 0 , true ],
0 commit comments