-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-introduce check for comment similarity to annoy spammers. Do not a…
…llow comments with email addresses.
- Loading branch information
1 parent
0d7ac8c
commit 51edc14
Showing
4 changed files
with
181 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,6 +269,55 @@ public function testLongTextWithLowNumberUpdatesIsNotANewExperience() | |
|
||
$this->assertFalse($this->commentModel->checkIfNewExperience($original, $updated)); | ||
} | ||
|
||
public function testCommentWithEmailAddressInTextIsRecognized() | ||
{ | ||
$comment = new Comment(); | ||
$comment->setTextfree('This is [email protected] in the middle of a text.'); | ||
|
||
$emailAddressFound = $this->commentModel->checkForEmailAddress($comment); | ||
|
||
$this->assertTrue($emailAddressFound); | ||
} | ||
public function testCommentWithEmailAddressAtStartOfTextIsRecognized() | ||
{ | ||
$comment = new Comment(); | ||
$comment->setTextfree('[email protected] at the start of a text.'); | ||
|
||
$emailAddressFound = $this->commentModel->checkForEmailAddress($comment); | ||
|
||
$this->assertTrue($emailAddressFound); | ||
} | ||
public function testCommentWithEmailAddressAtTheEndOfTextIsRecognized() | ||
{ | ||
$comment = new Comment(); | ||
$comment->setTextfree('At the end of this text, there is [email protected]'); | ||
|
||
$emailAddressFound = $this->commentModel->checkForEmailAddress($comment); | ||
|
||
$this->assertTrue($emailAddressFound); | ||
} | ||
|
||
public function testCommentWithTwoEmailAddressesInTextIsRecognized() | ||
{ | ||
$comment = new Comment(); | ||
$comment->setTextfree('This is [email protected] in the middle of a text. And another one at the end. [email protected]'); | ||
|
||
$emailAddressFound = $this->commentModel->checkForEmailAddress($comment); | ||
|
||
$this->assertTrue($emailAddressFound); | ||
} | ||
|
||
public function testCommentWithoutEmailAddressInTextIsRecognized() | ||
{ | ||
$comment = new Comment(); | ||
$comment->setTextfree('This is an @instagram username.'); | ||
|
||
$emailAddressFound = $this->commentModel->checkForEmailAddress($comment); | ||
|
||
$this->assertFalse($emailAddressFound); | ||
} | ||
|
||
private function buildRelations(array $relations): string | ||
{ | ||
return implode(',', $relations); | ||
|