From e61adc906687d25c50c05ce031177776bf3c5df1 Mon Sep 17 00:00:00 2001 From: Dorian Neto Date: Mon, 25 Sep 2017 19:10:55 -0300 Subject: [PATCH] Tests to the "containsCaseless" method from class Str --- src/Str.php | 5 +++++ tests/StrTest.php | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/Str.php b/src/Str.php index 228903a..ac805fe 100644 --- a/src/Str.php +++ b/src/Str.php @@ -23,6 +23,11 @@ class Str return false; } + /** + * Remove accents or special characters from a string. + * @param string $string + * @return string + */ public static function removeAccent($string) { $replace = [ diff --git a/tests/StrTest.php b/tests/StrTest.php index f80a64a..e64d919 100644 --- a/tests/StrTest.php +++ b/tests/StrTest.php @@ -7,6 +7,26 @@ use LaravelProfane\Str; class StrTest extends TestCase { + public function test_string_contains_a_piece_insensitive_match_from_text() + { + $this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'ass')); + } + + public function test_text_contains_insensitive_match_from_array() + { + $this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', ['fuk', 'fuck'])); + } + + public function test_text_contains_insensitive_match_from_string() + { + $this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'fUcK')); + } + + public function test_text_contains_the_same_insensitive_match_from_string() + { + $this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'Fuck')); + } + public function test_remove_accents_in_spanish_text() { $this->assertEquals('cojon', Str::removeAccent('cojón'));