mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-12-20 10:20:51 +00:00
f2220b151e
Why: * Temp accounts cannot thank other users, so do not add the "thank" link in log entries. What: * Change condition to check if a user is not named, rather than if they are anonymous * Add an integration test to verify the behavior for anon, temp, and named users Bug: T375209 Change-Id: Idb772a3072a6dc8a9d052cebb306b558f49caf31
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Thanks\Tests\Integration;
|
|
|
|
use MediaWiki\Request\FauxRequest;
|
|
use MediaWiki\Specials\SpecialLog;
|
|
use SpecialPageTestBase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Thanks\Hooks
|
|
* @group Database
|
|
*/
|
|
class ThanksSpecialLogTest extends SpecialPageTestBase {
|
|
|
|
public function testDoNotShowThanksLinkToTempUsersOnSpecialLog() {
|
|
// Create a logged event that can be thanked.
|
|
$this->editPage( 'Test', 'Foo', '', NS_MAIN, $this->getMutableTestUser()->getUser() );
|
|
$tempUser = $this->getServiceContainer()->getTempUserCreator()->create(
|
|
'~2024-1', new FauxRequest()
|
|
)->getUser();
|
|
// Load Special:Log as a temp user, check that the thanks link doesn't appear.
|
|
[ $html ] = $this->executeSpecialPage(
|
|
'',
|
|
new FauxRequest(),
|
|
null,
|
|
$tempUser
|
|
);
|
|
$this->assertStringNotContainsString( 'mw-thanks-thank-link', $html );
|
|
// Load Special:Log as an anon user, check that the thanks link doesn't appear.
|
|
[ $html ] = $this->executeSpecialPage();
|
|
$this->assertStringNotContainsString( 'mw-thanks-thank-link', $html );
|
|
// Load Special:Log as a named user, check that the thanks link does appear.
|
|
[ $html ] = $this->executeSpecialPage(
|
|
'',
|
|
new FauxRequest(),
|
|
null,
|
|
$this->getMutableTestUser()->getUser()
|
|
);
|
|
$this->assertStringContainsString( 'mw-thanks-thank-link', $html );
|
|
}
|
|
|
|
protected function newSpecialPage() {
|
|
$services = $this->getServiceContainer();
|
|
return new SpecialLog(
|
|
$services->getLinkBatchFactory(),
|
|
$services->getConnectionProvider(),
|
|
$services->getActorNormalization(),
|
|
$services->getUserIdentityLookup(),
|
|
$services->getUserNameUtils(),
|
|
$services->getLogFormatterFactory()
|
|
);
|
|
}
|
|
}
|