MediaWiki  REL1_23
ResourceLoaderTestCase.php
Go to the documentation of this file.
00001 <?php
00002 
00003 abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
00004 
00005     protected static function getResourceLoaderContext() {
00006         $resourceLoader = new ResourceLoader();
00007         $request = new FauxRequest( array(
00008                 'debug' => 'true',
00009                 'lang' => 'en',
00010                 'modules' => 'startup',
00011                 'only' => 'scripts',
00012                 'skin' => 'vector',
00013                 'target' => 'test',
00014         ) );
00015         return new ResourceLoaderContext( $resourceLoader, $request );
00016     }
00017 
00018     protected function setUp() {
00019         parent::setUp();
00020 
00021         $this->setMwGlobals( array(
00022             // For ResourceLoader::inDebugMode since it doesn't have context
00023             'wgResourceLoaderDebug' => true,
00024 
00025             // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
00026             'wgCacheEpoch' => '20140101000000',
00027 
00028             // For ResourceLoader::__construct()
00029             'wgResourceLoaderSources' => array(),
00030 
00031             // For wfScript()
00032             'wgScriptPath' => '/w',
00033             'wgScriptExtension' => '.php',
00034             'wgScript' => '/w/index.php',
00035             'wgLoadScript' => '/w/load.php',
00036         ) );
00037     }
00038 }
00039 
00040 /* Stubs */
00041 
00042 class ResourceLoaderTestModule extends ResourceLoaderModule {
00043 
00044     protected $dependencies = array();
00045     protected $group = null;
00046     protected $source = 'local';
00047     protected $targets = array( 'test' );
00048 
00049     public function __construct( $options = array() ) {
00050         foreach ( $options as $key => $value ) {
00051             $this->$key = $value;
00052         }
00053     }
00054 
00055     public function getDependencies() {
00056         return $this->dependencies;
00057     }
00058 
00059     public function getGroup() {
00060         return $this->group;
00061     }
00062 
00063     public function getSource() {
00064         return $this->source;
00065     }
00066 }
00067 
00068 class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {}