MediaWiki  1.29.1
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() {
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 
65  [
66  'rc_type' => RC_CATEGORIZE,
67  'rc_this_oldid' => $revId,
68  ],
69  __METHOD__
70  );
71  }
72 
74  $addedRevId = $this->editPageText( '[[Category:Normal]]' );
75  $removedRevId = $this->editPageText( 'Blank' );
76 
77  $this->assertEquals(
78  '(recentchanges-page-added-to-category: ' . self::TITLE_STRING . ')',
79  $this->getCategorizeRecentChangeForRevId( $addedRevId )->getAttribute( 'rc_comment' )
80  );
81  $this->assertEquals(
82  '(recentchanges-page-removed-from-category: ' . self::TITLE_STRING . ')',
83  $this->getCategorizeRecentChangeForRevId( $removedRevId )->getAttribute( 'rc_comment' )
84  );
85  }
86 
87 }
RunJobs
Maintenance script that runs pending jobs.
Definition: runJobs.php:33
RecentChange\newFromConds
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
Definition: RecentChange.php:185
CategoryMembershipChangeJobTest
CategoryMembershipChangeJob.
Definition: CategoryMembershipChangeJobTest.php:12
Maintenance\loadParamsAndArgs
loadParamsAndArgs( $self=null, $opts=null, $args=null)
Process command line arguments $mOptions becomes an array with keys set to the option names $mArgs be...
Definition: Maintenance.php:876
CategoryMembershipChangeJobTest\runJobs
runJobs()
Definition: CategoryMembershipChangeJobTest.php:33
JobQueueGroup\destroySingletons
static destroySingletons()
Destroy the singleton instances.
Definition: JobQueueGroup.php:85
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
CategoryMembershipChangeJobTest\addDBDataOnce
addDBDataOnce()
Stub.
Definition: CategoryMembershipChangeJobTest.php:27
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:120
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:658
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
MediaWikiTestCase
Definition: MediaWikiTestCase.php:13
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:129
MediaWikiTestCase\setContentLang
setContentLang( $lang)
Definition: MediaWikiTestCase.php:843
title
title
Definition: parserTests.txt:211
CategoryMembershipChangeJobTest\setUp
setUp()
Definition: CategoryMembershipChangeJobTest.php:21
CategoryMembershipChangeJobTest\editPageText
editPageText( $text)
Definition: CategoryMembershipChangeJobTest.php:45
CategoryMembershipChangeJobTest\$title
Title $title
Definition: CategoryMembershipChangeJobTest.php:19
CategoryMembershipChangeJobTest\TITLE_STRING
const TITLE_STRING
Definition: CategoryMembershipChangeJobTest.php:14
Title
Represents a title within MediaWiki.
Definition: Title.php:39
MediaWikiTestCase\insertPage
insertPage( $pageName, $text='Sample page for unit test.', $namespace=null)
Insert a new page.
Definition: MediaWikiTestCase.php:953
$revId
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context $revId
Definition: hooks.txt:1049
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:144
CategoryMembershipChangeJobTest\getCategorizeRecentChangeForRevId
getCategorizeRecentChangeForRevId( $revId)
Definition: CategoryMembershipChangeJobTest.php:63
CategoryMembershipChangeJobTest\testRun_normalCategoryAddedAndRemoved
testRun_normalCategoryAddedAndRemoved()
Definition: CategoryMembershipChangeJobTest.php:73