Don't use stashMwGlobals()

Being deprecated in I23d77398e4.

Change-Id: I9315111c86599472887c616658ac25ba7979d340
This commit is contained in:
Kunal Mehta 2018-10-07 22:02:48 -07:00
parent e8676a2bdd
commit da954dd045

View file

@ -92,27 +92,26 @@ class TemplateStylesContentTest extends TextContentTest {
}
public function testCrazyBrokenSanitizer() {
global $wgHooks;
$this->stashMwGlobals( 'wgHooks' );
// Big hack: Make a Token that returns a bad string, and a Sanitizer
// that returns that bad Token, just so we can test a code path that
// handles such bad output.
$wgHooks['TemplateStylesStylesheetSanitizer'][] = function ( &$sanitizer ) {
$badToken = $this->getMockBuilder( Wikimedia\CSS\Objects\Token::class )
->disableOriginalConstructor()
->setMethods( [ '__toString' ] )
->getMock();
$badToken->method( '__toString' )->willReturn( '"</style>"' );
$this->setTemporaryHook(
'TemplateStylesStylesheetSanitizer',
function ( &$sanitizer ) {
$badToken = $this->getMockBuilder( Wikimedia\CSS\Objects\Token::class )
->disableOriginalConstructor()
->setMethods( [ '__toString' ] )
->getMock();
$badToken->method( '__toString' )->willReturn( '"</style>"' );
$sanitizer = $this->getMockBuilder( Wikimedia\CSS\Sanitizer\StylesheetSanitizer::class )
->disableOriginalConstructor()
->setMethods( [ 'sanitize' ] )
->getMock();
$sanitizer->method( 'sanitize' )->willReturn( $badToken );
return false;
};
$sanitizer = $this->getMockBuilder( Wikimedia\CSS\Sanitizer\StylesheetSanitizer::class )
->disableOriginalConstructor()
->setMethods( [ 'sanitize' ] )
->getMock();
$sanitizer->method( 'sanitize' )->willReturn( $badToken );
return false;
}
);
$this->assertEquals(
Status::newFatal( 'templatestyles-end-tag-injection' ),