Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/307664
Change subject: Add basic test for Zero ...................................................................... Add basic test for Zero If the module loads with an error we should complain. ZeroBanner tests are run in MobileFrontend so this will prevent further breakages to this module. Bug: T143425 Change-Id: I5921acd85ef16defb9df5fdabd7355e2842c8550 --- M ZeroBanner.php A includes/TestHooks.php A tests/test_zerobanner.js 3 files changed, 55 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroBanner refs/changes/64/307664/1 diff --git a/ZeroBanner.php b/ZeroBanner.php index 68fec3a..ef92825 100644 --- a/ZeroBanner.php +++ b/ZeroBanner.php @@ -45,6 +45,7 @@ 'ApiRawJsonPrinter' => 'ApiZeroBanner', 'ApiZeroBanner', 'PageRendering', + 'TestHooks', 'PageRenderingHooks', 'ZeroConfig', 'ZeroSpecialPage' @@ -179,6 +180,8 @@ $wgHooks['MakeGlobalVariablesScript'][] = $hook . 'onMakeGlobalVariablesScript'; $wgHooks['SpecialMobileEditWatchlist::images'][] = $hook . 'onSpecialMobileEditWatchlist_images'; +$wgHooks['ResourceLoaderTestModules'][] = 'ZeroBanner\\TestHooks::onResourceLoaderTestModules'; + $wgAPIModules['zeroconfig'] = 'ZeroBanner\ApiZeroBanner'; // Define constants but don't add them to the namespace list - they will be used for external access only diff --git a/includes/TestHooks.php b/includes/TestHooks.php new file mode 100644 index 0000000..f118f81 --- /dev/null +++ b/includes/TestHooks.php @@ -0,0 +1,43 @@ +<?php +namespace ZeroBanner; +use ResourceLoader; + + +/** + * Main class for ZeroBanner extension. + * + * This class only contains static members. + * Static methods are used by the hooks and by the Special:ZeroBanner. + * The state is based on the X-CS and other headers, and has an instance + * of config object and and a few header-based cached values. + * + * @file + * @ingroup Extensions + */ +class TestHooks { + /** + * ResourceLoaderTestModules hook handler + * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules + * + * @param array $testModules + * @param ResourceLoader $resourceLoader + * @return bool + */ + public static function onResourceLoaderTestModules( array &$testModules, + ResourceLoader &$resourceLoader + ) { + $testModule = [ + 'dependencies' => [ 'zerobanner' ], + 'localBasePath' => __DIR__ . '/../tests/', + 'remoteExtPath' => 'ZeroBanner', + 'targets' => [ 'mobile', 'desktop' ], + 'scripts' => [ + 'test_zerobanner.js', + ] + ]; + + // Expose templates module + $testModules['qunit']["tests.zero"] = $testModule; + return true; + } +} diff --git a/tests/test_zerobanner.js b/tests/test_zerobanner.js new file mode 100644 index 0000000..859fe7c --- /dev/null +++ b/tests/test_zerobanner.js @@ -0,0 +1,9 @@ +( function ( M, $ ) { + QUnit.module( 'Zero' ); + + QUnit.test( '#init', 1, function ( assert ) { + assert.ok( mw.loader.getState( 'zerobanner' ) === 'ready', + 'check Zero banner module installed without problems' ); + } ); + +}( mw.mobileFrontend, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/307664 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5921acd85ef16defb9df5fdabd7355e2842c8550 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ZeroBanner Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits