|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Blaspsoft\Blasp\Tests; |
| 4 | + |
| 5 | +use Blaspsoft\Blasp\Facades\Blasp; |
| 6 | + |
| 7 | +class Issue32FalsePositiveTest extends TestCase |
| 8 | +{ |
| 9 | + /** |
| 10 | + * @dataProvider legitimateWordsProvider |
| 11 | + */ |
| 12 | + public function test_legitimate_words_not_flagged(string $word) |
| 13 | + { |
| 14 | + $result = Blasp::check($word); |
| 15 | + $this->assertFalse( |
| 16 | + $result->hasProfanity(), |
| 17 | + "\"$word\" should not be flagged as profanity but got: " . implode(', ', $result->getUniqueProfanitiesFound()) |
| 18 | + ); |
| 19 | + } |
| 20 | + |
| 21 | + public static function legitimateWordsProvider(): array |
| 22 | + { |
| 23 | + return [ |
| 24 | + 'assignment' => ['assignment'], |
| 25 | + 'passion' => ['passion'], |
| 26 | + 'classroom' => ['classroom'], |
| 27 | + 'passenger' => ['passenger'], |
| 28 | + 'assassin' => ['assassin'], |
| 29 | + 'massive' => ['massive'], |
| 30 | + 'embassy' => ['embassy'], |
| 31 | + 'harassment' => ['harassment'], |
| 32 | + 'compassion' => ['compassion'], |
| 33 | + 'association' => ['association'], |
| 34 | + ]; |
| 35 | + } |
| 36 | + |
| 37 | + public function test_actual_profanity_still_detected() |
| 38 | + { |
| 39 | + $result = Blasp::check('ass'); |
| 40 | + $this->assertTrue($result->hasProfanity()); |
| 41 | + } |
| 42 | +} |
0 commit comments