From: Kunal Mehta Date: Wed, 20 Aug 2014 07:26:50 +0000 (-0700) Subject: Add more tests for SkinFactory X-Git-Tag: 1.31.0-rc.0~14334^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=d9d0289b6c3c634251d35c83183e428d12b74d46;p=lhc%2Fweb%2Fwiklou.git Add more tests for SkinFactory Change-Id: I0a8f93abe597d6b2393f1c813e7bf76093f3ec89 --- diff --git a/tests/phpunit/includes/skins/SkinFactoryTest.php b/tests/phpunit/includes/skins/SkinFactoryTest.php index 7b7c7f86ea..36c56a9bb2 100644 --- a/tests/phpunit/includes/skins/SkinFactoryTest.php +++ b/tests/phpunit/includes/skins/SkinFactoryTest.php @@ -35,4 +35,34 @@ class SkinFactoryTest extends MediaWikiTestCase { $this->setExpectedException( 'UnexpectedValueException' ); $factory->makeSkin( 'unittest' ); } + + /** + * @covers SkinFactory::makeSkin + */ + public function testMakeSkinWithValidCallback() { + $factory = new SkinFactory(); + $factory->register( 'testfallback', 'TestFallback', function () { + return new SkinFallback(); + } ); + + $skin = $factory->makeSkin( 'testfallback' ); + $this->assertInstanceOf( 'Skin', $skin ); + $this->assertInstanceOf( 'SkinFallback', $skin ); + } + + /** + * @covers SkinFactory::getSkinNames + */ + public function testGetSkinNames() { + $factory = new SkinFactory(); + // A fake callback we can use that will never be called + $callback = function() {}; + $factory->register( 'skin1', 'Skin1', $callback ); + $factory->register( 'skin2', 'Skin2', $callback ); + $names = $factory->getSkinNames(); + $this->assertArrayHasKey( 'skin1', $names ); + $this->assertArrayHasKey( 'skin2', $names ); + $this->assertEquals( 'Skin1', $names['skin1'] ); + $this->assertEquals( 'Skin2', $names['skin2'] ); + } }