mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateStyles
synced 2024-11-30 19:15:07 +00:00
Don't use stashMwGlobals()
Being deprecated in I23d77398e4. Change-Id: I9315111c86599472887c616658ac25ba7979d340
This commit is contained in:
parent
e8676a2bdd
commit
da954dd045
|
@ -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' ),
|
||||
|
|
Loading…
Reference in a new issue