MediaWiki  1.23.2
ResourceLoaderModuleTest.php
Go to the documentation of this file.
1 <?php
2 
4 
9  public function testDefinitionSummary() {
10  $context = self::getResourceLoaderContext();
11 
12  $baseParams = array(
13  'scripts' => array( 'foo.js', 'bar.js' ),
14  'dependencies' => array( 'jquery', 'mediawiki' ),
15  'messages' => array( 'hello', 'world' ),
16  );
17 
18  $module = new ResourceLoaderFileModule( $baseParams );
19 
20  $jsonSummary = json_encode( $module->getDefinitionSummary( $context ) );
21 
22  // Exactly the same
23  $module = new ResourceLoaderFileModule( $baseParams );
24 
25  $this->assertEquals(
26  $jsonSummary,
27  json_encode( $module->getDefinitionSummary( $context ) ),
28  'Instance is insignificant'
29  );
30 
31  // Re-order dependencies
32  $module = new ResourceLoaderFileModule( array(
33  'dependencies' => array( 'mediawiki', 'jquery' ),
34  ) + $baseParams );
35 
36  $this->assertEquals(
37  $jsonSummary,
38  json_encode( $module->getDefinitionSummary( $context ) ),
39  'Order of dependencies is insignificant'
40  );
41 
42  // Re-order messages
43  $module = new ResourceLoaderFileModule( array(
44  'messages' => array( 'world', 'hello' ),
45  ) + $baseParams );
46 
47  $this->assertEquals(
48  $jsonSummary,
49  json_encode( $module->getDefinitionSummary( $context ) ),
50  'Order of messages is insignificant'
51  );
52 
53  // Re-order scripts
54  $module = new ResourceLoaderFileModule( array(
55  'scripts' => array( 'bar.js', 'foo.js' ),
56  ) + $baseParams );
57 
58  $this->assertNotEquals(
59  $jsonSummary,
60  json_encode( $module->getDefinitionSummary( $context ) ),
61  'Order of scripts is significant'
62  );
63 
64  // Subclass
65  $module = new ResourceLoaderFileModuleTestModule( $baseParams );
66 
67  $this->assertNotEquals(
68  $jsonSummary,
69  json_encode( $module->getDefinitionSummary( $context ) ),
70  'Class is significant'
71  );
72  }
73 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ResourceLoaderFileModuleTestModule
Definition: ResourceLoaderTestCase.php:68
ResourceLoaderModuleTest
Definition: ResourceLoaderModuleTest.php:3
ResourceLoaderFileModule
ResourceLoader module based on local JavaScript/CSS files.
Definition: ResourceLoaderFileModule.php:28
ResourceLoaderTestCase\getResourceLoaderContext
static getResourceLoaderContext()
Definition: ResourceLoaderTestCase.php:5
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ResourceLoaderModuleTest\testDefinitionSummary
testDefinitionSummary()
@covers ResourceLoaderModule::getDefinitionSummary @covers ResourceLoaderFileModule::getDefinitionSum...
Definition: ResourceLoaderModuleTest.php:9
ResourceLoaderTestCase
Definition: ResourceLoaderTestCase.php:3