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( array(
13 'modules' => 'startup',
16 'target' => 'phpunit',
18 $ctx = $this->getMockBuilder( 'ResourceLoaderContext' )
19 ->setConstructorArgs( array( $resourceLoader, $request ) )
20 ->setMethods( array( '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 // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
34 'CacheEpoch' => '20140101000000',
36 // For ResourceLoader::__construct()
37 'ResourceLoaderSources' => array(),
41 'ScriptExtension' => '.php',
42 'Script' => '/w/index.php',
43 'LoadScript' => '/w/load.php',
47 protected function setUp() {
50 ResourceLoader
::clearCache();
53 foreach ( self
::getSettings() as $key => $value ) {
54 $globals['wg' . $key] = $value;
56 $this->setMwGlobals( $globals );
62 class ResourceLoaderTestModule
extends ResourceLoaderModule
{
63 protected $messages = array();
64 protected $dependencies = array();
65 protected $group = null;
66 protected $source = 'local';
67 protected $script = '';
68 protected $styles = '';
69 protected $skipFunction = null;
70 protected $isRaw = false;
71 protected $targets = array( 'phpunit' );
73 public function __construct( $options = array() ) {
74 foreach ( $options as $key => $value ) {
79 public function getScript( ResourceLoaderContext
$context ) {
80 return $this->validateScriptFile( 'input', $this->script
);
83 public function getStyles( ResourceLoaderContext
$context ) {
84 return array( '' => $this->styles
);
87 public function getMessages() {
88 return $this->messages
;
91 public function getDependencies( ResourceLoaderContext
$context = null ) {
92 return $this->dependencies
;
95 public function getGroup() {
99 public function getSource() {
100 return $this->source
;
103 public function getSkipFunction() {
104 return $this->skipFunction
;
107 public function isRaw() {
111 public function enableModuleContentVersion() {
116 class ResourceLoaderFileModuleTestModule
extends ResourceLoaderFileModule
{