Debian Codegraph @

extensions/Thanks/tests/phpunit/integration/ThanksSpecialLogTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Thanks\Tests\Integration;
4
5 use MediaWiki\Request\FauxRequest;
6 use MediaWiki\Specials\SpecialLog;
7 use SpecialPageTestBase;
8
9 /**
10 * @covers \MediaWiki\Extension\Thanks\Hooks
11 * @group Database
12 */
13 class ThanksSpecialLogTest extends SpecialPageTestBase {
14
15 public function testDoNotShowThanksLinkToTempUsersOnSpecialLog() {
16 // Create a logged event that can be thanked.
17 $this->editPage( 'Test', 'Foo', '', NS_MAIN, $this->getMutableTestUser()->getUser() );
18 $tempUser = $this->getServiceContainer()->getTempUserCreator()->create(
19 '~2024-1', new FauxRequest()
20 )->getUser();
21 // Load Special:Log as a temp user, check that the thanks link doesn't appear.
22 [ $html ] = $this->executeSpecialPage(
23 '',
24 new FauxRequest(),
25 null,
26 $tempUser
27 );
28 $this->assertStringNotContainsString( 'mw-thanks-thank-link', $html );
29 // Load Special:Log as an anon user, check that the thanks link doesn't appear.
30 [ $html ] = $this->executeSpecialPage();
31 $this->assertStringNotContainsString( 'mw-thanks-thank-link', $html );
32 // Load Special:Log as a named user, check that the thanks link does appear.
33 [ $html ] = $this->executeSpecialPage(
34 '',
35 new FauxRequest(),
36 null,
37 $this->getMutableTestUser()->getUser()
38 );
39 $this->assertStringContainsString( 'mw-thanks-thank-link', $html );
40 }
41
42 protected function newSpecialPage() {
43 $services = $this->getServiceContainer();
44 return new SpecialLog(
45 $services->getLinkBatchFactory(),
46 $services->getConnectionProvider(),
47 $services->getActorNormalization(),
48 $services->getUserIdentityLookup(),
49 $services->getUserNameUtils(),
50 $services->getLogFormatterFactory()
51 );
52 }
53 }