wiki.techinc.nl/tests/phpunit/includes/specials/SpecialEditWatchlistTest.php
Umherirrender 3f35092448 Inject services into SpecialWatchlist/SpecialEditWatchlist
This covers only directly used services by this special page
Services used by the base class are not part of this patch set

Bug: T259960
Change-Id: I4baff83b8c7bb5bd1f5b00369bfc3cec70c2391a
2020-11-23 21:38:55 +00:00

60 lines
1.5 KiB
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* @author Addshore
*
* @group Database
*
* @covers SpecialEditWatchlist
*/
class SpecialEditWatchlistTest extends SpecialPageTestBase {
/**
* Returns a new instance of the special page under test.
*
* @return SpecialPage
*/
protected function newSpecialPage() {
$services = MediaWikiServices::getInstance();
return new SpecialEditWatchlist(
$services->getWatchedItemStore(),
$services->getTitleParser(),
$services->getGenderCache(),
$services->getLinkBatchFactory(),
$services->getNamespaceInfo(),
$services->getWikiPageFactory()
);
}
public function testNotLoggedIn_throwsException() {
$this->expectException( UserNotLoggedIn::class );
$this->executeSpecialPage();
}
public function testRootPage_displaysExplanationMessage() {
$user = new TestUser( __METHOD__ );
list( $html, ) = $this->executeSpecialPage( '', null, 'qqx', $user->getUser() );
$this->assertStringContainsString( '(watchlistedit-normal-explain)', $html );
}
public function testClearPage_hasClearButtonForm() {
$user = new TestUser( __METHOD__ );
list( $html, ) = $this->executeSpecialPage( 'clear', null, 'qqx', $user->getUser() );
$this->assertRegExp(
'/<form action=\'.*?Special:EditWatchlist\/clear\'/',
$html
);
}
public function testEditRawPage_hasTitlesBox() {
$user = new TestUser( __METHOD__ );
list( $html, ) = $this->executeSpecialPage( 'raw', null, 'qqx', $user->getUser() );
$this->assertStringContainsString(
'<div id=\'mw-input-wpTitles\'',
$html
);
}
}