3 abstract class ResourceLoaderTestCase
extends MediaWikiTestCase
{
7 * @return ResourceLoaderContext
9 protected function getResourceLoaderContext( $lang = 'en', $dir = 'ltr' ) {
10 $resourceLoader = new ResourceLoader();
11 $request = new FauxRequest( [
13 'modules' => 'startup',
16 'target' => 'phpunit',
18 $ctx = $this->getMockBuilder( 'ResourceLoaderContext' )
19 ->setConstructorArgs( [ $resourceLoader, $request ] )
20 ->setMethods( [ 'getDirection' ] )
22 $ctx->expects( $this->any() )->method( 'getDirection' )->will(
23 $this->returnValue( $dir )
28 public static function getSettings() {
30 // For ResourceLoader::inDebugMode since it doesn't have context
31 'ResourceLoaderDebug' => true,
33 // For ResourceLoaderContext::newDummyContext()
34 'DefaultSkin' => 'vector',
36 // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
37 'CacheEpoch' => '20140101000000',
39 // For ResourceLoader::__construct()
40 'ResourceLoaderSources' => [],
44 'ScriptExtension' => '.php',
45 'Script' => '/w/index.php',
46 'LoadScript' => '/w/load.php',
50 protected function setUp() {
53 ResourceLoader
::clearCache();
56 foreach ( self
::getSettings() as $key => $value ) {
57 $globals['wg' . $key] = $value;
59 $this->setMwGlobals( $globals );
65 class ResourceLoaderTestModule
extends ResourceLoaderModule
{
66 protected $messages = [];
67 protected $dependencies = [];
68 protected $group = null;
69 protected $source = 'local';
70 protected $script = '';
71 protected $styles = '';
72 protected $skipFunction = null;
73 protected $isRaw = false;
74 protected $targets = [ 'phpunit' ];
76 public function __construct( $options = [] ) {
77 foreach ( $options as $key => $value ) {
82 public function getScript( ResourceLoaderContext
$context ) {
83 return $this->validateScriptFile( 'input', $this->script
);
86 public function getStyles( ResourceLoaderContext
$context ) {
87 return [ '' => $this->styles
];
90 public function getMessages() {
91 return $this->messages
;
94 public function getDependencies( ResourceLoaderContext
$context = null ) {
95 return $this->dependencies
;
98 public function getGroup() {
102 public function getSource() {
103 return $this->source
;
106 public function getSkipFunction() {
107 return $this->skipFunction
;
110 public function isRaw() {
114 public function enableModuleContentVersion() {
119 class ResourceLoaderFileModuleTestModule
extends ResourceLoaderFileModule
{