Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / tests / phpunit / includes / jobqueue / jobs / CategoryMembershipChangeJobTest.php
blob656be381dd794a36f9d8a752ba23d34557d439bf
1 <?php
3 /**
4 * @covers CategoryMembershipChangeJob
6 * @group JobQueue
7 * @group Database
9 * @licence GNU GPL v2+
10 * @author Addshore
12 class CategoryMembershipChangeJobTest extends MediaWikiTestCase {
14 const TITLE_STRING = 'UTCatChangeJobPage';
16 /**
17 * @var Title
19 private $title;
21 public function setUp() {
22 parent::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();
35 $jobs = new RunJobs;
36 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
37 $jobs->execute();
40 /**
41 * @param string $text new page text
43 * @return int|null
45 private function editPageText( $text ) {
46 $page = WikiPage::factory( $this->title );
47 $editResult = $page->doEditContent(
48 ContentHandler::makeContent( $text, $this->title ),
49 __METHOD__
51 /** @var Revision $revision */
52 $revision = $editResult->value['revision'];
53 $this->runJobs();
55 return $revision->getId();
58 /**
59 * @param int $revId
61 * @return RecentChange|null
63 private function getCategorizeRecentChangeForRevId( $revId ) {
64 return RecentChange::newFromConds(
66 'rc_type' => RC_CATEGORIZE,
67 'rc_this_oldid' => $revId,
69 __METHOD__
73 public function testRun_normalCategoryAddedAndRemoved() {
74 $addedRevId = $this->editPageText( '[[Category:Normal]]' );
75 $removedRevId = $this->editPageText( 'Blank' );
77 $this->assertEquals(
78 '(recentchanges-page-added-to-category: ' . self::TITLE_STRING . ')',
79 $this->getCategorizeRecentChangeForRevId( $addedRevId )->getAttribute( 'rc_comment' )
81 $this->assertEquals(
82 '(recentchanges-page-removed-from-category: ' . self::TITLE_STRING . ')',
83 $this->getCategorizeRecentChangeForRevId( $removedRevId )->getAttribute( 'rc_comment' )