Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / resourceloader / ResourceLoaderFileModuleTest.php
blob9afc54d6cb1f0aa25ca7f870b1dfaf60a98af19a
1 <?php
3 /**
4 * @group ResourceLoader
5 */
6 class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
8 protected function setUp() {
9 parent::setUp();
11 // The return value of the closure shouldn't matter since this test should
12 // never call it
13 SkinFactory::getDefaultInstance()->register(
14 'fakeskin',
15 'FakeSkin',
16 function () {
21 public static function getModules() {
22 $base = array(
23 'localBasePath' => realpath( dirname( __FILE__ ) ),
26 return array(
27 'noTemplateModule' => array(),
29 'htmlTemplateModule' => $base + array(
30 'templates' => array(
31 'templates/template.html',
32 'templates/template2.html',
36 'aliasedHtmlTemplateModule' => $base + array(
37 'templates' => array(
38 'foo.html' => 'templates/template.html',
39 'bar.html' => 'templates/template2.html',
43 'templateModuleHandlebars' => $base + array(
44 'templates' => array(
45 'templates/template_awesome.handlebars',
51 public static function providerGetTemplates() {
52 $modules = self::getModules();
54 return array(
55 array(
56 $modules['noTemplateModule'],
57 array(),
59 array(
60 $modules['templateModuleHandlebars'],
61 array(
62 'templates/template_awesome.handlebars' => "wow\n",
65 array(
66 $modules['htmlTemplateModule'],
67 array(
68 'templates/template.html' => "<strong>hello</strong>\n",
69 'templates/template2.html' => "<div>goodbye</div>\n",
72 array(
73 $modules['aliasedHtmlTemplateModule'],
74 array(
75 'foo.html' => "<strong>hello</strong>\n",
76 'bar.html' => "<div>goodbye</div>\n",
82 public static function providerGetModifiedTime() {
83 $modules = self::getModules();
85 return array(
86 // Check the default value when no templates present in module is 1
87 array( $modules['noTemplateModule'], 1 ),
91 /**
92 * @covers ResourceLoaderFileModule::getAllSkinStyleFiles
94 public function testGetAllSkinStyleFiles() {
95 $baseParams = array(
96 'scripts' => array(
97 'foo.js',
98 'bar.js',
100 'styles' => array(
101 'foo.css',
102 'bar.css' => array( 'media' => 'print' ),
103 'screen.less' => array( 'media' => 'screen' ),
104 'screen-query.css' => array( 'media' => 'screen and (min-width: 400px)' ),
106 'skinStyles' => array(
107 'default' => 'quux-fallback.less',
108 'fakeskin' => array(
109 'baz-vector.css',
110 'quux-vector.less',
113 'messages' => array(
114 'hello',
115 'world',
119 $module = new ResourceLoaderFileModule( $baseParams );
121 $this->assertEquals(
122 array(
123 'foo.css',
124 'baz-vector.css',
125 'quux-vector.less',
126 'quux-fallback.less',
127 'bar.css',
128 'screen.less',
129 'screen-query.css',
131 array_map( 'basename', $module->getAllStyleFiles() )
136 * @dataProvider providerGetTemplates
137 * @covers ResourceLoaderFileModule::getTemplates
139 public function testGetTemplates( $module, $expected ) {
140 $rl = new ResourceLoaderFileModule( $module );
142 $this->assertEquals( $rl->getTemplates(), $expected );
146 * @dataProvider providerGetModifiedTime
147 * @covers ResourceLoaderFileModule::getModifiedTime
149 public function testGetModifiedTime( $module, $expected ) {
150 $rl = new ResourceLoaderFileModule( $module );
151 $ts = $rl->getModifiedTime( $this->getResourceLoaderContext() );
152 $this->assertEquals( $ts, $expected );