Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / resourceloader / ResourceLoaderWikiModuleTest.php
blob9dc180506fd66619f2d1b1eb110efb25ec9dd32e
1 <?php
3 class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
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 ) );
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
36 ), 'site', false,
38 // 'site' module with an empty page
39 array(
40 array(
41 'MediaWiki:Monobook.js' => array(
42 'timestamp' => 987654321,
43 'length' => 0,
45 ), 'site', false,
47 // 'user' module with a non-empty page
48 array(
49 array(
50 'User:FooBar/common.js' => array(
51 'timestamp' => 246813579,
52 'length' => 25,
54 ), 'user', false,
56 // 'user' module with an empty page
57 array(
58 array(
59 'User:FooBar/monobook.js' => array(
60 'timestamp' => 1357924680,
61 'length' => 0,
63 ), 'user', true,