X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FResourceLoaderTestCase.php;h=a8a8f4d7302e57ee0f15f0099a7557794feaa9f8;hb=fd9c94d971dfac73f0ea5865a3df80e69cf71ea7;hp=45cfdbfc612d35f6e3636e1d510072969f115a6d;hpb=950b3f960aea995ab7c95b01519866a2a1c923ab;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/ResourceLoaderTestCase.php b/tests/phpunit/ResourceLoaderTestCase.php index 45cfdbfc61..a8a8f4d730 100644 --- a/tests/phpunit/ResourceLoaderTestCase.php +++ b/tests/phpunit/ResourceLoaderTestCase.php @@ -14,9 +14,12 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase { * @param array|string $options Language code or options array * - string 'lang' Language code * - string 'dir' Language direction (ltr or rtl) + * - string 'modules' Pipe-separated list of module names + * - string|null 'only' "scripts" (unwrapped script), "styles" (stylesheet), or null + * (mw.loader.implement). * @return ResourceLoaderContext */ - protected function getResourceLoaderContext( $options = [] ) { + protected function getResourceLoaderContext( $options = [], ResourceLoader $rl = null ) { if ( is_string( $options ) ) { // Back-compat for extension tests $options = [ 'lang' => $options ]; @@ -24,13 +27,16 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase { $options += [ 'lang' => 'en', 'dir' => 'ltr', + 'skin' => 'vector', + 'modules' => 'startup', + 'only' => 'scripts', ]; - $resourceLoader = new ResourceLoader(); + $resourceLoader = $rl ?: new ResourceLoader(); $request = new FauxRequest( [ 'lang' => $options['lang'], - 'modules' => 'startup', - 'only' => 'scripts', - 'skin' => 'vector', + 'modules' => $options['modules'], + 'only' => $options['only'], + 'skin' => $options['skin'], 'target' => 'phpunit', ] ); $ctx = $this->getMockBuilder( 'ResourceLoaderContext' ) @@ -151,6 +157,12 @@ class EmptyResourceLoader extends ResourceLoader { public function __construct( Config $config = null, LoggerInterface $logger = null ) { $this->setLogger( $logger ?: new NullLogger() ); $this->config = $config ?: MediaWikiServices::getInstance()->getMainConfig(); + // Source "local" is required by StartupModule + $this->addSource( 'local', $this->config->get( 'LoadScript' ) ); $this->setMessageBlobStore( new MessageBlobStore( $this, $this->getLogger() ) ); } + + public function getErrors() { + return $this->errors; + } }