4 * @covers CategoryMembershipChangeJob
12 class CategoryMembershipChangeJobTest
extends MediaWikiTestCase
{
14 const TITLE_STRING
= 'UTCatChangeJobPage';
21 public function setUp() {
23 $this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
24 $this->setContentLang( 'qqx' );
27 public function addDBDataOnce() {
28 parent
::addDBDataOnce();
29 $insertResult = $this->insertPage( self
::TITLE_STRING
, 'UT Content' );
30 $this->title
= $insertResult['title'];
33 private function runJobs() {
34 JobQueueGroup
::destroySingletons();
36 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
41 * @param string $text new page text
45 private function editPageText( $text ) {
46 $page = WikiPage
::factory( $this->title
);
47 $editResult = $page->doEditContent(
48 ContentHandler
::makeContent( $text, $this->title
),
51 /** @var Revision $revision */
52 $revision = $editResult->value
['revision'];
55 return $revision->getId();
61 * @return RecentChange|null
63 private function getCategorizeRecentChangeForRevId( $revId ) {
64 return RecentChange
::newFromConds(
66 'rc_type' => RC_CATEGORIZE
,
67 'rc_this_oldid' => $revId,
73 public function testRun_normalCategoryAddedAndRemoved() {
74 $addedRevId = $this->editPageText( '[[Category:Normal]]' );
75 $removedRevId = $this->editPageText( 'Blank' );
78 '(recentchanges-page-added-to-category: ' . self
::TITLE_STRING
. ')',
79 $this->getCategorizeRecentChangeForRevId( $addedRevId )->getAttribute( 'rc_comment' )
82 '(recentchanges-page-removed-from-category: ' . self
::TITLE_STRING
. ')',
83 $this->getCategorizeRecentChangeForRevId( $removedRevId )->getAttribute( 'rc_comment' )