MediaWiki REL1_33
CategoryMembershipChangeJobTest.php
Go to the documentation of this file.
1<?php
2
13
14 const TITLE_STRING = 'UTCatChangeJobPage';
15
19 private $title;
20
21 public function setUp() {
22 parent::setUp();
23 $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
24 $this->setContentLang( 'qqx' );
25 }
26
27 public function addDBDataOnce() {
28 parent::addDBDataOnce();
29 $insertResult = $this->insertPage( self::TITLE_STRING, 'UT Content' );
30 $this->title = $insertResult['title'];
31 }
32
33 private function runJobs() {
34 JobQueueGroup::destroySingletons();
35 $jobs = new RunJobs;
36 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
37 $jobs->execute();
38 }
39
45 private function editPageText( $text ) {
46 $page = WikiPage::factory( $this->title );
47 $editResult = $page->doEditContent(
48 ContentHandler::makeContent( $text, $this->title ),
49 __METHOD__
50 );
52 $revision = $editResult->value['revision'];
53 $this->runJobs();
54
55 return $revision->getId();
56 }
57
63 private function getCategorizeRecentChangeForRevId( $revId ) {
64 $rc = RecentChange::newFromConds(
65 [
66 'rc_type' => RC_CATEGORIZE,
67 'rc_this_oldid' => $revId,
68 ],
69 __METHOD__
70 );
71
72 $this->assertNotNull( $rc, 'rev__id = ' . $revId );
73 return $rc;
74 }
75
77 $addedRevId = $this->editPageText( '[[Category:Normal]]' );
78 $removedRevId = $this->editPageText( 'Blank' );
79
80 $this->assertEquals(
81 '(recentchanges-page-added-to-category: ' . self::TITLE_STRING . ')',
82 $this->getCategorizeRecentChangeForRevId( $addedRevId )->getAttribute( 'rc_comment' )
83 );
84 $this->assertEquals(
85 '(recentchanges-page-removed-from-category: ' . self::TITLE_STRING . ')',
86 $this->getCategorizeRecentChangeForRevId( $removedRevId )->getAttribute( 'rc_comment' )
87 );
88 }
89
90}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
loadParamsAndArgs( $self=null, $opts=null, $args=null)
Process command line arguments $mOptions becomes an array with keys set to the option names $mArgs be...
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
insertPage( $pageName, $text='Sample page for unit test.', $namespace=null, User $user=null)
Insert a new page.
Maintenance script that runs pending jobs.
Definition runJobs.php:36
Represents a title within MediaWiki.
Definition Title.php:40
const RC_CATEGORIZE
Definition Defines.php:155
title