Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
44 lines
1,020 B
PHP
44 lines
1,020 B
PHP
<?php
|
|
|
|
use MediaWiki\Request\FauxRequest;
|
|
|
|
/**
|
|
* @covers SpecialUserLogout
|
|
*/
|
|
class SpecialUserLogoutTest extends SpecialPageTestBase {
|
|
|
|
/**
|
|
* Returns a new instance of the special page under test.
|
|
*
|
|
* @return SpecialPage
|
|
*/
|
|
protected function newSpecialPage() {
|
|
return new SpecialUserLogout();
|
|
}
|
|
|
|
public function testUserLogoutComplete() {
|
|
$oldName = __METHOD__;
|
|
$user = new TestUser( $oldName );
|
|
|
|
$session = RequestContext::getMain()->getRequest()->getSession();
|
|
$fauxRequest = new FauxRequest(
|
|
[ 'wpEditToken' => $session->getToken( 'logoutToken' ) ],
|
|
/* $wasPosted= */ true,
|
|
$session
|
|
);
|
|
|
|
$oldNameInHook = null;
|
|
$this->setTemporaryHook(
|
|
'UserLogoutComplete',
|
|
static function ( $user, $injected_html, $oldName ) use ( &$oldNameInHook ) {
|
|
$oldNameInHook = $oldName;
|
|
}
|
|
);
|
|
$this->executeSpecialPage( '', $fauxRequest, 'qqx', $user->getUser() );
|
|
$this->assertEquals(
|
|
$oldName,
|
|
$oldNameInHook,
|
|
'old name in UserLogoutComplete hook was incorrect'
|
|
);
|
|
}
|
|
}
|