diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..461b7b5 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":{"LaravelProfaneTests\\DictionaryTest::test_word_from_only_vi_files":3,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_vietnamese":3,"LaravelProfaneTests\\StrTest::test_remove_accents_in_vietnamese":3},"times":{"LaravelProfaneTests\\DictionaryTest::test_words_from_only_one_locale":0.021,"LaravelProfaneTests\\DictionaryTest::test_words_from_only_one_file":0.001,"LaravelProfaneTests\\DictionaryTest::test_words_from_locale_array":0.001,"LaravelProfaneTests\\DictionaryTest::test_words_from_file_array":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_with_numbers":0.003,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_not_validate_a_word_with_numbers_in_strict_mode":0.004,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_text":0.003,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_word":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_sentence":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_sentence_in_strict_mode":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_html_string":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_as_caseless_mode":0,"LaravelProfaneTests\\ProfaneValidatorTest::test_match_content":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_match_exact_word_in_strict_mode":0.004,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_bad_word_with_accent":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_enie_in_spanish_is_evaluated":0,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_greek":0.002,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_text_in_greek":0.002,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_french":0.002,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_french_canadian":0.001,"LaravelProfaneTests\\StrTest::test_string_contains_a_piece_insensitive_match_from_text":0,"LaravelProfaneTests\\StrTest::test_text_contains_insensitive_match_from_array":0,"LaravelProfaneTests\\StrTest::test_text_contains_insensitive_match_from_string":0,"LaravelProfaneTests\\StrTest::test_text_does_not_contain_match_in_strict_mode":0,"LaravelProfaneTests\\StrTest::test_text_contains_match_in_strict_mode":0,"LaravelProfaneTests\\StrTest::test_text_contains_match_in_not_strict_mode":0,"LaravelProfaneTests\\StrTest::test_text_contains_the_same_insensitive_match_from_string":0,"LaravelProfaneTests\\StrTest::test_remove_accents_in_spanish_text":0,"LaravelProfaneTests\\StrTest::test_enie_char_is_allowed":0,"LaravelProfaneTests\\StrTest::test_remove_accents_in_greek":0,"LaravelProfaneTests\\DictionaryTest::test_word_from_only_vi_files":0,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_vietnamese":0,"LaravelProfaneTests\\StrTest::test_remove_accents_in_vietnamese":0,"LaravelProfaneTests\\StrTest::test_text_contains_sensitive_match_from_string_in_vietnamese":0}} \ No newline at end of file diff --git a/src/dict/vi.php b/src/dict/vi.php new file mode 100644 index 0000000..daa4230 --- /dev/null +++ b/src/dict/vi.php @@ -0,0 +1,25 @@ + 'Trường :attribute có từ thô tục' +]; diff --git a/tests/DictionaryTest.php b/tests/DictionaryTest.php index 79abbcd..8858870 100644 --- a/tests/DictionaryTest.php +++ b/tests/DictionaryTest.php @@ -55,4 +55,11 @@ public function test_words_from_file_array() $this->assertEquals($dictionary->getDictionary(), $expected); } + + public function test_word_from_only_vi_files(){ + $dictionary = new Dictionary(__DIR__.'/../src/dict/vi.php'); + $expected = include __DIR__.'/../src/dict/vi.php'; + $this->assertEquals($dictionary->getDictionary(), $expected); + } + } diff --git a/tests/ProfaneValidatorTest.php b/tests/ProfaneValidatorTest.php index 95ffb7f..2baa1e6 100644 --- a/tests/ProfaneValidatorTest.php +++ b/tests/ProfaneValidatorTest.php @@ -150,4 +150,15 @@ public function test_can_validate_a_word_in_french_canadian() $this->assertFalse($builder->validate(['description', 'Décrisse gros cave', ['en', 'fr-ca']])); } + + public function test_can_validate_a_word_in_vietnamese(){ + $this->mockConfigs(); + + $builder = new ProfaneValidatorBuilder('vi'); + + $word = 'ê con cạc thằng lồn'; + + $this->assertTrue($builder->build()->isProfane($word)); + } + } diff --git a/tests/StrTest.php b/tests/StrTest.php index a7427ca..3b42fc6 100644 --- a/tests/StrTest.php +++ b/tests/StrTest.php @@ -59,4 +59,13 @@ public function test_remove_accents_in_greek() { $this->assertEquals('μαλακας', Str::removeAccent('μαλάκας')); } + + public function test_remove_accents_in_vietnamese(){ + $this->assertEquals('thằng lồn', Str::removeAccent('thằng lồn')); + } + + public function test_text_contains_sensitive_match_from_string_in_vietnamese(){ + $this->assertTrue(Str::containsCaseless('con đỉ mẹ mày', 'đỉ mẹ mày')); + } + }