@@ -343,6 +343,10 @@ public function testValidateString()
343343 $ str_equals = ['equals ' => 'Hello, World! ' ];
344344 $ str_in = ['in ' => ['hello ' , 'world ' , 'foo ' , 'bar ' ]];
345345 $ str_regex = ['regex ' => "/php/i " ];
346+ $ str_starts_with = ['starts_with ' => 'Hello ' ];
347+ $ str_ends_with = ['ends_with ' => 'World! ' ];
348+ $ str_contains = ['contains ' => 'llo, W ' ];
349+ $ str_case_insensitive = ['case_sensitive ' => false ];
346350
347351 $ this ->assertTrue (Validator::isString ('abc ' , array_merge ($ str_min_length , $ str_max_length )));
348352 $ this ->assertFalse (Validator::isString ('' , $ str_min_length ));
@@ -352,11 +356,21 @@ public function testValidateString()
352356 $ this ->assertFalse (Validator::isString (null ));
353357 $ this ->assertTrue (Validator::isString (null , $ str_allow_null ));
354358 $ this ->assertTrue (Validator::isString ('Hello, World! ' , $ str_equals ));
359+ $ this ->assertTrue (Validator::isString ('hello, world! ' , array_merge ($ str_case_insensitive , $ str_equals )));
355360 $ this ->assertFalse (Validator::isString ('Hello World! ' , $ str_equals ));
356361 $ this ->assertTrue (Validator::isString ('foo ' , $ str_in ));
357362 $ this ->assertFalse (Validator::isString ('cat ' , $ str_in ));
358363 $ this ->assertTrue (Validator::isString ('PHP is my favorite! ' , $ str_regex ));
359364 $ this ->assertFalse (Validator::isString ('Java is my favorite! ' , $ str_regex ));
365+ $ this ->assertTrue (Validator::isString ('Hello, World! ' , $ str_starts_with ));
366+ $ this ->assertTrue (Validator::isString ('hello, world! ' , array_merge ($ str_case_insensitive , $ str_starts_with )));
367+ $ this ->assertFalse (Validator::isString ('Jello, World! ' , $ str_starts_with ));
368+ $ this ->assertTrue (Validator::isString ('Hello, World! ' , $ str_ends_with ));
369+ $ this ->assertTrue (Validator::isString ('hello, world! ' , array_merge ($ str_case_insensitive , $ str_ends_with )));
370+ $ this ->assertFalse (Validator::isString ('Hello, whorld! ' , $ str_ends_with ));
371+ $ this ->assertTrue (Validator::isString ('Hello, World! ' , $ str_contains ));
372+ $ this ->assertTrue (Validator::isString ('hello, world! ' , array_merge ($ str_case_insensitive , $ str_contains )));
373+ $ this ->assertFalse (Validator::isString ('Hell0, World! ' , $ str_contains ));
360374 }
361375
362376 /**
0 commit comments