Merge "resourceloader: Wrap only=script responses in "if(window.mw)""
[lhc/web/wiklou.git] / tests / phpunit / includes / skins / SkinFactoryTest.php
1 <?php
2
3 class SkinFactoryTest extends MediaWikiTestCase {
4
5 /**
6 * @covers SkinFactory::register
7 */
8 public function testRegister() {
9 $factory = new SkinFactory();
10 $factory->register( 'fallback', 'Fallback', function() {
11 return new SkinFallback();
12 } );
13 $this->assertTrue( true ); // No exception thrown
14 $this->setExpectedException( 'InvalidArgumentException' );
15 $factory->register( 'invalid', 'Invalid', 'Invalid callback' );
16 }
17
18 /**
19 * @covers SkinFactory::makeSkin
20 */
21 public function testMakeSkinWithNoBuilders() {
22 $factory = new SkinFactory();
23 $this->setExpectedException( 'SkinException' );
24 $factory->makeSkin( 'nobuilderregistered' );
25 }
26
27 /**
28 * @covers SkinFactory::makeSkin
29 */
30 public function testMakeSkinWithInvalidCallback() {
31 $factory = new SkinFactory();
32 $factory->register( 'unittest', 'Unittest', function () {
33 return true; // Not a Skin object
34 } );
35 $this->setExpectedException( 'UnexpectedValueException' );
36 $factory->makeSkin( 'unittest' );
37 }
38 }