<?php
+use MediaWiki\MediaWikiServices;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
const BLANK_VERSION = '09p30q0';
/**
- * @param string $lang
- * @param string $dir
+ * @param array|string $options Language code or options array
+ * - string 'lang' Language code
+ * - string 'dir' Language direction (ltr or rtl)
* @return ResourceLoaderContext
*/
- protected function getResourceLoaderContext( $lang = 'en', $dir = 'ltr' ) {
+ protected function getResourceLoaderContext( $options = [] ) {
+ if ( is_string( $options ) ) {
+ // Back-compat for extension tests
+ $options = [ 'lang' => $options ];
+ }
+ $options += [
+ 'lang' => 'en',
+ 'dir' => 'ltr',
+ ];
$resourceLoader = new ResourceLoader();
$request = new FauxRequest( [
- 'lang' => $lang,
+ 'lang' => $options['lang'],
'modules' => 'startup',
'only' => 'scripts',
'skin' => 'vector',
->setConstructorArgs( [ $resourceLoader, $request ] )
->setMethods( [ 'getDirection' ] )
->getMock();
- $ctx->method( 'getDirection' )->willReturn( $dir );
+ $ctx->method( 'getDirection' )->willReturn( $options['dir'] );
return $ctx;
}
// and default registrations are done from ServiceWiring instead.
public function __construct( Config $config = null, LoggerInterface $logger = null ) {
$this->setLogger( $logger ?: new NullLogger() );
- $this->config = $config ?: ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+ $this->config = $config ?: MediaWikiServices::getInstance()->getMainConfig();
$this->setMessageBlobStore( new MessageBlobStore( $this, $this->getLogger() ) );
}
}