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',
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 protected function setUp() {
31 ResourceLoader
::clearCache();
33 $this->setMwGlobals( array(
34 // For ResourceLoader::inDebugMode since it doesn't have context
35 'wgResourceLoaderDebug' => true,
37 // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
38 'wgCacheEpoch' => '20140101000000',
40 // For ResourceLoader::__construct()
41 'wgResourceLoaderSources' => array(),
44 'wgScriptPath' => '/w',
45 'wgScriptExtension' => '.php',
46 'wgScript' => '/w/index.php',
47 'wgLoadScript' => '/w/load.php',
54 class ResourceLoaderTestModule
extends ResourceLoaderModule
{
55 protected $dependencies = array();
56 protected $group = null;
57 protected $source = 'local';
58 protected $script = '';
59 protected $styles = '';
60 protected $skipFunction = null;
61 protected $isRaw = false;
62 protected $targets = array( 'test' );
64 public function __construct( $options = array() ) {
65 foreach ( $options as $key => $value ) {
70 public function getScript( ResourceLoaderContext
$context ) {
74 public function getStyles( ResourceLoaderContext
$context ) {
75 return array( '' => $this->styles
);
78 public function getDependencies() {
79 return $this->dependencies
;
82 public function getGroup() {
86 public function getSource() {
90 public function getSkipFunction() {
91 return $this->skipFunction
;
94 public function isRaw() {
99 class ResourceLoaderFileModuleTestModule
extends ResourceLoaderFileModule
{
102 class ResourceLoaderWikiModuleTestModule
extends ResourceLoaderWikiModule
{
103 // Override expected via PHPUnit mocks and stubs
104 protected function getPages( ResourceLoaderContext
$context ) {