2015-03-27 17:08:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @group ResourceLoader
|
|
|
|
|
*/
|
|
|
|
|
class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase {
|
|
|
|
|
|
2015-03-29 17:53:47 +00:00
|
|
|
public static $commonImageData = array(
|
|
|
|
|
'add' => 'add.gif',
|
|
|
|
|
'remove' => array(
|
|
|
|
|
'file' => 'remove.svg',
|
|
|
|
|
'variants' => array( 'destructive' ),
|
|
|
|
|
),
|
|
|
|
|
'next' => array(
|
|
|
|
|
'file' => array(
|
|
|
|
|
'ltr' => 'next.svg',
|
|
|
|
|
'rtl' => 'prev.svg'
|
2015-03-27 17:08:11 +00:00
|
|
|
),
|
2015-03-29 17:53:47 +00:00
|
|
|
),
|
|
|
|
|
'help' => array(
|
|
|
|
|
'file' => array(
|
|
|
|
|
'ltr' => 'help-ltr.svg',
|
|
|
|
|
'rtl' => 'help-rtl.svg',
|
|
|
|
|
'lang' => array(
|
|
|
|
|
'he' => 'help-ltr.svg',
|
|
|
|
|
)
|
2015-03-27 17:08:11 +00:00
|
|
|
),
|
2015-03-29 17:53:47 +00:00
|
|
|
),
|
|
|
|
|
'bold' => array(
|
|
|
|
|
'file' => array(
|
|
|
|
|
'default' => 'bold-a.svg',
|
|
|
|
|
'lang' => array(
|
|
|
|
|
'en' => 'bold-b.svg',
|
2015-04-02 17:54:07 +00:00
|
|
|
'ar,de' => 'bold-f.svg',
|
2015-03-29 17:53:47 +00:00
|
|
|
)
|
2015-03-27 17:08:11 +00:00
|
|
|
),
|
2015-03-29 17:53:47 +00:00
|
|
|
)
|
|
|
|
|
);
|
2015-03-27 17:08:11 +00:00
|
|
|
|
2015-03-29 17:53:47 +00:00
|
|
|
public static $commonImageVariants = array(
|
|
|
|
|
'invert' => array(
|
|
|
|
|
'color' => '#FFFFFF',
|
|
|
|
|
'global' => true,
|
|
|
|
|
),
|
|
|
|
|
'primary' => array(
|
|
|
|
|
'color' => '#598AD1',
|
|
|
|
|
),
|
|
|
|
|
'constructive' => array(
|
|
|
|
|
'color' => '#00C697',
|
|
|
|
|
),
|
|
|
|
|
'destructive' => array(
|
|
|
|
|
'color' => '#E81915',
|
|
|
|
|
),
|
|
|
|
|
);
|
2015-03-27 17:08:11 +00:00
|
|
|
|
2015-03-29 17:53:47 +00:00
|
|
|
public static function providerGetModules() {
|
2015-03-27 17:08:11 +00:00
|
|
|
return array(
|
|
|
|
|
array(
|
|
|
|
|
array(
|
|
|
|
|
'class' => 'ResourceLoaderImageModule',
|
2015-03-27 17:27:47 +00:00
|
|
|
'prefix' => 'oo-ui-icon',
|
2015-03-29 17:53:47 +00:00
|
|
|
'variants' => self::$commonImageVariants,
|
|
|
|
|
'images' => self::$commonImageData,
|
2015-03-27 17:08:11 +00:00
|
|
|
),
|
2015-03-29 17:53:47 +00:00
|
|
|
'.oo-ui-icon-add {
|
2015-03-27 17:08:11 +00:00
|
|
|
...
|
|
|
|
|
}
|
2015-03-29 17:53:47 +00:00
|
|
|
.oo-ui-icon-add-invert {
|
2015-03-27 17:08:11 +00:00
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-remove {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-remove-invert {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-remove-destructive {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-next {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-next-invert {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-help {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-help-invert {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-bold {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.oo-ui-icon-bold-invert {
|
|
|
|
|
...
|
2015-03-23 21:04:54 +00:00
|
|
|
}',
|
|
|
|
|
),
|
|
|
|
|
array(
|
|
|
|
|
array(
|
|
|
|
|
'class' => 'ResourceLoaderImageModule',
|
|
|
|
|
'selectorWithoutVariant' => '.mw-ui-icon-{name}:after, .mw-ui-icon-{name}:before',
|
2015-09-26 19:48:17 +00:00
|
|
|
'selectorWithVariant' =>
|
|
|
|
|
'.mw-ui-icon-{name}-{variant}:after, .mw-ui-icon-{name}-{variant}:before',
|
2015-03-29 17:53:47 +00:00
|
|
|
'variants' => self::$commonImageVariants,
|
|
|
|
|
'images' => self::$commonImageData,
|
2015-03-23 21:04:54 +00:00
|
|
|
),
|
2015-03-29 17:53:47 +00:00
|
|
|
'.mw-ui-icon-add:after, .mw-ui-icon-add:before {
|
2015-03-23 21:04:54 +00:00
|
|
|
...
|
|
|
|
|
}
|
2015-03-29 17:53:47 +00:00
|
|
|
.mw-ui-icon-add-invert:after, .mw-ui-icon-add-invert:before {
|
2015-03-23 21:04:54 +00:00
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-remove:after, .mw-ui-icon-remove:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-remove-invert:after, .mw-ui-icon-remove-invert:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-remove-destructive:after, .mw-ui-icon-remove-destructive:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-next:after, .mw-ui-icon-next:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-next-invert:after, .mw-ui-icon-next-invert:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-help:after, .mw-ui-icon-help:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-help-invert:after, .mw-ui-icon-help-invert:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-bold:after, .mw-ui-icon-bold:before {
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
.mw-ui-icon-bold-invert:after, .mw-ui-icon-bold-invert:before {
|
|
|
|
|
...
|
2015-03-27 17:08:11 +00:00
|
|
|
}',
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providerGetModules
|
|
|
|
|
* @covers ResourceLoaderImageModule::getStyles
|
|
|
|
|
*/
|
|
|
|
|
public function testGetStyles( $module, $expected ) {
|
2015-09-26 19:48:17 +00:00
|
|
|
$module = new ResourceLoaderImageModuleTestable(
|
|
|
|
|
$module,
|
|
|
|
|
__DIR__ . '/../../data/resourceloader'
|
|
|
|
|
);
|
2015-03-27 17:08:11 +00:00
|
|
|
$styles = $module->getStyles( $this->getResourceLoaderContext() );
|
|
|
|
|
$this->assertEquals( $expected, $styles['all'] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceLoaderImageModuleTestable extends ResourceLoaderImageModule {
|
|
|
|
|
/**
|
|
|
|
|
* Replace with a stub to make test cases easier to write.
|
|
|
|
|
*/
|
|
|
|
|
protected function getCssDeclarations( $primary, $fallback ) {
|
|
|
|
|
return array( '...' );
|
|
|
|
|
}
|
|
|
|
|
}
|