From acaaa89c5ee777d4ef8dc2b4f250572fde0fa4dd Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 28 Jul 2022 20:55:30 -0700 Subject: [PATCH] phpunit: Fix context leak in SkinVectorTest There are two issues with context in this test case: 1. The $vectorTemplate object was not given the $context object. Calling setContext() is the same as MediaWiki would normally do after calling SkinFactory, e.g. as in RequestContext::getSkin. 2. The "main" glboal state was leaking into the test by mutating the result of getMain() instead of creating your own for use in the test. Change-Id: I09eb8c3a38c0d4e2c85461b61e6f14ab00995016 --- tests/phpunit/integration/SkinVectorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/SkinVectorTest.php b/tests/phpunit/integration/SkinVectorTest.php index ab5730a4..dac21909 100644 --- a/tests/phpunit/integration/SkinVectorTest.php +++ b/tests/phpunit/integration/SkinVectorTest.php @@ -198,10 +198,10 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase { */ public function testGetTemplateData() { $title = Title::newFromText( 'SkinVector' ); - $context = RequestContext::getMain(); - $context->setTitle( $title ); + $context = RequestContext::newExtraneousContext( $title ); $context->setLanguage( 'fr' ); $vectorTemplate = $this->provideVectorTemplateObject(); + $vectorTemplate->setContext( $context ); $this->setTemporaryHook( 'PersonalUrls', [ static function ( &$personal_urls, &$title, $skin ) { $personal_urls = [