mmm... that test should fail but no
This commit is contained in:
parent
f046206e3b
commit
d396cb076e
|
|
@ -34,6 +34,7 @@ return [
|
|||
'sex',
|
||||
'shit',
|
||||
'slut',
|
||||
'sucker',
|
||||
'titties',
|
||||
'twat',
|
||||
'vagina',
|
||||
|
|
|
|||
|
|
@ -6,27 +6,28 @@ use \Mockery as m;
|
|||
|
||||
class ProfaneValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockConfigs();
|
||||
}
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
m::close();
|
||||
}
|
||||
|
||||
public function test_can_validate_a_word()
|
||||
public function test_can_validate_a_word_with_numbers()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
$attribute = 'username';
|
||||
$word = 'culero23';
|
||||
$parameters = ['es'];
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
|
||||
$this->assertFalse($profane->validate($attribute, $word, $parameters));
|
||||
}
|
||||
|
||||
public function test_can_validate_a_text()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
$attribute = 'description';
|
||||
$text = 'fck you bitch. 幹!';
|
||||
$parameters = ['es', 'en' , 'zh-tw'];
|
||||
|
|
@ -39,71 +40,58 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase
|
|||
public function test_can_evaluate_profanity_of_a_word()
|
||||
{
|
||||
$word = 'fuck';
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
|
||||
$this->assertTrue($profane->isProfane($word));
|
||||
}
|
||||
|
||||
public function test_can_evaluate_profanity_of_a_sentence()
|
||||
{
|
||||
$word = 'fuck you if you read this';
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
|
||||
$this->assertTrue($profane->isProfane($word));
|
||||
}
|
||||
|
||||
public function test_can_evaluate_profanity_of_a_html_string()
|
||||
{
|
||||
$word = '<b>fuck</b> you if you read this.';
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
|
||||
$this->assertTrue($profane->isProfane($word));
|
||||
}
|
||||
|
||||
public function test_can_evaluate_as_caseless_mode()
|
||||
{
|
||||
$word = '<b>FUCK</b> you BITCH if you read this.';
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
|
||||
$this->assertTrue($profane->isProfane($word));
|
||||
}
|
||||
|
||||
public function test_match_exact_word()
|
||||
{
|
||||
$profane = new ProfaneValidator();
|
||||
// it thinks class ~= ass
|
||||
$this->assertTrue($profane->isProfane('class'));
|
||||
// but this should be profane
|
||||
$this->assertTrue($profane->isProfane('sucker96'));
|
||||
}
|
||||
|
||||
public function test_can_set_dictionary_when_you_pass_a_locale()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
$profane->setDictionary('es');
|
||||
|
||||
$expected = include __DIR__.'/../src/dict/es.php';
|
||||
|
||||
$this->assertEquals($profane->getBadwords(), $expected);
|
||||
}
|
||||
|
||||
public function test_can_set_dictionary_when_you_pass_a_file()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
$profane->setDictionary(__DIR__.'/../src/dict/es.php');
|
||||
|
||||
$expected = include __DIR__.'/../src/dict/es.php';
|
||||
|
||||
$this->assertEquals($profane->getBadwords(), $expected);
|
||||
}
|
||||
|
||||
public function test_can_set_dictionary_when_you_pass_an_array_of_files()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
$profane->setDictionary([__DIR__.'/../src/dict/es.php', __DIR__.'/../src/dict/en.php']);
|
||||
|
||||
|
|
@ -114,37 +102,26 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function test_can_set_dictionary_when_you_pass_an_array_of_locales()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
$profane->setDictionary(['es', 'en', 'it', 'zh-tw']);
|
||||
|
||||
$expected = array_merge(include __DIR__.'/../src/dict/es.php', include __DIR__.'/../src/dict/en.php', include __DIR__.'/../src/dict/it.php', include __DIR__.'/../src/dict/zh-tw.php');
|
||||
|
||||
$this->assertEquals($profane->getBadwords(), $expected);
|
||||
}
|
||||
|
||||
public function test_can_validate_a_bad_word_with_accent()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
$profane->setDictionary('sk');
|
||||
|
||||
$word = "piča";
|
||||
|
||||
$this->assertTrue( $profane->isProfane($word) );
|
||||
}
|
||||
|
||||
public function test_enie_in_spanish_is_evaluated()
|
||||
{
|
||||
$this->mockConfigs();
|
||||
|
||||
$profane = new ProfaneValidator();
|
||||
$profane->setDictionary('es');
|
||||
|
||||
$word = "coño";
|
||||
|
||||
// in spanish coño =! cono
|
||||
$this->assertTrue( $profane->isProfane($word) );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue