jenkins-bot has submitted this change and it was merged. Change subject: Add CategoryMembershipChangeJobTest ......................................................................
Add CategoryMembershipChangeJobTest Change-Id: Ia04bb85260be7d2aaaf171a2c886633b66ee6e77 --- A tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php 1 file changed, 86 insertions(+), 0 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php b/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php new file mode 100644 index 0000000..50a24ad --- /dev/null +++ b/tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php @@ -0,0 +1,86 @@ +<?php + +/** + * @covers CategoryMembershipChangeJob + * + * @group JobQueue + * @group Database + * + * @licence GNU GPL v2+ + * @author Addshore + */ +class CategoryMembershipChangeJobTest extends MediaWikiTestCase { + + const TITLE_STRING = 'UTCatChangeJobPage'; + + /** + * @var Title + */ + private $title; + + public function setUp() { + parent::setUp(); + $this->setMwGlobals( 'wgRCWatchCategoryMembership', true ); + } + + public function addDBData() { + parent::addDBData(); + $insertResult = $this->insertPage( self::TITLE_STRING, 'UT Content' ); + $this->title = $insertResult['title']; + } + + private function runJobs() { + JobQueueGroup::destroySingletons(); + $jobs = new RunJobs; + $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null ); + $jobs->execute(); + } + + /** + * @param string $text new page text + * + * @return int|null + */ + private function editPageText( $text ) { + $page = WikiPage::factory( $this->title ); + $editResult = $page->doEditContent( + ContentHandler::makeContent( $text, $this->title ), + __METHOD__ + ); + /** @var Revision $revision */ + $revision = $editResult->value['revision']; + $this->runJobs(); + + return $revision->getId(); + } + + /** + * @param int $revId + * + * @return RecentChange|null + */ + private function getCategorizeRecentChangeForRevId( $revId ) { + return RecentChange::newFromConds( + [ + 'rc_type' => RC_CATEGORIZE, + 'rc_this_oldid' => $revId, + ], + __METHOD__ + ); + } + + public function testRun_normalCategoryAddedAndRemoved() { + $addedRevId = $this->editPageText( '[[Category:Normal]]' ); + $removedRevId = $this->editPageText( 'Blank' ); + + $this->assertEquals( + '[[:' . self::TITLE_STRING . ']] added to category', + $this->getCategorizeRecentChangeForRevId( $addedRevId )->getAttribute( 'rc_comment' ) + ); + $this->assertEquals( + '[[:' . self::TITLE_STRING . ']] removed from category', + $this->getCategorizeRecentChangeForRevId( $removedRevId )->getAttribute( 'rc_comment' ) + ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/274002 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia04bb85260be7d2aaaf171a2c886633b66ee6e77 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: WMDE-Fisch <christoph.fisc...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits