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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
<?php
/**
* @covers EnhancedChangesList
*
* @group Database
*
* @author Katie Filbert < aude.wiki@gmail.com >
*/
class EnhancedChangesListTest extends MediaWikiLangTestCase {
/**
* @var TestRecentChangesHelper
*/
private $testRecentChangesHelper;
public function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
$this->testRecentChangesHelper = new TestRecentChangesHelper();
}
public function testBeginRecentChangesList_styleModules() {
$enhancedChangesList = $this->newEnhancedChangesList();
$enhancedChangesList->beginRecentChangesList();
$styleModules = $enhancedChangesList->getOutput()->getModuleStyles();
$this->assertContains(
'mediawiki.special.changeslist',
$styleModules,
'has mediawiki.special.changeslist'
);
$this->assertContains(
'mediawiki.special.changeslist.enhanced',
$styleModules,
'has mediawiki.special.changeslist.enhanced'
);
}
public function testBeginRecentChangesList_jsModules() {
$enhancedChangesList = $this->newEnhancedChangesList();
$enhancedChangesList->beginRecentChangesList();
$modules = $enhancedChangesList->getOutput()->getModules();
$this->assertContains( 'jquery.makeCollapsible', $modules, 'has jquery.makeCollapsible' );
$this->assertContains( 'mediawiki.icon', $modules, 'has mediawiki.icon' );
}
public function testBeginRecentChangesList_html() {
$enhancedChangesList = $this->newEnhancedChangesList();
$html = $enhancedChangesList->beginRecentChangesList();
$this->assertEquals( '<div class="mw-changeslist">', $html );
}
/**
* @todo more tests
*/
public function testRecentChangesLine() {
$enhancedChangesList = $this->newEnhancedChangesList();
$enhancedChangesList->beginRecentChangesList();
$recentChange = $this->getEditChange( '20131103092153' );
$html = $enhancedChangesList->recentChangesLine( $recentChange, false );
$this->assertInternalType( 'string', $html );
$recentChange2 = $this->getEditChange( '20131103092253' );
$html = $enhancedChangesList->recentChangesLine( $recentChange2, false );
$this->assertEquals( '', $html );
}
/**
* @todo more tests for actual formatting, this is more of a smoke test
*/
public function testEndRecentChangesList() {
$enhancedChangesList = $this->newEnhancedChangesList();
$enhancedChangesList->beginRecentChangesList();
$recentChange = $this->getEditChange( '20131103092153' );
$enhancedChangesList->recentChangesLine( $recentChange, false );
$recentChange2 = $this->getEditChange( '20131103092253' );
$enhancedChangesList->recentChangesLine( $recentChange2, false );
$html = $enhancedChangesList->endRecentChangesList();
preg_match_all( '/td class="mw-enhanced-rc-nested"/', $html, $matches );
$this->assertCount( 2, $matches[0] );
}
/**
* @return EnhancedChangesList
*/
private function newEnhancedChangesList() {
$user = User::newFromId( 0 );
$context = $this->testRecentChangesHelper->getTestContext( $user );
return new EnhancedChangesList( $context );
}
/**
* @return RecentChange
*/
private function getEditChange( $timestamp ) {
$user = $this->getTestUser();
$recentChange = $this->testRecentChangesHelper->makeEditRecentChange(
$user, 'Cat', $timestamp, 5, 191, 190, 0, 0
);
return $recentChange;
}
/**
* @return User
*/
private function getTestUser() {
$user = User::newFromName( 'TestRecentChangesUser' );
if ( !$user->getId() ) {
$user->addToDatabase();
}
return $user;
}
}
|