MediaWiki
REL1_31
CategoryMembershipChangeJobTest.php
Go to the documentation of this file.
1
<?php
2
12
class
CategoryMembershipChangeJobTest
extends
MediaWikiTestCase
{
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
return
RecentChange::newFromConds(
65
[
66
'rc_type'
=>
RC_CATEGORIZE
,
67
'rc_this_oldid'
=> $revId,
68
],
69
__METHOD__
70
);
71
}
72
73
public
function
testRun_normalCategoryAddedAndRemoved
() {
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
}
CategoryMembershipChangeJobTest
CategoryMembershipChangeJob.
Definition
CategoryMembershipChangeJobTest.php:12
CategoryMembershipChangeJobTest\getCategorizeRecentChangeForRevId
getCategorizeRecentChangeForRevId( $revId)
Definition
CategoryMembershipChangeJobTest.php:63
CategoryMembershipChangeJobTest\editPageText
editPageText( $text)
Definition
CategoryMembershipChangeJobTest.php:45
CategoryMembershipChangeJobTest\setUp
setUp()
Definition
CategoryMembershipChangeJobTest.php:21
CategoryMembershipChangeJobTest\addDBDataOnce
addDBDataOnce()
Stub.
Definition
CategoryMembershipChangeJobTest.php:27
CategoryMembershipChangeJobTest\runJobs
runJobs()
Definition
CategoryMembershipChangeJobTest.php:33
CategoryMembershipChangeJobTest\$title
Title $title
Definition
CategoryMembershipChangeJobTest.php:19
CategoryMembershipChangeJobTest\testRun_normalCategoryAddedAndRemoved
testRun_normalCategoryAddedAndRemoved()
Definition
CategoryMembershipChangeJobTest.php:73
CategoryMembershipChangeJobTest\TITLE_STRING
const TITLE_STRING
Definition
CategoryMembershipChangeJobTest.php:14
JobQueueGroup\destroySingletons
static destroySingletons()
Destroy the singleton instances.
Definition
JobQueueGroup.php:100
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:923
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
MediaWikiTestCase\insertPage
insertPage( $pageName, $text='Sample page for unit test.', $namespace=null)
Insert a new page.
Definition
MediaWikiTestCase.php:1033
MediaWikiTestCase\setContentLang
setContentLang( $lang)
Definition
MediaWikiTestCase.php:892
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition
MediaWikiTestCase.php:678
RunJobs
Maintenance script that runs pending jobs.
Definition
runJobs.php:36
Title
Represents a title within MediaWiki.
Definition
Title.php:39
RC_CATEGORIZE
const RC_CATEGORIZE
Definition
Defines.php:156
tests
phpunit
includes
jobqueue
jobs
CategoryMembershipChangeJobTest.php
Generated on Mon Nov 25 2024 15:36:24 for MediaWiki by
1.10.0