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