Merge "Add prebodyhtml template variable"
[lhc/web/wiklou.git] / tests / phpunit / ResourceLoaderTestCase.php
1 <?php
2
3 abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
4
5 protected static function getResourceLoaderContext() {
6 $resourceLoader = new ResourceLoader();
7 $request = new FauxRequest( array(
8 'debug' => 'true',
9 'lang' => 'en',
10 'modules' => 'startup',
11 'only' => 'scripts',
12 'skin' => 'vector',
13 'target' => 'test',
14 ) );
15 return new ResourceLoaderContext( $resourceLoader, $request );
16 }
17
18 protected function setUp() {
19 parent::setUp();
20
21 $this->setMwGlobals( array(
22 // For ResourceLoader::inDebugMode since it doesn't have context
23 'wgResourceLoaderDebug' => true,
24
25 // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
26 'wgCacheEpoch' => '20140101000000',
27
28 // For ResourceLoader::__construct()
29 'wgResourceLoaderSources' => array(),
30
31 // For wfScript()
32 'wgScriptPath' => '/w',
33 'wgScriptExtension' => '.php',
34 'wgScript' => '/w/index.php',
35 'wgLoadScript' => '/w/load.php',
36 ) );
37 }
38 }
39
40 /* Stubs */
41
42 class ResourceLoaderTestModule extends ResourceLoaderModule {
43
44 protected $dependencies = array();
45 protected $group = null;
46 protected $source = 'local';
47 protected $targets = array( 'test' );
48
49 public function __construct( $options = array() ) {
50 foreach ( $options as $key => $value ) {
51 $this->$key = $value;
52 }
53 }
54
55 public function getDependencies() {
56 return $this->dependencies;
57 }
58
59 public function getGroup() {
60 return $this->group;
61 }
62
63 public function getSource() {
64 return $this->source;
65 }
66 }
67
68 class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {}