@@ -1131,4 +1131,44 @@ public function testFromBase64(): void
1131
1131
$ this ->assertSame ('foo ' , Str::fromBase64 (base64_encode ('foo ' )));
1132
1132
$ this ->assertSame ('foobar ' , Str::fromBase64 (base64_encode ('foobar ' ), true ));
1133
1133
}
1134
+
1135
+ public function testChopStart ()
1136
+ {
1137
+ foreach ([
1138
+ 'http://laravel.com ' => ['http:// ' , 'laravel.com ' ],
1139
+ 'http://-http:// ' => ['http:// ' , '-http:// ' ],
1140
+ 'http://laravel.com ' => ['htp:/ ' , 'http://laravel.com ' ],
1141
+ 'http://laravel.com ' => ['http://www. ' , 'http://laravel.com ' ],
1142
+ 'http://laravel.com ' => ['-http:// ' , 'http://laravel.com ' ],
1143
+ 'http://laravel.com ' => [['https:// ' , 'http:// ' ], 'laravel.com ' ],
1144
+ 'http://www.laravel.com ' => [['http:// ' , 'www. ' ], 'www.laravel.com ' ],
1145
+ 'http://http-is-fun.test ' => ['http:// ' , 'http-is-fun.test ' ],
1146
+ 'πβ ' => ['π ' , 'β ' ],
1147
+ 'πβ ' => ['β ' , 'πβ ' ],
1148
+ ] as $ subject => $ value ) {
1149
+ [$ needle , $ expected ] = $ value ;
1150
+
1151
+ $ this ->assertSame ($ expected , Str::chopStart ($ subject , $ needle ));
1152
+ }
1153
+ }
1154
+
1155
+ public function testChopEnd ()
1156
+ {
1157
+ foreach ([
1158
+ 'path/to/file.php ' => ['.php ' , 'path/to/file ' ],
1159
+ '.php-.php ' => ['.php ' , '.php- ' ],
1160
+ 'path/to/file.php ' => ['.ph ' , 'path/to/file.php ' ],
1161
+ 'path/to/file.php ' => ['foo.php ' , 'path/to/file.php ' ],
1162
+ 'path/to/file.php ' => ['.php- ' , 'path/to/file.php ' ],
1163
+ 'path/to/file.php ' => [['.html ' , '.php ' ], 'path/to/file ' ],
1164
+ 'path/to/file.php ' => [['.php ' , 'file ' ], 'path/to/file ' ],
1165
+ 'path/to/php.php ' => ['.php ' , 'path/to/php ' ],
1166
+ 'βπ ' => ['π ' , 'β ' ],
1167
+ 'βπ ' => ['β ' , 'βπ ' ],
1168
+ ] as $ subject => $ value ) {
1169
+ [$ needle , $ expected ] = $ value ;
1170
+
1171
+ $ this ->assertSame ($ expected , Str::chopEnd ($ subject , $ needle ));
1172
+ }
1173
+ }
1134
1174
}
0 commit comments