mediawiki-extensions-Nuke/tests/phpunit/SpecialNukeTest.php
Bartosz Dziewoński 80bdcd3004 Restore support for matching 'LIKE' patterns/wildcards
Follow-up to 910ce4c870.

Add a test so that we don't break this again.

Bug: T355478
Change-Id: I98620dd66a3c3a6913f999d6f96eef0ef69271d1
2024-01-22 11:30:50 +00:00

52 lines
1.5 KiB
PHP

<?php
namespace MediaWiki\Extension\Nuke\Tests;
use MediaWiki\Extension\Nuke\SpecialNuke;
use MediaWiki\Permissions\UltimateAuthority;
use MediaWiki\Request\FauxRequest;
use SpecialPageTestBase;
/**
* @group Database
* @covers \MediaWiki\Extension\Nuke\SpecialNuke
*/
class SpecialNukeTest extends SpecialPageTestBase {
protected function newSpecialPage(): SpecialNuke {
$services = $this->getServiceContainer();
return new SpecialNuke(
$services->getJobQueueGroup(),
$services->getDBLoadBalancerFactory(),
$services->getPermissionManager(),
$services->getRepoGroup(),
$services->getUserFactory(),
$services->getUserNamePrefixSearch(),
$services->getUserNameUtils()
);
}
public function testExecutePattern() {
// Test that matching wildcards works, and that escaping wildcards works as documented
// at https://www.mediawiki.org/wiki/Help:Extension:Nuke
$this->editPage( '%PositiveNukeTest123', 'test' );
$this->editPage( 'NegativeNukeTest123', 'test' );
$user = $this->getTestSysop()->getUser();
$request = new FauxRequest( [
'action' => 'submit',
'pattern' => '\\%PositiveNukeTest%',
'wpFormIdentifier' => 'massdelete',
'wpEditToken' => $user->getEditToken(),
], true );
$performer = new UltimateAuthority( $user );
[ $html ] = $this->executeSpecialPage( '', $request, 'qqx', $performer );
$this->assertStringContainsString( 'PositiveNukeTest123', $html );
$this->assertStringNotContainsString( 'NegativeNukeTest123', $html );
}
}