| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
use MediaWiki\Context\DerivativeContext; |
| 8 |
use MediaWiki\Context\RequestContext; |
| 9 |
use MediaWiki\Request\FauxRequest; |
| 10 |
use MediaWiki\Revision\RevisionRecord; |
| 11 |
use MediaWiki\SpecialPage\SpecialPage; |
| 12 |
use MediaWiki\Specials\SpecialLog; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
class SpecialLogTest extends SpecialPageTestBase { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
protected function newSpecialPage() { |
| 26 |
$services = $this->getServiceContainer(); |
| 27 |
return new SpecialLog( |
| 28 |
$services->getLinkBatchFactory(), |
| 29 |
$services->getConnectionProvider(), |
| 30 |
$services->getActorNormalization(), |
| 31 |
$services->getUserIdentityLookup(), |
| 32 |
$services->getUserNameUtils(), |
| 33 |
$services->getLogFormatterFactory() |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public function testInvalidDate() { |
| 42 |
[ $html, ] = $this->executeSpecialPage( |
| 43 |
'', |
| 44 |
|
| 45 |
new FauxRequest( [ 'wpdate' => '2018-13-01' ] ), |
| 46 |
'qqx' |
| 47 |
); |
| 48 |
$this->assertStringContainsString( '(log-summary)', $html ); |
| 49 |
} |
| 50 |
|
| 51 |
public function testSuppressionLog() { |
| 52 |
|
| 53 |
$user = ( new TestUser( 'BadGuy' ) )->getUser(); |
| 54 |
$title = $this->insertPage( 'Foo', 'Bar', null, $user )['title']; |
| 55 |
$revId = $title->getLatestRevID(); |
| 56 |
|
| 57 |
$context = new DerivativeContext( RequestContext::getMain() ); |
| 58 |
$context->setUser( $this->getTestUser( [ 'sysop', 'suppress' ] )->getUser() ); |
| 59 |
|
| 60 |
$list = RevisionDeleter::createList( 'revision', $context, $title, [ $revId ] ); |
| 61 |
$status = $list->setVisibility( [ |
| 62 |
'value' => [ |
| 63 |
RevisionRecord::DELETED_RESTRICTED => 1, |
| 64 |
RevisionRecord::DELETED_COMMENT => 1 |
| 65 |
], |
| 66 |
'comment' => 'SpecialLogTest' |
| 67 |
] ); |
| 68 |
$this->assertStatusGood( $status ); |
| 69 |
|
| 70 |
|
| 71 |
$this->mergeMwGlobalArrayValue( |
| 72 |
'wgGroupPermissions', [ |
| 73 |
'*' => [ |
| 74 |
'suppressionlog' => true |
| 75 |
] |
| 76 |
] |
| 77 |
); |
| 78 |
|
| 79 |
[ $html, ] = $this->executeSpecialPage( |
| 80 |
'suppress', |
| 81 |
new FauxRequest( [ 'offender' => 'BadGuy' ] ), |
| 82 |
'qqx' |
| 83 |
); |
| 84 |
$this->assertStringNotContainsString( '(logempty)', $html ); |
| 85 |
$this->assertStringContainsString( '(logentry-suppress-revision', $html ); |
| 86 |
|
| 87 |
|
| 88 |
[ $html, ] = $this->executeSpecialPage( |
| 89 |
'suppress', |
| 90 |
new FauxRequest(), |
| 91 |
'qqx' |
| 92 |
); |
| 93 |
$this->assertStringNotContainsString( '(logempty)', $html ); |
| 94 |
$this->assertStringContainsString( '(logentry-suppress-revision', $html ); |
| 95 |
|
| 96 |
|
| 97 |
[ $html, ] = $this->executeSpecialPage( |
| 98 |
'suppress', |
| 99 |
new FauxRequest( [ 'offender' => 'GoodGuy' ] ), |
| 100 |
'qqx' |
| 101 |
); |
| 102 |
$this->assertStringContainsString( '(logempty)', $html ); |
| 103 |
$this->assertStringNotContainsString( '(logentry-suppress-revision', $html ); |
| 104 |
} |
| 105 |
|
| 106 |
} |