resourceloader: Add test coverage for WikiModule::getType
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 13 Jul 2019 18:32:17 +0000 (19:32 +0100)
committerCatrope <roan@wikimedia.org>
Mon, 15 Jul 2019 22:39:43 +0000 (22:39 +0000)
Change-Id: If004cc4ff3835091c01a4df84006be3f6fa173b2

tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php

index 6ac0377..5964915 100644 (file)
@@ -92,6 +92,33 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                yield 'some group' => [ [ 'group' => 'foobar' ], 'foobar' ];
        }
 
+       /**
+        * @dataProvider provideGetType
+        */
+       public function testGetType( $params, $expected ) {
+               $module = new ResourceLoaderWikiModule( $params );
+               $this->assertSame( $expected, $module->getType() );
+       }
+
+       public static function provideGetType() {
+               yield 'empty' => [
+                       [],
+                       ResourceLoaderWikiModule::LOAD_GENERAL,
+               ];
+               yield 'scripts' => [
+                       [ 'scripts' => [ 'Example.js' ] ],
+                       ResourceLoaderWikiModule::LOAD_GENERAL,
+               ];
+               yield 'styles' => [
+                       [ 'styles' => [ 'Example.css' ] ],
+                       ResourceLoaderWikiModule::LOAD_STYLES,
+               ];
+               yield 'styles and scripts' => [
+                       [ 'styles' => [ 'Example.css' ], 'scripts' => [ 'Example.js' ] ],
+                       ResourceLoaderWikiModule::LOAD_GENERAL,
+               ];
+       }
+
        /**
         * @dataProvider provideIsKnownEmpty
         */