16 parent::__construct( $name, $data, $dataName );
18 $this->tablesUsed[] =
'recentchanges';
19 $this->tablesUsed[] =
'page';
25 self::$users[
'ApiQueryRecentChangesIntegrationTestUser'] = $this->
getMutableTestUser();
30 return self::$users[
'ApiQueryRecentChangesIntegrationTestUser']->getUser();
36 $title = Title::newFromLinkTarget( $target );
37 $page = WikiPage::factory( $title );
39 ContentHandler::makeContent( __CLASS__ . $i++, $title ),
48 $title = Title::newFromLinkTarget( $target );
49 $page = WikiPage::factory( $title );
51 ContentHandler::makeContent( __CLASS__, $title ),
60 $title = Title::newFromLinkTarget( $target );
61 $page = WikiPage::factory( $title );
63 ContentHandler::makeContent( __CLASS__, $title ),
72 $title = Title::newFromLinkTarget( $target );
73 $page = WikiPage::factory( $title );
75 ContentHandler::makeContent( __CLASS__, $title ),
84 $title = Title::newFromLinkTarget( $target );
85 $page = WikiPage::factory( $title );
86 $page->doDeleteArticleReal( $reason );
99 foreach ( $editData as $singleEditData ) {
100 if ( array_key_exists(
'minorEdit', $singleEditData ) && $singleEditData[
'minorEdit'] ) {
103 $singleEditData[
'target'],
104 $singleEditData[
'summary']
108 if ( array_key_exists(
'botEdit', $singleEditData ) && $singleEditData[
'botEdit'] ) {
111 $singleEditData[
'target'],
112 $singleEditData[
'summary']
118 $singleEditData[
'target'],
119 $singleEditData[
'summary']
127 [
'action' =>
'query',
'list' =>
'recentchanges' ],
139 [
'action' =>
'query',
'generator' =>
'recentchanges' ],
149 return $response[0][
'query'][
'recentchanges'];
154 Language::factory(
'en' ),
155 MediaWikiServices::getInstance()->getGenderCache()
161 return $formatter->getPrefixedText( $target );
165 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
170 $this->assertArrayHasKey(
'query', $result[0] );
171 $this->assertArrayHasKey(
'recentchanges', $result[0][
'query'] );
174 $this->assertCount( 1, $items );
176 $this->assertArraySubset(
179 'ns' => $target->getNamespace(),
180 'title' => $this->getPrefixedText( $target ),
184 $this->assertArrayNotHasKey(
'bot', $item );
185 $this->assertArrayNotHasKey(
'new', $item );
186 $this->assertArrayNotHasKey(
'minor', $item );
187 $this->assertArrayHasKey(
'pageid', $item );
188 $this->assertArrayHasKey(
'revid', $item );
189 $this->assertArrayHasKey(
'old_revid', $item );
193 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
199 $this->assertCount( 1, $items );
200 $this->assertArrayHasKey(
'pageid', $items[0] );
201 $this->assertArrayHasKey(
'revid', $items[0] );
202 $this->assertArrayHasKey(
'old_revid', $items[0] );
203 $this->assertEquals(
'new', $items[0][
'type'] );
207 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
208 $talkTarget =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
213 'target' => $subjectTarget,
214 'summary' =>
'Create the page',
217 'target' => $talkTarget,
218 'summary' =>
'Create Talk page',
229 'ns' => $talkTarget->getNamespace(),
230 'title' => $this->getPrefixedText( $talkTarget ),
234 'ns' => $subjectTarget->getNamespace(),
235 'title' => $this->getPrefixedText( $subjectTarget ),
238 $this->getItemsFromApiResponse( $result )
243 $normalEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
244 $minorEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPageM' );
245 $botEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPageB' );
250 'target' => $normalEditTarget,
251 'summary' =>
'Create the page',
254 'target' => $minorEditTarget,
255 'summary' =>
'Create the page',
258 'target' => $minorEditTarget,
259 'summary' =>
'Change content',
263 'target' => $botEditTarget,
264 'summary' =>
'Create the page with a bot',
304 $userEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
305 $anonEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPageA' );
329 $userEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
330 $anonEditTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPageA' );
331 $this->
doPageEdit( $user, $userEditTarget,
'Create the page' );
345 'userid' => $user->getId(),
348 $this->getItemsFromApiResponse( $result )
353 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
362 'comment' =>
'Create the <b>page</b>',
370 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
379 'parsedcomment' =>
'Create the <b>page</b>',
387 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
393 $this->assertCount( 1, $items );
394 $this->assertArrayHasKey(
'timestamp', $items[0] );
395 $this->assertInternalType(
'string', $items[0][
'timestamp'] );
399 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
419 'Create the page that will be deleted'
421 $this->
deletePage( $target,
'Important Reason' );
425 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
431 $this->assertCount( 1, $items );
432 $this->assertArraySubset(
435 'logtype' =>
'delete',
436 'logaction' =>
'delete',
441 $this->assertArrayHasKey(
'logid', $items[0] );
446 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
447 $this->
doPageEdit( $user, $target,
'Create the page' );
462 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
463 $talkTarget =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
468 'target' => $subjectTarget,
469 'summary' =>
'Create the page',
472 'target' => $talkTarget,
473 'summary' =>
'Create the talk page',
481 $this->assertCount( 1, $items );
482 $this->assertArraySubset(
492 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
497 'rcshow' => WatchedItemQueryService::FILTER_ANON
501 'rcshow' => WatchedItemQueryService::FILTER_NOT_ANON
505 $this->assertCount( 1, $items );
506 $this->assertArraySubset( [
'anon' =>
true ], $items[0] );
511 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
512 $talkTarget =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
517 'target' => $subjectTarget,
518 'summary' =>
'Create the page',
521 'target' => $subjectTarget,
522 'summary' =>
'Change the content',
525 'target' => $talkTarget,
526 'summary' =>
'Create Talk page',
538 'ns' => $talkTarget->getNamespace(),
539 'title' => $this->getPrefixedText( $talkTarget ),
543 'ns' => $subjectTarget->getNamespace(),
544 'title' => $this->getPrefixedText( $subjectTarget ),
547 $this->getItemsFromApiResponse( $resultNew )
553 'ns' => $subjectTarget->getNamespace(),
554 'title' => $this->getPrefixedText( $subjectTarget ),
557 $this->getItemsFromApiResponse( $resultEdit )
562 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
563 $talkTarget =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
573 'ns' => $subjectTarget->getNamespace(),
574 'title' => $this->getPrefixedText( $subjectTarget ),
577 $this->getItemsFromApiResponse( $result )
582 $title = Title::newFromLinkTarget( $target );
588 'rc_namespace' => $title->getNamespace(),
589 'rc_title' => $title->getDBkey(),
591 'rc_source' =>
'foo',
593 'rc_cur_id' => $title->getArticleID(),
595 'rc_user_text' =>
'm>External User',
597 'rc_comment_text' =>
'',
598 'rc_comment_data' =>
null,
599 'rc_this_oldid' => $title->getLatestRevID(),
600 'rc_last_oldid' => $title->getLatestRevID(),
605 'rc_old_len' => $title->getLength(),
606 'rc_new_len' => $title->getLength(),
609 'rc_log_type' =>
null,
610 'rc_log_action' =>
'',
614 'prefixedDBkey' => $title->getPrefixedDBkey(),
615 'lastTimestamp' => 0,
616 'oldSize' => $title->getLength(),
617 'newSize' => $title->getLength(),
618 'pageStatus' =>
'changed'
626 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
627 $talkTarget =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
628 $this->
doPageEdit( $user, $subjectTarget,
'Create the page' );
629 $this->
doPageEdit( $user, $talkTarget,
'Create Talk page' );
639 'type' =>
'external',
640 'ns' => $subjectTarget->getNamespace(),
641 'title' => $this->getPrefixedText( $subjectTarget ),
644 $this->getItemsFromApiResponse( $result )
650 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
656 'target' => $categoryTarget,
657 'summary' =>
'Create the category',
660 'target' => $subjectTarget,
661 'summary' =>
'Create the page and add it to the category',
665 $title = Title::newFromLinkTarget( $subjectTarget );
668 $rc = RecentChange::newForCategorization(
669 $revision->getTimestamp(),
670 Title::newFromLinkTarget( $categoryTarget ),
672 $revision->getComment(),
686 'type' =>
'categorize',
687 'ns' => $categoryTarget->getNamespace(),
688 'title' => $this->getPrefixedText( $categoryTarget ),
691 $this->getItemsFromApiResponse( $result )
696 $target1 =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
697 $target2 =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
698 $target3 =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage2' );
703 'target' => $target1,
704 'summary' =>
'Create the page',
707 'target' => $target2,
708 'summary' =>
'Create Talk page',
711 'target' => $target3,
712 'summary' =>
'Create the page',
724 'ns' => $target3->getNamespace(),
725 'title' => $this->getPrefixedText( $target3 )
729 'ns' => $target2->getNamespace(),
730 'title' => $this->getPrefixedText( $target2 )
734 'ns' => $target1->getNamespace(),
735 'title' => $this->getPrefixedText( $target1 )
738 $this->getItemsFromApiResponse( $resultWithoutLimit )
744 'ns' => $target3->getNamespace(),
745 'title' => $this->getPrefixedText( $target3 )
749 'ns' => $target2->getNamespace(),
750 'title' => $this->getPrefixedText( $target2 )
753 $this->getItemsFromApiResponse( $resultWithLimit )
755 $this->assertArrayHasKey(
'continue', $resultWithLimit[0] );
756 $this->assertArrayHasKey(
'rccontinue', $resultWithLimit[0][
'continue'] );
760 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
766 'summary' =>
'Create the page',
770 'summary' =>
'Change the content',
782 'ns' => $target->getNamespace(),
783 'title' => $this->getPrefixedText( $target ),
787 'ns' => $target->getNamespace(),
788 'title' => $this->getPrefixedText( $target ),
791 $this->getItemsFromApiResponse( $resultNoAllRev )
797 'ns' => $target->getNamespace(),
798 'title' => $this->getPrefixedText( $target ),
802 'ns' => $target->getNamespace(),
803 'title' => $this->getPrefixedText( $target ),
806 $this->getItemsFromApiResponse( $resultAllRev )
811 $subjectTarget =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
812 $talkTarget =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
817 'target' => $subjectTarget,
818 'summary' =>
'Create the page',
821 'target' => $talkTarget,
822 'summary' =>
'Create Talk page',
828 [
'rcdir' =>
'older',
'rcprop' =>
'title' ]
831 [
'rcdir' =>
'newer',
'rcprop' =>
'title' ]
838 'ns' => $talkTarget->getNamespace(),
839 'title' => $this->getPrefixedText( $talkTarget )
843 'ns' => $subjectTarget->getNamespace(),
844 'title' => $this->getPrefixedText( $subjectTarget )
847 $this->getItemsFromApiResponse( $resultDirOlder )
853 'ns' => $subjectTarget->getNamespace(),
854 'title' => $this->getPrefixedText( $subjectTarget )
858 'ns' => $talkTarget->getNamespace(),
859 'title' => $this->getPrefixedText( $talkTarget )
862 $this->getItemsFromApiResponse( $resultDirNewer )
867 $page1 =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
868 $page2 =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage2' );
869 $page3 =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage3' );
875 'summary' =>
'Create the page',
879 'summary' =>
'Create the page',
883 'summary' =>
'Create the page',
890 'rctitle' =>
'ApiQueryRecentChangesIntegrationTestPage',
897 'rctitle' =>
'Talk:ApiQueryRecentChangesIntegrationTestPage2',
906 'ns' => $page1->getNamespace(),
907 'title' => $this->getPrefixedText( $page1 )
910 $this->getItemsFromApiResponse( $result )
917 'ns' => $page2->getNamespace(),
918 'title' => $this->getPrefixedText( $page2 )
921 $this->getItemsFromApiResponse( $result2 )
926 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
930 'rcstart' =>
'20010115000000',
935 'rcend' =>
'20010115000000',
944 'ns' => $target->getNamespace(),
945 'title' => $this->getPrefixedText( $target ),
948 $this->getItemsFromApiResponse( $resultStart )
954 $target1 =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
955 $target2 =
new TitleValue( 1,
'ApiQueryRecentChangesIntegrationTestPage' );
956 $target3 =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage2' );
961 'target' => $target1,
962 'summary' =>
'Create the page',
965 'target' => $target2,
966 'summary' =>
'Create Talk page',
969 'target' => $target3,
970 'summary' =>
'Create the page',
976 $this->assertArrayHasKey(
'continue', $firstResult[0] );
977 $this->assertArrayHasKey(
'rccontinue', $firstResult[0][
'continue'] );
979 $continuationParam = $firstResult[0][
'continue'][
'rccontinue'];
982 [
'rccontinue' => $continuationParam,
'rcprop' =>
'title' ]
989 'ns' => $target3->getNamespace(),
990 'title' => $this->getPrefixedText( $target3 ),
994 'ns' => $target2->getNamespace(),
995 'title' => $this->getPrefixedText( $target2 ),
998 $this->getItemsFromApiResponse( $firstResult )
1000 $this->assertEquals(
1004 'ns' => $target1->getNamespace(),
1005 'title' => $this->getPrefixedText( $target1 )
1008 $this->getItemsFromApiResponse( $continuedResult )
1013 $target =
new TitleValue( 0,
'ApiQueryRecentChangesIntegrationTestPage' );
1018 $this->assertArrayHasKey(
'query', $result[0] );
1019 $this->assertArrayHasKey(
'pages', $result[0][
'query'] );
1022 $pages = array_values( $result[0][
'query'][
'pages'] );
1024 $this->assertCount( 1, $pages );
1025 $this->assertArraySubset(
1027 'ns' => $target->getNamespace(),
1028 'title' => $this->getPrefixedText( $target ),
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
doGeneratorRecentChangesRequest(array $params=[])
testCommentPropParameter()
doBotPageEdit(User $user, LinkTarget $target, $summary)
doPageEdits(User $user, array $editData)
Performs a batch of page edits as a specified user.
doPageEdit(User $user, LinkTarget $target, $summary)
doAnonPageEdit(LinkTarget $target, $summary)
testNewAndEditTypeParameters()
testExternalTypeParameters()
getExternalRC(LinkTarget $target)
testParsedCommentPropParameter()
getPrefixedText(LinkTarget $target)
testTimestampPropParameter()
deletePage(LinkTarget $target, $reason)
testUserIdPropParameter()
__construct( $name=null, array $data=[], $dataName='')
testCategorizeTypeParameter()
testGeneratorRecentChangesPropInfo_returnsRCPages()
testListRecentChanges_returnsRCInfo()
doMinorPageEdit(User $user, LinkTarget $target, $summary)
createPageAndDeleteIt(LinkTarget $target)
testLoginfoPropParameter()
getItemsFromApiResponse(array $response)
doListRecentChangesRequest(array $params=[])
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
Utility class for creating new RC entries.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Represents a page (or page fragment) title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromId( $id)
Static factory method for creation from a given user ID.
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only $response
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))