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