Merge "Drop cache interwiki"
[mediawiki.git] / tests / phpunit / includes / specials / SpecialLogTest.php
blob3986f7a2103b66f5d574ed003286b38ebfeefe7b
1 <?php
2 /**
3 * @license GPL-2.0-or-later
4 * @author Legoktm
5 */
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;
14 /**
15 * @group Database
16 * @covers \MediaWiki\Specials\SpecialLog
18 class SpecialLogTest extends SpecialPageTestBase {
20 /**
21 * Returns a new instance of the special page under test.
23 * @return SpecialPage
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()
37 /**
38 * Verify that no exception was thrown for an invalid date
39 * @see T201411
41 public function testInvalidDate() {
42 [ $html, ] = $this->executeSpecialPage(
43 '',
44 // There is no 13th month
45 new FauxRequest( [ 'wpdate' => '2018-13-01' ] ),
46 'qqx'
48 $this->assertStringContainsString( '(log-summary)', $html );
51 public function testSuppressionLog() {
52 // Have "BadGuy" create a revision
53 $user = ( new TestUser( 'BadGuy' ) )->getUser();
54 $title = $this->insertPage( 'Foo', 'Bar', null, $user )['title'];
55 $revId = $title->getLatestRevID();
57 $context = new DerivativeContext( RequestContext::getMain() );
58 $context->setUser( $this->getTestUser( [ 'sysop', 'suppress' ] )->getUser() );
59 // Hide our revision's comment
60 $list = RevisionDeleter::createList( 'revision', $context, $title, [ $revId ] );
61 $status = $list->setVisibility( [
62 'value' => [
63 RevisionRecord::DELETED_RESTRICTED => 1,
64 RevisionRecord::DELETED_COMMENT => 1
66 'comment' => 'SpecialLogTest'
67 ] );
68 $this->assertStatusGood( $status );
70 // Allow everyone to read the suppression log
71 $this->mergeMwGlobalArrayValue(
72 'wgGroupPermissions', [
73 '*' => [
74 'suppressionlog' => true
79 [ $html, ] = $this->executeSpecialPage(
80 'suppress',
81 new FauxRequest( [ 'offender' => 'BadGuy' ] ),
82 'qqx'
84 $this->assertStringNotContainsString( '(logempty)', $html );
85 $this->assertStringContainsString( '(logentry-suppress-revision', $html );
87 // Full suppression log
88 [ $html, ] = $this->executeSpecialPage(
89 'suppress',
90 new FauxRequest(),
91 'qqx'
93 $this->assertStringNotContainsString( '(logempty)', $html );
94 $this->assertStringContainsString( '(logentry-suppress-revision', $html );
96 // Suppression log for unknown user should be empty
97 [ $html, ] = $this->executeSpecialPage(
98 'suppress',
99 new FauxRequest( [ 'offender' => 'GoodGuy' ] ),
100 'qqx'
102 $this->assertStringContainsString( '(logempty)', $html );
103 $this->assertStringNotContainsString( '(logentry-suppress-revision', $html );