From 74cc1e3c7cfbf2a8855bf6e13cc59116cf7c127f Mon Sep 17 00:00:00 2001 From: Apostolos Siokas Date: Wed, 21 Jun 2017 19:24:16 +0300 Subject: [PATCH] Adding Greek bad words list --- src/Str.php | 2 +- src/dict/gr.php | 116 +++++++++++++++++++++++++++++++++ src/lang/gr/validator.php | 5 ++ tests/ProfaneValidatorTest.php | 24 +++++++ 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 src/dict/gr.php create mode 100644 src/lang/gr/validator.php diff --git a/src/Str.php b/src/Str.php index 2838e4b..228903a 100644 --- a/src/Str.php +++ b/src/Str.php @@ -67,7 +67,7 @@ class Str 'в'=>'v', 'ו'=>'v', 'В'=>'v', 'ש'=>'w', 'ŵ'=>'w', 'Ŵ'=>'w', 'ы'=>'y', 'ŷ'=>'y', 'ý'=>'y', 'ÿ'=>'y', 'Ÿ'=>'y', 'Ŷ'=>'y', - 'Ы'=>'y', 'ž'=>'z', 'З'=>'z', 'з'=>'z', 'ź'=>'z', 'ז'=>'z', 'ż'=>'z', 'ſ'=>'z', 'Ж'=>'zh', 'ж'=>'zh' + 'Ы'=>'y', 'ž'=>'z', 'З'=>'z', 'з'=>'z', 'ź'=>'z', 'ז'=>'z', 'ż'=>'z', 'ſ'=>'z', 'Ж'=>'zh', 'ж'=>'zh', 'ά' => 'α', 'έ' => 'ε', 'ή' => 'η', 'ί' => 'ι', 'ό' => 'ο', 'ύ' => 'υ', 'ώ' => 'ω', ]; return strtr($string, $replace); diff --git a/src/dict/gr.php b/src/dict/gr.php new file mode 100644 index 0000000..eb143c7 --- /dev/null +++ b/src/dict/gr.php @@ -0,0 +1,116 @@ + 'Στο πεδίο :attribute εμπεριέχονται χυδαίες εκφράσεις', +]; diff --git a/tests/ProfaneValidatorTest.php b/tests/ProfaneValidatorTest.php index 63ce3d1..4b62918 100644 --- a/tests/ProfaneValidatorTest.php +++ b/tests/ProfaneValidatorTest.php @@ -148,6 +148,30 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase $this->assertTrue( $profane->isProfane($word) ); } + public function test_can_validate_a_word_in_greek() + { + $this->mockConfigs(); + + $profane = new ProfaneValidator(); + $profane->setDictionary('gr'); + + $word = "μαλάκας"; + + $this->assertTrue($profane->isProfane($word)); + } + + public function test_can_validate_a_text_in_greek() + { + $this->mockConfigs(); + $attribute = 'description'; + $text = 'εισαι πουτανα'; + $parameters = ['en' , 'gr']; + + $profane = new ProfaneValidator(); + + $this->assertFalse($profane->validate($attribute, $text, $parameters)); + } + private function mockConfigs() { Config::shouldReceive('get')