| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\EditPage\SpamChecker; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class SpamCheckerTest extends MediaWikiUnitTestCase { |
| 11 |
|
| 12 |
public function testNoMatches() { |
| 13 |
$checker = new SpamChecker( [], [] ); |
| 14 |
$this->assertFalse( |
| 15 |
$checker->checkContent( 'spam content goes here' ) |
| 16 |
); |
| 17 |
$this->assertFalse( |
| 18 |
$checker->checkSummary( 'spam summary goes here' ) |
| 19 |
); |
| 20 |
} |
| 21 |
|
| 22 |
public function testMatchContent() { |
| 23 |
$checker = new SpamChecker( [ '/spam\s*content/' ], [] ); |
| 24 |
$this->assertSame( |
| 25 |
'spam content', |
| 26 |
$checker->checkContent( 'spam content goes here' ) |
| 27 |
); |
| 28 |
$this->assertFalse( |
| 29 |
$checker->checkSummary( 'spam summary goes here' ) |
| 30 |
); |
| 31 |
} |
| 32 |
|
| 33 |
public function testMatchSummary() { |
| 34 |
$checker = new SpamChecker( [], [ '/spam\s*summary/' ] ); |
| 35 |
$this->assertFalse( |
| 36 |
$checker->checkContent( 'spam content goes here' ) |
| 37 |
); |
| 38 |
$this->assertSame( |
| 39 |
'spam summary', |
| 40 |
$checker->checkSummary( 'spam summary goes here' ) |
| 41 |
); |
| 42 |
} |
| 43 |
} |