test: Clean up data providers that should be static
[lhc/web/wiklou.git] / tests / phpunit / includes / resourceloader / ResourceLoaderWikiModuleTest.php
1 <?php
2
3 class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
4
5 /**
6 * @covers ResourceLoaderWikiModule::isKnownEmpty
7 * @dataProvider provideIsKnownEmpty
8 */
9 public function testIsKnownEmpty( $titleInfo, $group, $expected ) {
10 $module = $this->getMockBuilder( 'ResourceLoaderWikiModuleTestModule' )
11 ->setMethods( array( 'getTitleInfo', 'getGroup' ) )
12 ->getMock();
13 $module->expects( $this->any() )
14 ->method( 'getTitleInfo' )
15 ->will( $this->returnValue( $titleInfo ) );
16 $module->expects( $this->any() )
17 ->method( 'getGroup' )
18 ->will( $this->returnValue( $group ) );
19 $context = $this->getMockBuilder( 'ResourceLoaderContext' )
20 ->disableOriginalConstructor()
21 ->getMock();
22 $this->assertEquals( $expected, $module->isKnownEmpty( $context ) );
23 }
24
25 public static function provideIsKnownEmpty() {
26 return array(
27 // No valid pages
28 array( array(), 'test1', true ),
29 // 'site' module with a non-empty page
30 array(
31 array(
32 'MediaWiki:Common.js' => array(
33 'timestamp' => 123456789,
34 'length' => 1234
35 )
36 ), 'site', false,
37 ),
38 // 'site' module with an empty page
39 array(
40 array(
41 'MediaWiki:Monobook.js' => array(
42 'timestamp' => 987654321,
43 'length' => 0,
44 ),
45 ), 'site', false,
46 ),
47 // 'user' module with a non-empty page
48 array(
49 array(
50 'User:FooBar/common.js' => array(
51 'timestamp' => 246813579,
52 'length' => 25,
53 ),
54 ), 'user', false,
55 ),
56 // 'user' module with an empty page
57 array(
58 array(
59 'User:FooBar/monobook.js' => array(
60 'timestamp' => 1357924680,
61 'length' => 0,
62 ),
63 ), 'user', true,
64 ),
65 );
66 }
67 }