From: jenkins-bot Date: Thu, 12 Oct 2017 21:55:35 +0000 (+0000) Subject: Merge "Skin: Make skins aware of their registered skin name" X-Git-Tag: 1.31.0-rc.0~1793 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=a8379682a46a428320c88702c800a6107c015137;hp=f2b87a9db52043747b6ecc56dd10f261fe604110 Merge "Skin: Make skins aware of their registered skin name" --- diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 167b49d9f3..07964a4d55 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -34,7 +34,11 @@ use MediaWiki\MediaWikiServices; * @ingroup Skins */ abstract class Skin extends ContextSource { + /** + * @var string|null + */ protected $skinname = null; + protected $mRelevantTitle = null; protected $mRelevantUser = null; @@ -134,7 +138,17 @@ abstract class Skin extends ContextSource { } /** - * @return string Skin name + * @since 1.31 + * @param string|null $skinname + */ + public function __construct( $skinname = null ) { + if ( is_string( $skinname ) ) { + $this->skinname = $skinname; + } + } + + /** + * @return string|null Skin name */ public function getSkinName() { return $this->skinname; diff --git a/tests/phpunit/includes/skins/SkinFactoryTest.php b/tests/phpunit/includes/skins/SkinFactoryTest.php index d3663c84ad..a8b9fd1ba0 100644 --- a/tests/phpunit/includes/skins/SkinFactoryTest.php +++ b/tests/phpunit/includes/skins/SkinFactoryTest.php @@ -48,6 +48,18 @@ class SkinFactoryTest extends MediaWikiTestCase { $skin = $factory->makeSkin( 'testfallback' ); $this->assertInstanceOf( 'Skin', $skin ); $this->assertInstanceOf( 'SkinFallback', $skin ); + $this->assertEquals( 'fallback', $skin->getSkinName() ); + } + + /** + * @covers Skin::__constructor + * @covers Skin::getSkinName + */ + public function testGetSkinName() { + $skin = new SkinFallback(); + $this->assertEquals( 'fallback', $skin->getSkinName(), 'Default' ); + $skin = new SkinFallback( 'testname' ); + $this->assertEquals( 'testname', $skin->getSkinName(), 'Constructor argument' ); } /**