Get rid of CSS transitions on form elements in mediawiki.ui
[mediawiki.git] / tests / phpunit / ResourceLoaderTestCase.php
blob325b20eec1b85ecbf26e12cb1d10cf4e36b70005
1 <?php
3 abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
4 /**
5 * @param string $lang
6 * @param string $dir
7 * @return ResourceLoaderContext
8 */
9 protected function getResourceLoaderContext( $lang = 'en', $dir = 'ltr' ) {
10 $resourceLoader = new ResourceLoader();
11 $request = new FauxRequest( array(
12 'lang' => $lang,
13 'modules' => 'startup',
14 'only' => 'scripts',
15 'skin' => 'vector',
16 'target' => 'test',
17 ) );
18 $ctx = $this->getMockBuilder( 'ResourceLoaderContext' )
19 ->setConstructorArgs( array( $resourceLoader, $request ) )
20 ->setMethods( array( 'getDirection' ) )
21 ->getMock();
22 $ctx->expects( $this->any() )->method( 'getDirection' )->will(
23 $this->returnValue( $dir )
25 return $ctx;
28 public static function getSettings() {
29 return array(
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(),
39 // For wfScript()
40 'ScriptPath' => '/w',
41 'ScriptExtension' => '.php',
42 'Script' => '/w/index.php',
43 'LoadScript' => '/w/load.php',
47 protected function setUp() {
48 parent::setUp();
50 ResourceLoader::clearCache();
52 $globals = array();
53 foreach ( self::getSettings() as $key => $value ) {
54 $globals['wg' . $key] = $value;
56 $this->setMwGlobals( $globals );
60 /* Stubs */
62 class ResourceLoaderTestModule extends ResourceLoaderModule {
63 protected $dependencies = array();
64 protected $group = null;
65 protected $source = 'local';
66 protected $script = '';
67 protected $styles = '';
68 protected $skipFunction = null;
69 protected $isRaw = false;
70 protected $targets = array( 'test' );
72 public function __construct( $options = array() ) {
73 foreach ( $options as $key => $value ) {
74 $this->$key = $value;
78 public function getScript( ResourceLoaderContext $context ) {
79 return $this->validateScriptFile( 'input', $this->script );
82 public function getStyles( ResourceLoaderContext $context ) {
83 return array( '' => $this->styles );
86 public function getDependencies( ResourceLoaderContext $context = null ) {
87 return $this->dependencies;
90 public function getGroup() {
91 return $this->group;
94 public function getSource() {
95 return $this->source;
98 public function getSkipFunction() {
99 return $this->skipFunction;
102 public function isRaw() {
103 return $this->isRaw;
106 public function enableModuleContentVersion() {
107 return true;
111 class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {