3 abstract class ResourceLoaderTestCase
extends MediaWikiTestCase
{
4 protected static function getResourceLoaderContext( $lang = 'en' ) {
5 $resourceLoader = new ResourceLoader();
6 $request = new FauxRequest( array(
8 'modules' => 'startup',
13 return new ResourceLoaderContext( $resourceLoader, $request );
16 protected function setUp() {
19 ResourceLoader
::clearCache();
21 $this->setMwGlobals( array(
22 // For ResourceLoader::inDebugMode since it doesn't have context
23 'wgResourceLoaderDebug' => true,
25 // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
26 'wgCacheEpoch' => '20140101000000',
28 // For ResourceLoader::__construct()
29 'wgResourceLoaderSources' => array(),
32 'wgScriptPath' => '/w',
33 'wgScriptExtension' => '.php',
34 'wgScript' => '/w/index.php',
35 'wgLoadScript' => '/w/load.php',
42 class ResourceLoaderTestModule
extends ResourceLoaderModule
{
43 protected $dependencies = array();
44 protected $group = null;
45 protected $source = 'local';
46 protected $script = '';
47 protected $styles = '';
48 protected $skipFunction = null;
49 protected $isRaw = false;
50 protected $targets = array( 'test' );
52 public function __construct( $options = array() ) {
53 foreach ( $options as $key => $value ) {
58 public function getScript( ResourceLoaderContext
$context ) {
62 public function getStyles( ResourceLoaderContext
$context ) {
63 return array( '' => $this->styles
);
66 public function getDependencies() {
67 return $this->dependencies
;
70 public function getGroup() {
74 public function getSource() {
78 public function getSkipFunction() {
79 return $this->skipFunction
;
82 public function isRaw() {
87 class ResourceLoaderFileModuleTestModule
extends ResourceLoaderFileModule
{
90 class ResourceLoaderWikiModuleTestModule
extends ResourceLoaderWikiModule
{
91 // Override expected via PHPUnit mocks and stubs
92 protected function getPages( ResourceLoaderContext
$context ) {