aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
diff options
context:
space:
mode:
authorjdlrobson <jdlrobson@gmail.com>2014-10-09 17:07:14 -0700
committerjdlrobson <jdlrobson@gmail.com>2014-10-17 09:23:04 -0700
commitd146934f94ba7028fb0ad0a180786bc5856990d6 (patch)
tree6558ea53b8dff5e5bb5963c16a91f7af83a4f451 /tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
parent05b7a51966709d42beb5f786378bb8af4ca7a72f (diff)
downloadmediawikicore-d146934f94ba7028fb0ad0a180786bc5856990d6.tar.gz
mediawikicore-d146934f94ba7028fb0ad0a180786bc5856990d6.zip
Add RL template module with HTML markup language
Preparation work for templating in core. RL should allow us to ship HTML / template markup from server to client. Use in Special:Upload and mediawiki.feedback as a proof of concept. Separation of concerns etc... See Also: Ia63d6b6868f23a773e4a41daa0036d4bf2cd6724 Change-Id: I6ff38c12897e3164969a1090449e626001926c3b
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php')
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
new file mode 100644
index 000000000000..474a01b0f14e
--- /dev/null
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * @group ResourceLoader
+ */
+class ResourceLoaderFileModuleTest extends MediaWikiTestCase {
+ 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',
+ ),
+ ),
+ );
+ }
+
+ public 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' => "<strong>hello</strong>\n",
+ 'templates/template2.html' => "<div>goodbye</div>\n",
+ ),
+ ),
+ array(
+ $modules['aliasedHtmlTemplateModule'],
+ array(
+ 'foo.html' => "<strong>hello</strong>\n",
+ 'bar.html' => "<div>goodbye</div>\n",
+ ),
+ ),
+ );
+ }
+
+ public function providerGetModifiedTime() {
+ $modules = self::getModules();
+
+ return array(
+ // Check the default value when no templates present in module is 1
+ array( $modules['noTemplateModule'], 1 ),
+ );
+ }
+
+ // tests
+ /**
+ * @dataProvider providerGetTemplates
+ */
+ public function testGetTemplates( $module, $expected ) {
+ $rl = new ResourceLoaderFileModule( $module );
+
+ $this->assertEquals( $rl->getTemplates(), $expected );
+ }
+
+ /**
+ * @dataProvider providerGetModifiedTime
+ */
+ public function testGetModifiedTime( $module, $expected ) {
+ $rl = new ResourceLoaderFileModule( $module );
+ $ts = $rl->getModifiedTime( new ResourceLoaderContext(
+ new ResourceLoader, new WebRequest() ) );
+ $this->assertEquals( $ts, $expected );
+ }
+}