From c83e2445b86744bebd9304e9ba8e67a455d230a5 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 19 Aug 2018 01:42:58 +0100 Subject: [PATCH] CSP: In tests, use setMwGlobals() instead of manual set+undo This is the idiom as used in other PHPUnit tests for MediaWiki. Change-Id: I285e5abe57bad8b9a8a3b35d81bb3a9f5f3dbe85 --- tests/phpunit/includes/ContentSecurityPolicyTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/includes/ContentSecurityPolicyTest.php b/tests/phpunit/includes/ContentSecurityPolicyTest.php index 250d49d720..5f0200d09d 100644 --- a/tests/phpunit/includes/ContentSecurityPolicyTest.php +++ b/tests/phpunit/includes/ContentSecurityPolicyTest.php @@ -273,13 +273,9 @@ class ContentSecurityPolicyTest extends MediaWikiTestCase { * @covers ContentSecurityPolicy::isNonceRequired */ public function testCSPIsEnabled( $main, $reportOnly, $expected ) { - global $wgCSPReportOnlyHeader, $wgCSPHeader; - global $wgCSPHeader; - $oldReport = wfSetVar( $wgCSPReportOnlyHeader, $reportOnly ); - $oldMain = wfSetVar( $wgCSPHeader, $main ); + $this->setMwGlobals( 'wgCSPReportOnlyHeader', $reportOnly ); + $this->setMwGlobals( 'wgCSPHeader', $main ); $res = ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ); - wfSetVar( $wgCSPReportOnlyHeader, $oldReport ); - wfSetVar( $wgCSPHeader, $oldMain ); $this->assertEquals( $res, $expected ); } -- 2.20.1