4 * @covers EnhancedChangesList
9 * @author Katie Filbert < aude.wiki@gmail.com >
11 class EnhancedChangesListTest
extends MediaWikiLangTestCase
{
14 * @var TestRecentChangesHelper
16 private $testRecentChangesHelper;
18 public function __construct( $name = null, array $data = array(), $dataName = '' ) {
19 parent
::__construct( $name, $data, $dataName );
21 $this->testRecentChangesHelper
= new TestRecentChangesHelper();
24 public function testBeginRecentChangesList_styleModules() {
25 $enhancedChangesList = $this->newEnhancedChangesList();
26 $enhancedChangesList->beginRecentChangesList();
28 $styleModules = $enhancedChangesList->getOutput()->getModuleStyles();
30 $this->assertContains(
31 'mediawiki.special.changeslist',
33 'has mediawiki.special.changeslist'
36 $this->assertContains(
37 'mediawiki.special.changeslist.enhanced',
39 'has mediawiki.special.changeslist.enhanced'
43 public function testBeginRecentChangesList_jsModules() {
44 $enhancedChangesList = $this->newEnhancedChangesList();
45 $enhancedChangesList->beginRecentChangesList();
47 $modules = $enhancedChangesList->getOutput()->getModules();
49 $this->assertContains( 'jquery.makeCollapsible', $modules, 'has jquery.makeCollapsible' );
50 $this->assertContains( 'mediawiki.icon', $modules, 'has mediawiki.icon' );
53 public function testBeginRecentChangesList_html() {
54 $enhancedChangesList = $this->newEnhancedChangesList();
55 $html = $enhancedChangesList->beginRecentChangesList();
57 $this->assertEquals( '<div class="mw-changeslist">', $html );
63 public function testRecentChangesLine() {
64 $enhancedChangesList = $this->newEnhancedChangesList();
65 $enhancedChangesList->beginRecentChangesList();
67 $recentChange = $this->getEditChange( '20131103092153' );
68 $html = $enhancedChangesList->recentChangesLine( $recentChange, false );
70 $this->assertInternalType( 'string', $html );
72 $recentChange2 = $this->getEditChange( '20131103092253' );
73 $html = $enhancedChangesList->recentChangesLine( $recentChange2, false );
75 $this->assertEquals( '', $html );
79 * @todo more tests for actual formatting, this is more of a smoke test
81 public function testEndRecentChangesList() {
82 $enhancedChangesList = $this->newEnhancedChangesList();
83 $enhancedChangesList->beginRecentChangesList();
85 $recentChange = $this->getEditChange( '20131103092153' );
86 $enhancedChangesList->recentChangesLine( $recentChange, false );
88 $recentChange2 = $this->getEditChange( '20131103092253' );
89 $enhancedChangesList->recentChangesLine( $recentChange2, false );
91 $html = $enhancedChangesList->endRecentChangesList();
93 preg_match_all( '/td class="mw-enhanced-rc-nested"/', $html, $matches );
94 $this->assertCount( 2, $matches[0] );
98 * @return EnhancedChangesList
100 private function newEnhancedChangesList() {
101 $user = User
::newFromId( 0 );
102 $context = $this->testRecentChangesHelper
->getTestContext( $user );
104 return new EnhancedChangesList( $context );
108 * @return RecentChange
110 private function getEditChange( $timestamp ) {
111 $user = $this->getTestUser();
112 $recentChange = $this->testRecentChangesHelper
->makeEditRecentChange(
113 $user, 'Cat', $timestamp, 5, 191, 190, 0, 0
116 return $recentChange;
122 private function getTestUser() {
123 $user = User
::newFromName( 'TestRecentChangesUser' );
125 if ( !$user->getId() ) {
126 $user->addToDatabase();