protected $revisionsMerged;
/**
- * MergeHistory constructor.
* @param Title $source Page from which history will be merged
* @param Title $dest Page to which history will be merged
* @param string|bool $timestamp Timestamp up to which history from the source will be merged
protected $params;
/**
- * Constructor.
- *
* @param string $global Name of the global variable.
* @param string|callable $class Name of the class of the real object
* or a factory function to call
}
/**
- * Constructor.
- *
* Only public since 1.21
*
* @param Page $page
protected $caller;
/**
- * LinkBatch constructor.
* @param LinkTarget[] $arr Initial items to be added to the batch
*/
public function __construct( $arr = [] ) {
private $mergeableKeys = null;
/**
- * Constructor.
* For constructor parameters, see the documentation in DefaultSettings.php
* for $wgLocalisationCacheConf.
*
];
/**
- * WikiTextStructure constructor.
* @param ParserOutput $parserOutput
*/
public function __construct( ParserOutput $parserOutput ) {
protected $bailoutComplexity = 0;
/**
- * Constructor.
* Computes diff between sequences of strings.
*
* @param string[] $from_lines An array of strings.
}
/**
- * Constructor.
* Do not call this except from inside a repo class.
* @param Title $title
* @param FileRepo $repo
];
/**
- * Constructor.
- *
* @param string $siteName
* @param string $admin
* @param array $option
protected $installer;
/**
- * Constructor.
- *
* @param Installer $installer
*/
public function __construct( Installer $installer ) {
protected $currentPageName;
/**
- * Constructor.
- *
* @param WebRequest $request
*/
public function __construct( WebRequest $request ) {
}
/**
- * Constructor.
* @see ArrayObject::__construct
*
* @since 1.20
private $callableName;
/**
- * Constructor.
- *
* @throws InvalidArgumentException if $callable is not a callable.
* @param callable $callable Function or method to memoize.
* @param int $ttl TTL in seconds. Defaults to 3600 (1hr). Capped at 86400 (24h).
private $logger;
/**
- * Constructor.
- *
* Primary job is to initialize the XMLParser
*/
function __construct( LoggerInterface $logger = null ) {
protected $legacy = false;
/**
- * Constructor.
- *
* @since 1.19
* @param string $type
* @param string $subtype
private $linkRenderer;
/**
- * Constructor.
* The first two parameters used to be $skin and $out, but now only a context
* is needed, that's why there's a second unused parameter.
*
public function getStyles( ResourceLoaderContext $context ) {
$logo = $this->getLogo( $this->getConfig() );
$styles = parent::getStyles( $context );
+ $this->normalizeStyles( $styles );
$default = !is_array( $logo ) ? $logo : $logo['1x'];
$styles['all'][] = '.mw-wiki-logo { background-image: ' .
return $styles;
}
+ /**
+ * Ensure all media keys use array values.
+ *
+ * Normalises arrays returned by the ResourceLoaderFileModule::getStyles() method.
+ *
+ * @param array &$styles Associative array, keys are strings (media queries),
+ * values are strings or arrays
+ */
+ private function normalizeStyles( &$styles ) {
+ foreach ( $styles as $key => $val ) {
+ if ( !is_array( $val ) ) {
+ $styles[$key] = [ $val ];
+ }
+ }
+ }
+
/**
* @param Config $conf
* @return string|array Single url if no variants are defined
private $rowAugmentor;
/**
- * PerRowAugmentor constructor.
* @param ResultAugmentor $augmentor Per-result augmentor to use.
*/
public function __construct( ResultAugmentor $augmentor ) {
private $mergeCallback;
/**
- * SearchIndexFieldDefinition constructor.
* @param string $name Field name
* @param int $type Index type
*/
const PATH_PAGE = 'page_path';
/**
- * Constructor.
- *
* @since 1.21
*
* @param string $type
protected $internalId = null;
/**
- * Constructor.
- *
* @since 1.21
*
* @param string $type
class UserRightsProxy {
/**
- * Constructor.
- *
* @see newFromId()
* @see newFromName()
* @param IDatabase $db Db connection
/** @var FileContentsHasher */
private static $instance;
- /**
- * Constructor.
- */
public function __construct() {
$this->cache = ObjectCache::getLocalServerInstance( 'hash' );
}
--- /dev/null
+<?php
+
+/**
+ * @group Database
+ * @group ResourceLoader
+ */
+class ResourceLoaderSkinModuleTest extends PHPUnit_Framework_TestCase {
+
+ public static function provideGetStyles() {
+ return [
+ [
+ 'parent' => [],
+ 'expected' => [
+ 'all' => [ '.mw-wiki-logo { background-image: url(/logo.png); }' ],
+ ],
+ ],
+ [
+ 'parent' => [
+ 'screen' => '.example {}',
+ ],
+ 'expected' => [
+ 'screen' => [ '.example {}' ],
+ 'all' => [ '.mw-wiki-logo { background-image: url(/logo.png); }' ],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideGetStyles
+ * @covers ResourceLoaderSkinModule::normalizeStyles
+ * @covers ResourceLoaderSkinModule::getStyles
+ */
+ public function testGetStyles( $parent, $expected ) {
+ $module = $this->getMockBuilder( ResourceLoaderSkinModule::class )
+ ->disableOriginalConstructor()
+ ->setMethods( [ 'readStyleFiles' ] )
+ ->getMock();
+ $module->expects( $this->once() )->method( 'readStyleFiles' )
+ ->willReturn( $parent );
+ $module->setConfig( new HashConfig( [
+ 'ResourceBasePath' => '/w',
+ 'Logo' => '/logo.png',
+ 'LogoHD' => false,
+ ] ) );
+
+ $ctx = $this->getMockBuilder( ResourceLoaderContext::class )
+ ->disableOriginalConstructor()->getMock();
+
+ $this->assertEquals(
+ $module->getStyles( $ctx ),
+ $expected
+ );
+ }
+
+ /**
+ * @covers ResourceLoaderSkinModule::isKnownEmpty
+ */
+ public function testIsKnownEmpty() {
+ $module = $this->getMockBuilder( ResourceLoaderSkinModule::class )
+ ->disableOriginalConstructor()->setMethods( null )->getMock();
+ $ctx = $this->getMockBuilder( ResourceLoaderContext::class )
+ ->disableOriginalConstructor()->getMock();
+
+ $this->assertFalse( $module->isKnownEmpty( $ctx ) );
+ }
+}