From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- .../ResourceLoaderFileModuleTest.php | 247 +++++++++++++ .../ResourceLoaderImageModuleTest.php | 162 +++++++++ .../resourceloader/ResourceLoaderImageTest.php | 122 +++++++ .../resourceloader/ResourceLoaderModuleTest.php | 61 +--- .../ResourceLoaderStartUpModuleTest.php | 388 +++++++++++++++++++++ .../ResourceLoaderStartupModuleTest.php | 388 --------------------- .../includes/resourceloader/ResourceLoaderTest.php | 185 +++++++--- .../ResourceLoaderWikiModuleTest.php | 84 ++++- .../resourceloader/templates/template.html | 1 + .../resourceloader/templates/template2.html | 1 + .../templates/template_awesome.handlebars | 1 + 11 files changed, 1133 insertions(+), 507 deletions(-) create mode 100644 tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php create mode 100644 tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php create mode 100644 tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php create mode 100644 tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php delete mode 100644 tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php create mode 100644 tests/phpunit/includes/resourceloader/templates/template.html create mode 100644 tests/phpunit/includes/resourceloader/templates/template2.html create mode 100644 tests/phpunit/includes/resourceloader/templates/template_awesome.handlebars (limited to 'tests/phpunit/includes/resourceloader') diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php new file mode 100644 index 00000000..122995a5 --- /dev/null +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -0,0 +1,247 @@ +register( + 'fakeskin', + 'FakeSkin', + function () { + } + ); + } + + private static function getModules() { + $base = array( + 'localBasePath' => realpath( dirname( __FILE__ ) ), + ); + + return array( + 'noTemplateModule' => array(), + + 'htmlTemplateModule' => $base + array( + 'templates' => array( + 'templates/template.html', + 'templates/template2.html', + ) + ), + + 'aliasedHtmlTemplateModule' => $base + array( + 'templates' => array( + 'foo.html' => 'templates/template.html', + 'bar.html' => 'templates/template2.html', + ) + ), + + 'templateModuleHandlebars' => $base + array( + 'templates' => array( + 'templates/template_awesome.handlebars', + ), + ), + + 'aliasFooFromBar' => $base + array( + 'templates' => array( + 'foo.foo' => 'templates/template.bar', + ), + ), + ); + } + + public static function providerTemplateDependencies() { + $modules = self::getModules(); + + return array( + array( + $modules['noTemplateModule'], + array(), + ), + array( + $modules['htmlTemplateModule'], + array( + 'mediawiki.template', + ), + ), + array( + $modules['templateModuleHandlebars'], + array( + 'mediawiki.template', + 'mediawiki.template.handlebars', + ), + ), + array( + $modules['aliasFooFromBar'], + array( + 'mediawiki.template', + 'mediawiki.template.foo', + ), + ), + ); + } + + /** + * @dataProvider providerTemplateDependencies + * @covers ResourceLoaderFileModule::__construct + * @covers ResourceLoaderFileModule::getDependencies + */ + public function testTemplateDependencies( $module, $expected ) { + $rl = new ResourceLoaderFileModule( $module ); + $this->assertEquals( $rl->getDependencies(), $expected ); + } + + /** + * @covers ResourceLoaderFileModule::getAllStyleFiles + * @covers ResourceLoaderFileModule::getAllSkinStyleFiles + * @covers ResourceLoaderFileModule::getSkinStyleFiles + */ + public function testGetAllSkinStyleFiles() { + $baseParams = array( + 'scripts' => array( + 'foo.js', + 'bar.js', + ), + 'styles' => array( + 'foo.css', + 'bar.css' => array( 'media' => 'print' ), + 'screen.less' => array( 'media' => 'screen' ), + 'screen-query.css' => array( 'media' => 'screen and (min-width: 400px)' ), + ), + 'skinStyles' => array( + 'default' => 'quux-fallback.less', + 'fakeskin' => array( + 'baz-vector.css', + 'quux-vector.less', + ), + ), + 'messages' => array( + 'hello', + 'world', + ), + ); + + $module = new ResourceLoaderFileModule( $baseParams ); + + $this->assertEquals( + array( + 'foo.css', + 'baz-vector.css', + 'quux-vector.less', + 'quux-fallback.less', + 'bar.css', + 'screen.less', + 'screen-query.css', + ), + array_map( 'basename', $module->getAllStyleFiles() ) + ); + } + + /** + * Strip @noflip annotations from CSS code. + * @param string $css + * @return string + */ + private static function stripNoflip( $css ) { + return str_replace( '/*@noflip*/ ', '', $css ); + } + + /** + * What happens when you mix @embed and @noflip? + * This really is an integration test, but oh well. + * + * @covers ResourceLoaderFileModule::getStyles + * @covers ResourceLoaderFileModule::getStyleFiles + */ + public function testMixedCssAnnotations( ) { + $basePath = __DIR__ . '/../../data/css'; + $testModule = new ResourceLoaderFileModule( array( + 'localBasePath' => $basePath, + 'styles' => array( 'test.css' ), + ) ); + $expectedModule = new ResourceLoaderFileModule( array( + 'localBasePath' => $basePath, + 'styles' => array( 'expected.css' ), + ) ); + + $contextLtr = $this->getResourceLoaderContext( 'en', 'ltr' ); + $contextRtl = $this->getResourceLoaderContext( 'he', 'rtl' ); + + // Since we want to compare the effect of @noflip+@embed against the effect of just @embed, and + // the @noflip annotations are always preserved, we need to strip them first. + $this->assertEquals( + $expectedModule->getStyles( $contextLtr ), + self::stripNoflip( $testModule->getStyles( $contextLtr ) ), + "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode" + ); + $this->assertEquals( + $expectedModule->getStyles( $contextLtr ), + self::stripNoflip( $testModule->getStyles( $contextRtl ) ), + "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode" + ); + } + + public static function providerGetTemplates() { + $modules = self::getModules(); + + return array( + array( + $modules['noTemplateModule'], + array(), + ), + array( + $modules['templateModuleHandlebars'], + array( + 'templates/template_awesome.handlebars' => "wow\n", + ), + ), + array( + $modules['htmlTemplateModule'], + array( + 'templates/template.html' => "hello\n", + 'templates/template2.html' => "
goodbye
\n", + ), + ), + array( + $modules['aliasedHtmlTemplateModule'], + array( + 'foo.html' => "hello\n", + 'bar.html' => "
goodbye
\n", + ), + ), + ); + } + + /** + * @dataProvider providerGetTemplates + * @covers ResourceLoaderFileModule::getTemplates + */ + public function testGetTemplates( $module, $expected ) { + $rl = new ResourceLoaderFileModule( $module ); + + $this->assertEquals( $rl->getTemplates(), $expected ); + } + + public static function providerGetModifiedTime() { + $modules = self::getModules(); + + return array( + // Check the default value when no templates present in module is 1 + array( $modules['noTemplateModule'], 1 ), + ); + } + + /** + * @dataProvider providerGetModifiedTime + * @covers ResourceLoaderFileModule::getModifiedTime + */ + public function testGetModifiedTime( $module, $expected ) { + $rl = new ResourceLoaderFileModule( $module ); + $ts = $rl->getModifiedTime( $this->getResourceLoaderContext() ); + $this->assertEquals( $ts, $expected ); + } +} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php new file mode 100644 index 00000000..d0bc210b --- /dev/null +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php @@ -0,0 +1,162 @@ + 'add.gif', + 'remove' => array( + 'file' => 'remove.svg', + 'variants' => array( 'destructive' ), + ), + 'next' => array( + 'file' => array( + 'ltr' => 'next.svg', + 'rtl' => 'prev.svg' + ), + ), + 'help' => array( + 'file' => array( + 'ltr' => 'help-ltr.svg', + 'rtl' => 'help-rtl.svg', + 'lang' => array( + 'he' => 'help-ltr.svg', + ) + ), + ), + 'bold' => array( + 'file' => array( + 'default' => 'bold-a.svg', + 'lang' => array( + 'en' => 'bold-b.svg', + 'ar,de' => 'bold-f.svg', + ) + ), + ) + ); + + public static $commonImageVariants = array( + 'invert' => array( + 'color' => '#FFFFFF', + 'global' => true, + ), + 'primary' => array( + 'color' => '#598AD1', + ), + 'constructive' => array( + 'color' => '#00C697', + ), + 'destructive' => array( + 'color' => '#E81915', + ), + ); + + public static function providerGetModules() { + return array( + array( + array( + 'class' => 'ResourceLoaderImageModule', + 'prefix' => 'oo-ui-icon', + 'variants' => self::$commonImageVariants, + 'images' => self::$commonImageData, + ), + '.oo-ui-icon-add { + ... +} +.oo-ui-icon-add-invert { + ... +} +.oo-ui-icon-remove { + ... +} +.oo-ui-icon-remove-invert { + ... +} +.oo-ui-icon-remove-destructive { + ... +} +.oo-ui-icon-next { + ... +} +.oo-ui-icon-next-invert { + ... +} +.oo-ui-icon-help { + ... +} +.oo-ui-icon-help-invert { + ... +} +.oo-ui-icon-bold { + ... +} +.oo-ui-icon-bold-invert { + ... +}', + ), + array( + array( + 'class' => 'ResourceLoaderImageModule', + 'selectorWithoutVariant' => '.mw-ui-icon-{name}:after, .mw-ui-icon-{name}:before', + 'selectorWithVariant' => '.mw-ui-icon-{name}-{variant}:after, .mw-ui-icon-{name}-{variant}:before', + 'variants' => self::$commonImageVariants, + 'images' => self::$commonImageData, + ), + '.mw-ui-icon-add:after, .mw-ui-icon-add:before { + ... +} +.mw-ui-icon-add-invert:after, .mw-ui-icon-add-invert:before { + ... +} +.mw-ui-icon-remove:after, .mw-ui-icon-remove:before { + ... +} +.mw-ui-icon-remove-invert:after, .mw-ui-icon-remove-invert:before { + ... +} +.mw-ui-icon-remove-destructive:after, .mw-ui-icon-remove-destructive:before { + ... +} +.mw-ui-icon-next:after, .mw-ui-icon-next:before { + ... +} +.mw-ui-icon-next-invert:after, .mw-ui-icon-next-invert:before { + ... +} +.mw-ui-icon-help:after, .mw-ui-icon-help:before { + ... +} +.mw-ui-icon-help-invert:after, .mw-ui-icon-help-invert:before { + ... +} +.mw-ui-icon-bold:after, .mw-ui-icon-bold:before { + ... +} +.mw-ui-icon-bold-invert:after, .mw-ui-icon-bold-invert:before { + ... +}', + ), + ); + } + + /** + * @dataProvider providerGetModules + * @covers ResourceLoaderImageModule::getStyles + */ + public function testGetStyles( $module, $expected ) { + $module = new ResourceLoaderImageModuleTestable( $module, __DIR__ . '/../../data/resourceloader' ); + $styles = $module->getStyles( $this->getResourceLoaderContext() ); + $this->assertEquals( $expected, $styles['all'] ); + } +} + +class ResourceLoaderImageModuleTestable extends ResourceLoaderImageModule { + /** + * Replace with a stub to make test cases easier to write. + */ + protected function getCssDeclarations( $primary, $fallback ) { + return array( '...' ); + } +} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php new file mode 100644 index 00000000..758cfe19 --- /dev/null +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php @@ -0,0 +1,122 @@ +imagesPath = __DIR__ . '/../../data/resourceloader'; + } + + protected function getTestImage( $name ) { + $options = ResourceLoaderImageModuleTest::$commonImageData[$name]; + $fileDescriptor = is_string( $options ) ? $options : $options['file']; + $allowedVariants = is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : array(); + $variants = array_fill_keys( $allowedVariants, array( 'color' => 'red' ) ); + return new ResourceLoaderImageTestable( $name, 'test', $fileDescriptor, $this->imagesPath, $variants ); + } + + public static function provideGetPath() { + return array( + array( 'add', 'en', 'add.gif' ), + array( 'add', 'he', 'add.gif' ), + array( 'remove', 'en', 'remove.svg' ), + array( 'remove', 'he', 'remove.svg' ), + array( 'next', 'en', 'next.svg' ), + array( 'next', 'he', 'prev.svg' ), + array( 'help', 'en', 'help-ltr.svg' ), + array( 'help', 'ar', 'help-rtl.svg' ), + array( 'help', 'he', 'help-ltr.svg' ), + array( 'bold', 'en', 'bold-b.svg' ), + array( 'bold', 'de', 'bold-f.svg' ), + array( 'bold', 'ar', 'bold-f.svg' ), + array( 'bold', 'fr', 'bold-a.svg' ), + array( 'bold', 'he', 'bold-a.svg' ), + ); + } + + /** + * @covers ResourceLoaderImage::getPath + * @dataProvider provideGetPath + */ + public function testGetPath( $imageName, $languageCode, $path ) { + static $dirMap = array( + 'en' => 'ltr', + 'de' => 'ltr', + 'fr' => 'ltr', + 'he' => 'rtl', + 'ar' => 'rtl', + ); + static $contexts = array(); + + $image = $this->getTestImage( $imageName ); + $context = $this->getResourceLoaderContext( $languageCode, $dirMap[$languageCode] ); + + $this->assertEquals( $image->getPath( $context ), $this->imagesPath . '/' . $path ); + } + + /** + * @covers ResourceLoaderImage::getExtension + * @covers ResourceLoaderImage::getMimeType + */ + public function testGetExtension() { + $image = $this->getTestImage( 'remove' ); + $this->assertEquals( $image->getExtension(), 'svg' ); + $this->assertEquals( $image->getExtension( 'original' ), 'svg' ); + $this->assertEquals( $image->getExtension( 'rasterized' ), 'png' ); + $image = $this->getTestImage( 'add' ); + $this->assertEquals( $image->getExtension(), 'gif' ); + $this->assertEquals( $image->getExtension( 'original' ), 'gif' ); + $this->assertEquals( $image->getExtension( 'rasterized' ), 'gif' ); + } + + /** + * @covers ResourceLoaderImage::getImageData + * @covers ResourceLoaderImage::variantize + * @covers ResourceLoaderImage::massageSvgPathdata + */ + public function testGetImageData() { + $context = $this->getResourceLoaderContext( 'en', 'ltr' ); + + $image = $this->getTestImage( 'remove' ); + $data = file_get_contents( $this->imagesPath . '/remove.svg' ); + $dataConstructive = file_get_contents( $this->imagesPath . '/remove_variantize.svg' ); + $this->assertEquals( $image->getImageData( $context, null, 'original' ), $data ); + $this->assertEquals( $image->getImageData( $context, 'destructive', 'original' ), $dataConstructive ); + // Stub, since we don't know if we even have a SVG handler, much less what exactly it'll output + $this->assertEquals( $image->getImageData( $context, null, 'rasterized' ), 'RASTERIZESTUB' ); + + $image = $this->getTestImage( 'add' ); + $data = file_get_contents( $this->imagesPath . '/add.gif' ); + $this->assertEquals( $image->getImageData( $context, null, 'original' ), $data ); + $this->assertEquals( $image->getImageData( $context, null, 'rasterized' ), $data ); + } + + /** + * @covers ResourceLoaderImage::massageSvgPathdata + */ + public function testMassageSvgPathdata() { + $image = $this->getTestImage( 'next' ); + $data = file_get_contents( $this->imagesPath . '/next.svg' ); + $dataMassaged = file_get_contents( $this->imagesPath . '/next_massage.svg' ); + $this->assertEquals( $image->massageSvgPathdata( $data ), $dataMassaged ); + } +} + +class ResourceLoaderImageTestable extends ResourceLoaderImage { + // Make some protected methods public + public function getPath( ResourceLoaderContext $context ) { + return parent::getPath( $context ); + } + public function massageSvgPathdata( $svg ) { + return parent::massageSvgPathdata( $svg ); + } + // Stub, since we don't know if we even have a SVG handler, much less what exactly it'll output + public function rasterize( $svg ) { + return 'RASTERIZESTUB'; + } +} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php index b0edaaf7..6d1ed4e0 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php @@ -2,71 +2,12 @@ class ResourceLoaderModuleTest extends ResourceLoaderTestCase { - protected function setUp() { - parent::setUp(); - - // The return value of the closure shouldn't matter since this test should - // never call it - SkinFactory::getDefaultInstance()->register( - 'fakeskin', - 'FakeSkin', - function () { - } - ); - } - - /** - * @covers ResourceLoaderFileModule::getAllSkinStyleFiles - */ - public function testGetAllSkinStyleFiles() { - $context = self::getResourceLoaderContext(); - - $baseParams = array( - 'scripts' => array( - 'foo.js', - 'bar.js', - ), - 'styles' => array( - 'foo.css', - 'bar.css' => array( 'media' => 'print' ), - 'screen.less' => array( 'media' => 'screen' ), - 'screen-query.css' => array( 'media' => 'screen and (min-width: 400px)' ), - ), - 'skinStyles' => array( - 'default' => 'quux-fallback.less', - 'fakeskin' => array( - 'baz-vector.css', - 'quux-vector.less', - ), - ), - 'messages' => array( - 'hello', - 'world', - ), - ); - - $module = new ResourceLoaderFileModule( $baseParams ); - - $this->assertEquals( - array( - 'foo.css', - 'baz-vector.css', - 'quux-vector.less', - 'quux-fallback.less', - 'bar.css', - 'screen.less', - 'screen-query.css', - ), - array_map( 'basename', $module->getAllStyleFiles() ) - ); - } - /** * @covers ResourceLoaderModule::getDefinitionSummary * @covers ResourceLoaderFileModule::getDefinitionSummary */ public function testDefinitionSummary() { - $context = self::getResourceLoaderContext(); + $context = $this->getResourceLoaderContext(); $baseParams = array( 'scripts' => array( 'foo.js', 'bar.js' ), diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php new file mode 100644 index 00000000..7f3506cc --- /dev/null +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php @@ -0,0 +1,388 @@ + 'Empty registry', + 'modules' => array(), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php" +} );mw.loader.register( [] );' + ) ), + array( array( + 'msg' => 'Basic registry', + 'modules' => array( + 'test.blank' => new ResourceLoaderTestModule(), + ), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php" +} );mw.loader.register( [ + [ + "test.blank", + 1388534400 + ] +] );', + ) ), + array( array( + 'msg' => 'Group signature', + 'modules' => array( + 'test.blank' => new ResourceLoaderTestModule(), + 'test.group.foo' => new ResourceLoaderTestModule( array( 'group' => 'x-foo' ) ), + 'test.group.bar' => new ResourceLoaderTestModule( array( 'group' => 'x-bar' ) ), + ), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php" +} );mw.loader.register( [ + [ + "test.blank", + 1388534400 + ], + [ + "test.group.foo", + 1388534400, + [], + "x-foo" + ], + [ + "test.group.bar", + 1388534400, + [], + "x-bar" + ] +] );' + ) ), + array( array( + 'msg' => 'Different target (non-test should not be registered)', + 'modules' => array( + 'test.blank' => new ResourceLoaderTestModule(), + 'test.target.foo' => new ResourceLoaderTestModule( array( 'targets' => array( 'x-foo' ) ) ), + ), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php" +} );mw.loader.register( [ + [ + "test.blank", + 1388534400 + ] +] );' + ) ), + array( array( + 'msg' => 'Foreign source', + 'sources' => array( + 'example' => array( + 'loadScript' => 'http://example.org/w/load.php', + 'apiScript' => 'http://example.org/w/api.php', + ), + ), + 'modules' => array( + 'test.blank' => new ResourceLoaderTestModule( array( 'source' => 'example' ) ), + ), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php", + "example": "http://example.org/w/load.php" +} );mw.loader.register( [ + [ + "test.blank", + 1388534400, + [], + null, + "example" + ] +] );' + ) ), + array( array( + 'msg' => 'Conditional dependency function', + 'modules' => array( + 'test.x.core' => new ResourceLoaderTestModule(), + 'test.x.polyfill' => new ResourceLoaderTestModule( array( + 'skipFunction' => 'return true;' + ) ), + 'test.y.polyfill' => new ResourceLoaderTestModule( array( + 'skipFunction' => + 'return !!(' . + ' window.JSON &&' . + ' JSON.parse &&' . + ' JSON.stringify' . + ');' + ) ), + 'test.z.foo' => new ResourceLoaderTestModule( array( + 'dependencies' => array( + 'test.x.core', + 'test.x.polyfill', + 'test.y.polyfill', + ), + ) ), + ), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php" +} );mw.loader.register( [ + [ + "test.x.core", + 1388534400 + ], + [ + "test.x.polyfill", + 1388534400, + [], + null, + null, + "return true;" + ], + [ + "test.y.polyfill", + 1388534400, + [], + null, + null, + "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);" + ], + [ + "test.z.foo", + 1388534400, + [ + 0, + 1, + 2 + ] + ] +] );', + ) ), + array( array( + // This may seem like an edge case, but a plain MediaWiki core install + // with a few extensions installed is likely far more complex than this + // even, not to mention an install like Wikipedia. + // TODO: Make this even more realistic. + 'msg' => 'Advanced (everything combined)', + 'sources' => array( + 'example' => array( + 'loadScript' => 'http://example.org/w/load.php', + 'apiScript' => 'http://example.org/w/api.php', + ), + ), + 'modules' => array( + 'test.blank' => new ResourceLoaderTestModule(), + 'test.x.core' => new ResourceLoaderTestModule(), + 'test.x.util' => new ResourceLoaderTestModule( array( + 'dependencies' => array( + 'test.x.core', + ), + ) ), + 'test.x.foo' => new ResourceLoaderTestModule( array( + 'dependencies' => array( + 'test.x.core', + ), + ) ), + 'test.x.bar' => new ResourceLoaderTestModule( array( + 'dependencies' => array( + 'test.x.core', + 'test.x.util', + ), + ) ), + 'test.x.quux' => new ResourceLoaderTestModule( array( + 'dependencies' => array( + 'test.x.foo', + 'test.x.bar', + 'test.x.util', + 'test.x.unknown', + ), + ) ), + 'test.group.foo.1' => new ResourceLoaderTestModule( array( + 'group' => 'x-foo', + ) ), + 'test.group.foo.2' => new ResourceLoaderTestModule( array( + 'group' => 'x-foo', + ) ), + 'test.group.bar.1' => new ResourceLoaderTestModule( array( + 'group' => 'x-bar', + ) ), + 'test.group.bar.2' => new ResourceLoaderTestModule( array( + 'group' => 'x-bar', + 'source' => 'example', + ) ), + 'test.target.foo' => new ResourceLoaderTestModule( array( + 'targets' => array( 'x-foo' ), + ) ), + 'test.target.bar' => new ResourceLoaderTestModule( array( + 'source' => 'example', + 'targets' => array( 'x-foo' ), + ) ), + ), + 'out' => ' +mw.loader.addSource( { + "local": "/w/load.php", + "example": "http://example.org/w/load.php" +} );mw.loader.register( [ + [ + "test.blank", + 1388534400 + ], + [ + "test.x.core", + 1388534400 + ], + [ + "test.x.util", + 1388534400, + [ + 1 + ] + ], + [ + "test.x.foo", + 1388534400, + [ + 1 + ] + ], + [ + "test.x.bar", + 1388534400, + [ + 2 + ] + ], + [ + "test.x.quux", + 1388534400, + [ + 3, + 4, + "test.x.unknown" + ] + ], + [ + "test.group.foo.1", + 1388534400, + [], + "x-foo" + ], + [ + "test.group.foo.2", + 1388534400, + [], + "x-foo" + ], + [ + "test.group.bar.1", + 1388534400, + [], + "x-bar" + ], + [ + "test.group.bar.2", + 1388534400, + [], + "x-bar", + "example" + ] +] );' + ) ), + ); + } + + /** + * @dataProvider provideGetModuleRegistrations + * @covers ResourceLoaderStartUpModule::compileUnresolvedDependencies + * @covers ResourceLoaderStartUpModule::getModuleRegistrations + * @covers ResourceLoader::makeLoaderSourcesScript + * @covers ResourceLoader::makeLoaderRegisterScript + */ + public function testGetModuleRegistrations( $case ) { + if ( isset( $case['sources'] ) ) { + $this->setMwGlobals( 'wgResourceLoaderSources', $case['sources'] ); + } + + $context = $this->getResourceLoaderContext(); + $rl = $context->getResourceLoader(); + + $rl->register( $case['modules'] ); + + $module = new ResourceLoaderStartUpModule(); + $this->assertEquals( + ltrim( $case['out'], "\n" ), + $module->getModuleRegistrations( $context ), + $case['msg'] + ); + } + + public static function provideRegistrations() { + return array( + array( array( + 'test.blank' => new ResourceLoaderTestModule(), + 'test.min' => new ResourceLoaderTestModule( array( + 'skipFunction' => + 'return !!(' . + ' window.JSON &&' . + ' JSON.parse &&' . + ' JSON.stringify' . + ');', + 'dependencies' => array( + 'test.blank', + ), + ) ), + ) ) + ); + } + /** + * @dataProvider provideRegistrations + */ + public function testRegistrationsMinified( $modules ) { + $this->setMwGlobals( 'wgResourceLoaderDebug', false ); + + $context = $this->getResourceLoaderContext(); + $rl = $context->getResourceLoader(); + $rl->register( $modules ); + $module = new ResourceLoaderStartUpModule(); + $this->assertEquals( +'mw.loader.addSource({"local":"/w/load.php"});' +. 'mw.loader.register([' +. '["test.blank",1388534400],' +. '["test.min",1388534400,[0],null,null,' +. '"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"' +. ']]);', + $module->getModuleRegistrations( $context ), + 'Minified output' + ); + } + + /** + * @dataProvider provideRegistrations + */ + public function testRegistrationsUnminified( $modules ) { + $context = $this->getResourceLoaderContext(); + $rl = $context->getResourceLoader(); + $rl->register( $modules ); + $module = new ResourceLoaderStartUpModule(); + $this->assertEquals( +'mw.loader.addSource( { + "local": "/w/load.php" +} );mw.loader.register( [ + [ + "test.blank", + 1388534400 + ], + [ + "test.min", + 1388534400, + [ + 0 + ], + null, + null, + "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);" + ] +] );', + $module->getModuleRegistrations( $context ), + 'Unminified output' + ); + } + +} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php deleted file mode 100644 index a1893873..00000000 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php +++ /dev/null @@ -1,388 +0,0 @@ - 'Empty registry', - 'modules' => array(), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php" -} );mw.loader.register( [] );' - ) ), - array( array( - 'msg' => 'Basic registry', - 'modules' => array( - 'test.blank' => new ResourceLoaderTestModule(), - ), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php" -} );mw.loader.register( [ - [ - "test.blank", - "1388534400" - ] -] );', - ) ), - array( array( - 'msg' => 'Group signature', - 'modules' => array( - 'test.blank' => new ResourceLoaderTestModule(), - 'test.group.foo' => new ResourceLoaderTestModule( array( 'group' => 'x-foo' ) ), - 'test.group.bar' => new ResourceLoaderTestModule( array( 'group' => 'x-bar' ) ), - ), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php" -} );mw.loader.register( [ - [ - "test.blank", - "1388534400" - ], - [ - "test.group.foo", - "1388534400", - [], - "x-foo" - ], - [ - "test.group.bar", - "1388534400", - [], - "x-bar" - ] -] );' - ) ), - array( array( - 'msg' => 'Different target (non-test should not be registered)', - 'modules' => array( - 'test.blank' => new ResourceLoaderTestModule(), - 'test.target.foo' => new ResourceLoaderTestModule( array( 'targets' => array( 'x-foo' ) ) ), - ), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php" -} );mw.loader.register( [ - [ - "test.blank", - "1388534400" - ] -] );' - ) ), - array( array( - 'msg' => 'Foreign source', - 'sources' => array( - 'example' => array( - 'loadScript' => 'http://example.org/w/load.php', - 'apiScript' => 'http://example.org/w/api.php', - ), - ), - 'modules' => array( - 'test.blank' => new ResourceLoaderTestModule( array( 'source' => 'example' ) ), - ), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php", - "example": "http://example.org/w/load.php" -} );mw.loader.register( [ - [ - "test.blank", - "1388534400", - [], - null, - "example" - ] -] );' - ) ), - array( array( - 'msg' => 'Conditional dependency function', - 'modules' => array( - 'test.x.core' => new ResourceLoaderTestModule(), - 'test.x.polyfill' => new ResourceLoaderTestModule( array( - 'skipFunction' => 'return true;' - ) ), - 'test.y.polyfill' => new ResourceLoaderTestModule( array( - 'skipFunction' => - 'return !!(' . - ' window.JSON &&' . - ' JSON.parse &&' . - ' JSON.stringify' . - ');' - ) ), - 'test.z.foo' => new ResourceLoaderTestModule( array( - 'dependencies' => array( - 'test.x.core', - 'test.x.polyfil', - 'test.y.polyfil', - ), - ) ), - ), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php" -} );mw.loader.register( [ - [ - "test.x.core", - "1388534400" - ], - [ - "test.x.polyfill", - "1388534400", - [], - null, - "local", - "return true;" - ], - [ - "test.y.polyfill", - "1388534400", - [], - null, - "local", - "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);" - ], - [ - "test.z.foo", - "1388534400", - [ - "test.x.core", - "test.x.polyfil", - "test.y.polyfil" - ] - ] -] );', - ) ), - array( array( - // This may seem like an edge case, but a plain MediaWiki core install - // with a few extensions installed is likely far more complex than this - // even, not to mention an install like Wikipedia. - // TODO: Make this even more realistic. - 'msg' => 'Advanced (everything combined)', - 'sources' => array( - 'example' => array( - 'loadScript' => 'http://example.org/w/load.php', - 'apiScript' => 'http://example.org/w/api.php', - ), - ), - 'modules' => array( - 'test.blank' => new ResourceLoaderTestModule(), - 'test.x.core' => new ResourceLoaderTestModule(), - 'test.x.util' => new ResourceLoaderTestModule( array( - 'dependencies' => array( - 'test.x.core', - ), - ) ), - 'test.x.foo' => new ResourceLoaderTestModule( array( - 'dependencies' => array( - 'test.x.core', - ), - ) ), - 'test.x.bar' => new ResourceLoaderTestModule( array( - 'dependencies' => array( - 'test.x.core', - 'test.x.util', - ), - ) ), - 'test.x.quux' => new ResourceLoaderTestModule( array( - 'dependencies' => array( - 'test.x.foo', - 'test.x.bar', - 'test.x.util', - 'test.x.unknown', - ), - ) ), - 'test.group.foo.1' => new ResourceLoaderTestModule( array( - 'group' => 'x-foo', - ) ), - 'test.group.foo.2' => new ResourceLoaderTestModule( array( - 'group' => 'x-foo', - ) ), - 'test.group.bar.1' => new ResourceLoaderTestModule( array( - 'group' => 'x-bar', - ) ), - 'test.group.bar.2' => new ResourceLoaderTestModule( array( - 'group' => 'x-bar', - 'source' => 'example', - ) ), - 'test.target.foo' => new ResourceLoaderTestModule( array( - 'targets' => array( 'x-foo' ), - ) ), - 'test.target.bar' => new ResourceLoaderTestModule( array( - 'source' => 'example', - 'targets' => array( 'x-foo' ), - ) ), - ), - 'out' => ' -mw.loader.addSource( { - "local": "/w/load.php", - "example": "http://example.org/w/load.php" -} );mw.loader.register( [ - [ - "test.blank", - "1388534400" - ], - [ - "test.x.core", - "1388534400" - ], - [ - "test.x.util", - "1388534400", - [ - "test.x.core" - ] - ], - [ - "test.x.foo", - "1388534400", - [ - "test.x.core" - ] - ], - [ - "test.x.bar", - "1388534400", - [ - "test.x.util" - ] - ], - [ - "test.x.quux", - "1388534400", - [ - "test.x.foo", - "test.x.bar", - "test.x.unknown" - ] - ], - [ - "test.group.foo.1", - "1388534400", - [], - "x-foo" - ], - [ - "test.group.foo.2", - "1388534400", - [], - "x-foo" - ], - [ - "test.group.bar.1", - "1388534400", - [], - "x-bar" - ], - [ - "test.group.bar.2", - "1388534400", - [], - "x-bar", - "example" - ] -] );' - ) ), - ); - } - - /** - * @dataProvider provideGetModuleRegistrations - * @covers ResourceLoaderStartupModule::optimizeDependencies - * @covers ResourceLoaderStartUpModule::getModuleRegistrations - * @covers ResourceLoader::makeLoaderSourcesScript - * @covers ResourceLoader::makeLoaderRegisterScript - */ - public function testGetModuleRegistrations( $case ) { - if ( isset( $case['sources'] ) ) { - $this->setMwGlobals( 'wgResourceLoaderSources', $case['sources'] ); - } - - $context = self::getResourceLoaderContext(); - $rl = $context->getResourceLoader(); - - $rl->register( $case['modules'] ); - - $module = new ResourceLoaderStartUpModule(); - $this->assertEquals( - ltrim( $case['out'], "\n" ), - $module->getModuleRegistrations( $context ), - $case['msg'] - ); - } - - public static function provideRegistrations() { - return array( - array( array( - 'test.blank' => new ResourceLoaderTestModule(), - 'test.min' => new ResourceLoaderTestModule( array( - 'skipFunction' => - 'return !!(' . - ' window.JSON &&' . - ' JSON.parse &&' . - ' JSON.stringify' . - ');', - 'dependencies' => array( - 'test.blank', - ), - ) ), - ) ) - ); - } - /** - * @dataProvider provideRegistrations - */ - public function testRegistrationsMinified( $modules ) { - $this->setMwGlobals( 'wgResourceLoaderDebug', false ); - - $context = self::getResourceLoaderContext(); - $rl = $context->getResourceLoader(); - $rl->register( $modules ); - $module = new ResourceLoaderStartUpModule(); - $this->assertEquals( -'mw.loader.addSource({"local":"/w/load.php"});' -. 'mw.loader.register([' -. '["test.blank","1388534400"],' -. '["test.min","1388534400",["test.blank"],null,"local",' -. '"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"' -. ']]);', - $module->getModuleRegistrations( $context ), - 'Minified output' - ); - } - - /** - * @dataProvider provideRegistrations - */ - public function testRegistrationsUnminified( $modules ) { - $context = self::getResourceLoaderContext(); - $rl = $context->getResourceLoader(); - $rl->register( $modules ); - $module = new ResourceLoaderStartUpModule(); - $this->assertEquals( -'mw.loader.addSource( { - "local": "/w/load.php" -} );mw.loader.register( [ - [ - "test.blank", - "1388534400" - ], - [ - "test.min", - "1388534400", - [ - "test.blank" - ], - null, - "local", - "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);" - ] -] );', - $module->getModuleRegistrations( $context ), - 'Unminified output' - ); - } - -} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index f19f6886..ca7307ec 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -2,13 +2,9 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { - protected static $resourceLoaderRegisterModulesHook; - protected function setUp() { parent::setUp(); - // $wgResourceLoaderLESSFunctions, $wgResourceLoaderLESSImportPaths; $wgResourceLoaderLESSVars; - $this->setMwGlobals( array( 'wgResourceLoaderLESSFunctions' => array( 'test-sum' => function ( $frame, $less ) { @@ -30,35 +26,33 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { ) ); } - /* Hook Methods */ - - /** - * ResourceLoaderRegisterModules hook - */ - public static function resourceLoaderRegisterModules( &$resourceLoader ) { - self::$resourceLoaderRegisterModulesHook = true; - - return true; - } - - /* Provider Methods */ public static function provideValidModules() { return array( array( 'TEST.validModule1', new ResourceLoaderTestModule() ), ); } - /* Test Methods */ - /** * Ensures that the ResourceLoaderRegisterModules hook is called when a new * ResourceLoader object is constructed. * @covers ResourceLoader::__construct */ public function testCreatingNewResourceLoaderCallsRegistrationHook() { - self::$resourceLoaderRegisterModulesHook = false; + $resourceLoaderRegisterModulesHook = false; + + $this->setMwGlobals( 'wgHooks', array( + 'ResourceLoaderRegisterModules' => array( + function ( &$resourceLoader ) use ( &$resourceLoaderRegisterModulesHook ) { + $resourceLoaderRegisterModulesHook = true; + } + ) + ) ); + $resourceLoader = new ResourceLoader(); - $this->assertTrue( self::$resourceLoaderRegisterModulesHook ); + $this->assertTrue( + $resourceLoaderRegisterModulesHook, + 'Hook ResourceLoaderRegisterModules called' + ); return $resourceLoader; } @@ -80,7 +74,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { * @covers ResourceLoaderFileModule::compileLessFile */ public function testLessFileCompilation() { - $context = self::getResourceLoaderContext(); + $context = $this->getResourceLoaderContext(); $basePath = __DIR__ . '/../../data/less/module'; $module = new ResourceLoaderFileModule( array( 'localBasePath' => $basePath, @@ -96,42 +90,10 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { * @param string $css * @return string */ - private function stripNoflip( $css ) { + private static function stripNoflip( $css ) { return str_replace( '/*@noflip*/ ', '', $css ); } - /** - * What happens when you mix @embed and @noflip? - * This really is an integration test, but oh well. - */ - public function testMixedCssAnnotations( ) { - $basePath = __DIR__ . '/../../data/css'; - $testModule = new ResourceLoaderFileModule( array( - 'localBasePath' => $basePath, - 'styles' => array( 'test.css' ), - ) ); - $expectedModule = new ResourceLoaderFileModule( array( - 'localBasePath' => $basePath, - 'styles' => array( 'expected.css' ), - ) ); - - $contextLtr = self::getResourceLoaderContext( 'en' ); - $contextRtl = self::getResourceLoaderContext( 'he' ); - - // Since we want to compare the effect of @noflip+@embed against the effect of just @embed, and - // the @noflip annotations are always preserved, we need to strip them first. - $this->assertEquals( - $expectedModule->getStyles( $contextLtr ), - $this->stripNoflip( $testModule->getStyles( $contextLtr ) ), - "/*@noflip*/ with /*@embed*/ gives correct results in LTR mode" - ); - $this->assertEquals( - $expectedModule->getStyles( $contextLtr ), - $this->stripNoflip( $testModule->getStyles( $contextRtl ) ), - "/*@noflip*/ with /*@embed*/ gives correct results in RTL mode" - ); - } - /** * @dataProvider providePackedModules * @covers ResourceLoader::makePackedModulesString @@ -193,6 +155,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { /** * @dataProvider provideAddSource * @covers ResourceLoader::addSource + * @covers ResourceLoader::getSources */ public function testAddSource( $name, $info, $expected ) { $rl = new ResourceLoader; @@ -223,6 +186,106 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { ); } + public static function provideLoaderImplement() { + return array( + array( array( + 'title' => 'Implement scripts, styles and messages', + + 'name' => 'test.example', + 'scripts' => 'mw.example();', + 'styles' => array( 'css' => array( '.mw-example {}' ) ), + 'messages' => array( 'example' => '' ), + 'templates' => array(), + + 'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) { +mw.example(); +}, { + "css": [ + ".mw-example {}" + ] +}, { + "example": "" +} );', + ) ), + array( array( + 'title' => 'Implement scripts', + + 'name' => 'test.example', + 'scripts' => 'mw.example();', + 'styles' => array(), + 'messages' => new XmlJsCode( '{}' ), + 'templates' => array(), + 'title' => 'scripts, styles and messags', + + 'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) { +mw.example(); +} );', + ) ), + array( array( + 'title' => 'Implement styles', + + 'name' => 'test.example', + 'scripts' => array(), + 'styles' => array( 'css' => array( '.mw-example {}' ) ), + 'messages' => new XmlJsCode( '{}' ), + 'templates' => array(), + + 'expected' => 'mw.loader.implement( "test.example", [], { + "css": [ + ".mw-example {}" + ] +} );', + ) ), + array( array( + 'title' => 'Implement scripts and messages', + + 'name' => 'test.example', + 'scripts' => 'mw.example();', + 'styles' => array(), + 'messages' => array( 'example' => '' ), + 'templates' => array(), + + 'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) { +mw.example(); +}, {}, { + "example": "" +} );', + ) ), + array( array( + 'title' => 'Implement scripts and templates', + + 'name' => 'test.example', + 'scripts' => 'mw.example();', + 'styles' => array(), + 'messages' => new XmlJsCode( '{}' ), + 'templates' => array( 'example.html' => '' ), + + 'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) { +mw.example(); +}, {}, {}, { + "example.html": "" +} );', + ) ), + ); + } + + /** + * @dataProvider provideLoaderImplement + * @covers ResourceLoader::makeLoaderImplementScript + */ + public function testMakeLoaderImplementScript( $case ) { + $this->assertEquals( + $case['expected'], + ResourceLoader::makeLoaderImplementScript( + $case['name'], + $case['scripts'], + $case['styles'], + $case['messages'], + $case['templates'] + ) + ); + } + /** * @covers ResourceLoader::getLoadScript */ @@ -242,8 +305,14 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { $this->assertTrue( true ); } } -} -/* Hooks */ -global $wgHooks; -$wgHooks['ResourceLoaderRegisterModules'][] = 'ResourceLoaderTest::resourceLoaderRegisterModules'; + /** + * @covers ResourceLoader::isModuleRegistered + */ + public function testIsModuleRegistered() { + $rl = new ResourceLoader(); + $rl->register( 'test.module', new ResourceLoaderTestModule() ); + $this->assertTrue( $rl->isModuleRegistered( 'test.module' ) ); + $this->assertFalse( $rl->isModuleRegistered( 'test.modulenotregistered' ) ); + } +} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php index 9dc18050..93a3ebba 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php @@ -2,12 +2,94 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase { + /** + * @covers ResourceLoaderWikiModule::__construct + * @dataProvider provideConstructor + */ + public function testConstructor( $params ) { + $module = new ResourceLoaderWikiModule( $params ); + $this->assertInstanceOf( 'ResourceLoaderWikiModule', $module ); + } + + public static function provideConstructor() { + return array( + // Nothing + array( null ), + array( array() ), + // Unrecognized settings + array( array( 'foo' => 'baz' ) ), + // Real settings + array( array( 'scripts' => array( 'MediaWiki:Common.js' ) ) ), + ); + } + + /** + * @dataProvider provideGetPages + * @covers ResourceLoaderWikiModule::getPages + */ + public function testGetPages( $params, Config $config, $expected ) { + $module = new ResourceLoaderWikiModule( $params ); + $module->setConfig( $config ); + + // Use getDefinitionSummary because getPages is protected + $summary = $module->getDefinitionSummary( ResourceLoaderContext::newDummyContext() ); + $this->assertEquals( + $expected, + $summary['pages'] + ); + } + + public static function provideGetPages() { + $settings = array( + 'UseSiteJs' => true, + 'UseSiteCss' => true, + ); + + $params = array( + 'styles' => array( 'MediaWiki:Common.css' ), + 'scripts' => array( 'MediaWiki:Common.js' ), + ); + + return array( + array( array(), new HashConfig( $settings ), array() ), + array( $params, new HashConfig( $settings ), array( + 'MediaWiki:Common.js' => array( 'type' => 'script' ), + 'MediaWiki:Common.css' => array( 'type' => 'style' ) + ) ), + array( $params, new HashConfig( array( 'UseSiteCss' => false ) + $settings ), array( + 'MediaWiki:Common.js' => array( 'type' => 'script' ), + ) ), + array( $params, new HashConfig( array( 'UseSiteJs' => false ) + $settings ), array( + 'MediaWiki:Common.css' => array( 'type' => 'style' ), + ) ), + array( $params, new HashConfig( array( 'UseSiteJs' => false, 'UseSiteCss' => false ) ), array() ), + ); + } + + /** + * @covers ResourceLoaderWikiModule::getGroup + * @dataProvider provideGetGroup + */ + public function testGetGroup( $params, $expected ) { + $module = new ResourceLoaderWikiModule( $params ); + $this->assertEquals( $expected, $module->getGroup() ); + } + + public static function provideGetGroup() { + return array( + // No group specified + array( array(), null ), + // A random group + array( array( 'group' => 'foobar' ), 'foobar' ), + ); + } + /** * @covers ResourceLoaderWikiModule::isKnownEmpty * @dataProvider provideIsKnownEmpty */ public function testIsKnownEmpty( $titleInfo, $group, $expected ) { - $module = $this->getMockBuilder( 'ResourceLoaderWikiModuleTestModule' ) + $module = $this->getMockBuilder( 'ResourceLoaderWikiModule' ) ->setMethods( array( 'getTitleInfo', 'getGroup' ) ) ->getMock(); $module->expects( $this->any() ) diff --git a/tests/phpunit/includes/resourceloader/templates/template.html b/tests/phpunit/includes/resourceloader/templates/template.html new file mode 100644 index 00000000..1f6a7d22 --- /dev/null +++ b/tests/phpunit/includes/resourceloader/templates/template.html @@ -0,0 +1 @@ +hello diff --git a/tests/phpunit/includes/resourceloader/templates/template2.html b/tests/phpunit/includes/resourceloader/templates/template2.html new file mode 100644 index 00000000..a322f67d --- /dev/null +++ b/tests/phpunit/includes/resourceloader/templates/template2.html @@ -0,0 +1 @@ +
goodbye
diff --git a/tests/phpunit/includes/resourceloader/templates/template_awesome.handlebars b/tests/phpunit/includes/resourceloader/templates/template_awesome.handlebars new file mode 100644 index 00000000..5f5c07d5 --- /dev/null +++ b/tests/phpunit/includes/resourceloader/templates/template_awesome.handlebars @@ -0,0 +1 @@ +wow -- cgit v1.2.3-54-g00ecf