Tests to the "containsCaseless" method from class Str

This commit is contained in:
Dorian Neto 2017-09-25 19:10:55 -03:00
parent 40e6d6d62b
commit e61adc9066
2 changed files with 25 additions and 0 deletions

View File

@ -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 = [

View File

@ -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'));