3 class ResourceLoaderWikiModuleTest
extends ResourceLoaderTestCase
{
6 * @covers ResourceLoaderWikiModule::__construct
7 * @dataProvider provideConstructor
9 public function testConstructor( $params ) {
10 $module = new ResourceLoaderWikiModule( $params );
11 $this->assertInstanceOf( 'ResourceLoaderWikiModule', $module );
14 public static function provideConstructor() {
19 // Unrecognized settings
20 array( array( 'foo' => 'baz' ) ),
22 array( array( 'scripts' => array( 'MediaWiki:Common.js' ) ) ),
27 * @dataProvider provideGetPages
28 * @covers ResourceLoaderWikiModule::getPages
30 public function testGetPages( $params, Config
$config, $expected ) {
31 $module = new ResourceLoaderWikiModule( $params );
32 $module->setConfig( $config );
34 // Use getDefinitionSummary because getPages is protected
35 $summary = $module->getDefinitionSummary( ResourceLoaderContext
::newDummyContext() );
42 public static function provideGetPages() {
49 'styles' => array( 'MediaWiki:Common.css' ),
50 'scripts' => array( 'MediaWiki:Common.js' ),
54 array( array(), new HashConfig( $settings ), array() ),
55 array( $params, new HashConfig( $settings ), array(
56 'MediaWiki:Common.js' => array( 'type' => 'script' ),
57 'MediaWiki:Common.css' => array( 'type' => 'style' )
59 array( $params, new HashConfig( array( 'UseSiteCss' => false ) +
$settings ), array(
60 'MediaWiki:Common.js' => array( 'type' => 'script' ),
62 array( $params, new HashConfig( array( 'UseSiteJs' => false ) +
$settings ), array(
63 'MediaWiki:Common.css' => array( 'type' => 'style' ),
65 array( $params, new HashConfig( array( 'UseSiteJs' => false, 'UseSiteCss' => false ) ), array() ),
70 * @covers ResourceLoaderWikiModule::getGroup
71 * @dataProvider provideGetGroup
73 public function testGetGroup( $params, $expected ) {
74 $module = new ResourceLoaderWikiModule( $params );
75 $this->assertEquals( $expected, $module->getGroup() );
78 public static function provideGetGroup() {
81 array( array(), null ),
83 array( array( 'group' => 'foobar' ), 'foobar' ),
88 * @covers ResourceLoaderWikiModule::isKnownEmpty
89 * @dataProvider provideIsKnownEmpty
91 public function testIsKnownEmpty( $titleInfo, $group, $expected ) {
92 $module = $this->getMockBuilder( 'ResourceLoaderWikiModule' )
93 ->setMethods( array( 'getTitleInfo', 'getGroup' ) )
95 $module->expects( $this->any() )
96 ->method( 'getTitleInfo' )
97 ->will( $this->returnValue( $titleInfo ) );
98 $module->expects( $this->any() )
99 ->method( 'getGroup' )
100 ->will( $this->returnValue( $group ) );
101 $context = $this->getMockBuilder( 'ResourceLoaderContext' )
102 ->disableOriginalConstructor()
104 $this->assertEquals( $expected, $module->isKnownEmpty( $context ) );
107 public static function provideIsKnownEmpty() {
110 array( array(), 'test1', true ),
111 // 'site' module with a non-empty page
114 'MediaWiki:Common.js' => array(
115 'timestamp' => 123456789,
120 // 'site' module with an empty page
123 'MediaWiki:Monobook.js' => array(
124 'timestamp' => 987654321,
129 // 'user' module with a non-empty page
132 'User:FooBar/common.js' => array(
133 'timestamp' => 246813579,
138 // 'user' module with an empty page
141 'User:FooBar/monobook.js' => array(
142 'timestamp' => 1357924680,