3 use MediaWiki\Linker\LinkTarget
;
4 use MediaWiki\MediaWikiServices
;
11 * @covers ApiQueryRecentChanges
13 class ApiQueryRecentChangesIntegrationTest
extends ApiTestCase
{
15 public function __construct( $name = null, array $data = [], $dataName = '' ) {
16 parent
::__construct( $name, $data, $dataName );
17 $this->tablesUsed
= array_unique(
18 array_merge( $this->tablesUsed
, [ 'recentchanges', 'page' ] )
22 protected function setUp() {
24 self
::$users['ApiQueryRecentChangesIntegrationTestUser'] = $this->getMutableTestUser();
25 $this->doLogin( 'ApiQueryRecentChangesIntegrationTestUser' );
26 wfGetDB( DB_MASTER
)->delete( 'recentchanges', '*', __METHOD__
);
29 private function getLoggedInTestUser() {
30 return self
::$users['ApiQueryRecentChangesIntegrationTestUser']->getUser();
33 private function doPageEdit( User
$user, LinkTarget
$target, $content, $summary ) {
34 $title = Title
::newFromLinkTarget( $target );
35 $page = WikiPage
::factory( $title );
37 ContentHandler
::makeContent( $content, $title ),
45 private function doMinorPageEdit( User
$user, LinkTarget
$target, $content, $summary ) {
46 $title = Title
::newFromLinkTarget( $target );
47 $page = WikiPage
::factory( $title );
49 ContentHandler
::makeContent( $content, $title ),
57 private function doBotPageEdit( User
$user, LinkTarget
$target, $content, $summary ) {
58 $title = Title
::newFromLinkTarget( $target );
59 $page = WikiPage
::factory( $title );
61 ContentHandler
::makeContent( $content, $title ),
69 private function doAnonPageEdit( LinkTarget
$target, $content, $summary ) {
70 $title = Title
::newFromLinkTarget( $target );
71 $page = WikiPage
::factory( $title );
73 ContentHandler
::makeContent( $content, $title ),
81 private function deletePage( LinkTarget
$target, $reason ) {
82 $title = Title
::newFromLinkTarget( $target );
83 $page = WikiPage
::factory( $title );
84 $page->doDeleteArticleReal( $reason );
88 * Performs a batch of page edits as a specified user
90 * @param array $editData associative array, keys:
91 * - target => LinkTarget page to edit
92 * - content => string new content
93 * - summary => string edit summary
94 * - minorEdit => bool mark as minor edit if true (defaults to false)
95 * - botEdit => bool mark as bot edit if true (defaults to false)
97 private function doPageEdits( User
$user, array $editData ) {
98 foreach ( $editData as $singleEditData ) {
99 if ( array_key_exists( 'minorEdit', $singleEditData ) && $singleEditData['minorEdit'] ) {
100 $this->doMinorPageEdit(
102 $singleEditData['target'],
103 $singleEditData['content'],
104 $singleEditData['summary']
108 if ( array_key_exists( 'botEdit', $singleEditData ) && $singleEditData['botEdit'] ) {
109 $this->doBotPageEdit(
111 $singleEditData['target'],
112 $singleEditData['content'],
113 $singleEditData['summary']
119 $singleEditData['target'],
120 $singleEditData['content'],
121 $singleEditData['summary']
126 private function doListRecentChangesRequest( array $params = [], $user = null ) {
127 return $this->doApiRequest(
129 [ 'action' => 'query', 'list' => 'recentchanges' ],
137 private function doGeneratorRecentChangesRequest( array $params = [] ) {
138 return $this->doApiRequest(
140 [ 'action' => 'query', 'generator' => 'recentchanges' ],
146 private function getItemsFromApiResponse( array $response ) {
147 return $response[0]['query']['recentchanges'];
151 * Convenience method to assert that actual items array fetched from API is equal to the expected
152 * array, Unlike assertEquals this only checks if values of specified keys are equal in both
153 * arrays. This could be used e.g. not to compare IDs that could change between test run
154 * but only stable keys.
155 * Optionally this also checks that specified keys are present in the actual item without
156 * performing any checks on the related values.
158 * @param array $actualItems array of actual items (associative arrays)
159 * @param array $expectedItems array of expected items (associative arrays),
160 * those items have less keys than actual items
161 * @param array $keysUsedInValueComparison list of keys of the actual item that will be used
162 * in the comparison of values
163 * @param array $requiredKeys optional, list of keys that must be present in the
164 * actual items. Values of those keys are not checked.
166 private function assertArraySubsetsEqual(
168 array $expectedItems,
169 array $keysUsedInValueComparison,
170 array $requiredKeys = []
172 $this->assertCount( count( $expectedItems ), $actualItems );
174 // not checking values of all keys of the actual item, so removing unwanted keys from comparison
175 $actualItemsOnlyComparedValues = array_map(
176 function ( array $item ) use ( $keysUsedInValueComparison ) {
177 return array_intersect_key( $item, array_flip( $keysUsedInValueComparison ) );
184 $actualItemsOnlyComparedValues
187 // Check that each item in $actualItems contains all of keys specified in $requiredKeys
188 $actualItemsKeysOnly = array_map( 'array_keys', $actualItems );
189 foreach ( $actualItemsKeysOnly as $keysOfTheItem ) {
190 $this->assertEmpty( array_diff( $requiredKeys, $keysOfTheItem ) );
194 private function getTitleFormatter() {
195 return new MediaWikiTitleCodec(
196 Language
::factory( 'en' ),
197 MediaWikiServices
::getInstance()->getGenderCache()
201 private function getPrefixedText( LinkTarget
$target ) {
202 $formatter = $this->getTitleFormatter();
203 return $formatter->getPrefixedText( $target );
206 public function testListRecentChanges_returnsRCInfo() {
207 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
209 $this->getLoggedInTestUser(),
215 $result = $this->doListRecentChangesRequest();
217 $this->assertArrayHasKey( 'query', $result[0] );
218 $this->assertArrayHasKey( 'recentchanges', $result[0]['query'] );
220 $this->assertArraySubsetsEqual(
221 $this->getItemsFromApiResponse( $result ),
225 'ns' => $target->getNamespace(),
226 'title' => $this->getPrefixedText( $target ),
229 [ 'type', 'ns', 'title', 'bot', 'new', 'minor' ],
230 [ 'pageid', 'revid', 'old_revid' ]
234 public function testIdsPropParameter() {
235 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
237 $this->getLoggedInTestUser(),
243 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'ids', ] );
244 $items = $this->getItemsFromApiResponse( $result );
246 $this->assertCount( 1, $items );
247 $this->assertArrayHasKey( 'pageid', $items[0] );
248 $this->assertArrayHasKey( 'revid', $items[0] );
249 $this->assertArrayHasKey( 'old_revid', $items[0] );
250 $this->assertEquals( 'new', $items[0]['type'] );
253 public function testTitlePropParameter() {
254 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
255 $talkTarget = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
257 $this->getLoggedInTestUser(),
260 'target' => $subjectTarget,
261 'content' => 'Some Content',
262 'summary' => 'Create the page',
265 'target' => $talkTarget,
266 'content' => 'Some Talk Page Content',
267 'summary' => 'Create Talk page',
272 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', ] );
278 'ns' => $talkTarget->getNamespace(),
279 'title' => $this->getPrefixedText( $talkTarget ),
283 'ns' => $subjectTarget->getNamespace(),
284 'title' => $this->getPrefixedText( $subjectTarget ),
287 $this->getItemsFromApiResponse( $result )
291 public function testFlagsPropParameter() {
292 $normalEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
293 $minorEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPageM' );
294 $botEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPageB' );
296 $this->getLoggedInTestUser(),
299 'target' => $normalEditTarget,
300 'content' => 'Some Content',
301 'summary' => 'Create the page',
304 'target' => $minorEditTarget,
305 'content' => 'Some Content',
306 'summary' => 'Create the page',
309 'target' => $minorEditTarget,
310 'content' => 'Slightly Better Content',
311 'summary' => 'Change content',
315 'target' => $botEditTarget,
316 'content' => 'Some Content',
317 'summary' => 'Create the page with a bot',
323 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'flags', ] );
352 $this->getItemsFromApiResponse( $result )
356 public function testUserPropParameter() {
357 $userEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
358 $anonEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPageA' );
360 $this->getLoggedInTestUser(),
365 $this->doAnonPageEdit(
371 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'user', ] );
378 'user' => User
::newFromId( 0 )->getName(),
382 'user' => $this->getLoggedInTestUser()->getName(),
385 $this->getItemsFromApiResponse( $result )
389 public function testUserIdPropParameter() {
390 $user = $this->getLoggedInTestUser();
391 $userEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
392 $anonEditTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPageA' );
399 $this->doAnonPageEdit(
405 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'userid', ] );
416 'userid' => $user->getId(),
419 $this->getItemsFromApiResponse( $result )
423 public function testCommentPropParameter() {
424 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
426 $this->getLoggedInTestUser(),
429 'Create the <b>page</b>'
432 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'comment', ] );
438 'comment' => 'Create the <b>page</b>',
441 $this->getItemsFromApiResponse( $result )
445 public function testParsedCommentPropParameter() {
446 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
448 $this->getLoggedInTestUser(),
451 'Create the <b>page</b>'
454 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'parsedcomment', ] );
460 'parsedcomment' => 'Create the <b>page</b>',
463 $this->getItemsFromApiResponse( $result )
467 public function testTimestampPropParameter() {
468 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
470 $this->getLoggedInTestUser(),
476 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'timestamp', ] );
477 $items = $this->getItemsFromApiResponse( $result );
479 $this->assertCount( 1, $items );
480 $this->assertArrayHasKey( 'timestamp', $items[0] );
481 $this->assertInternalType( 'string', $items[0]['timestamp'] );
484 public function testSizesPropParameter() {
485 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
487 $this->getLoggedInTestUser(),
493 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'sizes', ] );
503 $this->getItemsFromApiResponse( $result )
507 private function createPageAndDeleteIt( LinkTarget
$target ) {
509 $this->getLoggedInTestUser(),
512 'Create the page that will be deleted'
514 $this->deletePage( $target, 'Important Reason' );
517 public function testLoginfoPropParameter() {
518 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
519 $this->createPageAndDeleteIt( $target );
521 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'loginfo', ] );
523 $this->assertArraySubsetsEqual(
524 $this->getItemsFromApiResponse( $result ),
528 'logtype' => 'delete',
529 'logaction' => 'delete',
533 [ 'type', 'logtype', 'logaction', 'logparams' ],
538 public function testEmptyPropParameter() {
539 $user = $this->getLoggedInTestUser();
540 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
548 $result = $this->doListRecentChangesRequest( [ 'rcprop' => '', ] );
556 $this->getItemsFromApiResponse( $result )
560 public function testNamespaceParam() {
561 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
562 $talkTarget = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
564 $this->getLoggedInTestUser(),
567 'target' => $subjectTarget,
568 'content' => 'Some Content',
569 'summary' => 'Create the page',
572 'target' => $talkTarget,
573 'content' => 'Some Content',
574 'summary' => 'Create the talk page',
579 $result = $this->doListRecentChangesRequest( [ 'rcnamespace' => '0', ] );
581 $this->assertArraySubsetsEqual(
582 $this->getItemsFromApiResponse( $result ),
586 'title' => $this->getPrefixedText( $subjectTarget ),
593 public function testShowAnonParams() {
594 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
595 $this->doAnonPageEdit(
601 $resultAnon = $this->doListRecentChangesRequest( [
603 'rcshow' => WatchedItemQueryService
::FILTER_ANON
605 $resultNotAnon = $this->doListRecentChangesRequest( [
607 'rcshow' => WatchedItemQueryService
::FILTER_NOT_ANON
610 $this->assertArraySubsetsEqual(
611 $this->getItemsFromApiResponse( $resultAnon ),
617 $this->assertEmpty( $this->getItemsFromApiResponse( $resultNotAnon ) );
620 public function testNewAndEditTypeParameters() {
621 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
622 $talkTarget = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
624 $this->getLoggedInTestUser(),
627 'target' => $subjectTarget,
628 'content' => 'Some Content',
629 'summary' => 'Create the page',
632 'target' => $subjectTarget,
633 'content' => 'Some Other Content',
634 'summary' => 'Change the content',
637 'target' => $talkTarget,
638 'content' => 'Some Talk Page Content',
639 'summary' => 'Create Talk page',
644 $resultNew = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'new' ] );
645 $resultEdit = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'edit' ] );
651 'ns' => $talkTarget->getNamespace(),
652 'title' => $this->getPrefixedText( $talkTarget ),
656 'ns' => $subjectTarget->getNamespace(),
657 'title' => $this->getPrefixedText( $subjectTarget ),
660 $this->getItemsFromApiResponse( $resultNew )
666 'ns' => $subjectTarget->getNamespace(),
667 'title' => $this->getPrefixedText( $subjectTarget ),
670 $this->getItemsFromApiResponse( $resultEdit )
674 public function testLogTypeParameters() {
675 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
676 $talkTarget = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
677 $this->createPageAndDeleteIt( $subjectTarget );
679 $this->getLoggedInTestUser(),
681 'Some Talk Page Content',
685 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'log' ] );
691 'ns' => $subjectTarget->getNamespace(),
692 'title' => $this->getPrefixedText( $subjectTarget ),
695 $this->getItemsFromApiResponse( $result )
699 private function getExternalRC( LinkTarget
$target ) {
700 $title = Title
::newFromLinkTarget( $target );
702 $rc = new RecentChange
;
703 $rc->mTitle
= $title;
705 'rc_timestamp' => wfTimestamp( TS_MW
),
706 'rc_namespace' => $title->getNamespace(),
707 'rc_title' => $title->getDBkey(),
708 'rc_type' => RC_EXTERNAL
,
709 'rc_source' => 'foo',
711 'rc_cur_id' => $title->getArticleID(),
713 'rc_user_text' => 'External User',
715 'rc_comment_text' => '',
716 'rc_comment_data' => null,
717 'rc_this_oldid' => $title->getLatestRevID(),
718 'rc_last_oldid' => $title->getLatestRevID(),
723 'rc_old_len' => $title->getLength(),
724 'rc_new_len' => $title->getLength(),
727 'rc_log_type' => null,
728 'rc_log_action' => '',
732 'prefixedDBkey' => $title->getPrefixedDBkey(),
733 'lastTimestamp' => 0,
734 'oldSize' => $title->getLength(),
735 'newSize' => $title->getLength(),
736 'pageStatus' => 'changed'
742 public function testExternalTypeParameters() {
743 $user = $this->getLoggedInTestUser();
744 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
745 $talkTarget = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
755 'Some Talk Page Content',
759 $rc = $this->getExternalRC( $subjectTarget );
762 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'external' ] );
767 'type' => 'external',
768 'ns' => $subjectTarget->getNamespace(),
769 'title' => $this->getPrefixedText( $subjectTarget ),
772 $this->getItemsFromApiResponse( $result )
776 public function testCategorizeTypeParameter() {
777 $user = $this->getLoggedInTestUser();
778 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
779 $categoryTarget = new TitleValue( NS_CATEGORY
, 'ApiQueryRecentChangesIntegrationTestCategory' );
784 'target' => $categoryTarget,
785 'content' => 'Some Content',
786 'summary' => 'Create the category',
789 'target' => $subjectTarget,
790 'content' => 'Some Content [[Category:ApiQueryRecentChangesIntegrationTestCategory]]t',
791 'summary' => 'Create the page and add it to the category',
795 $title = Title
::newFromLinkTarget( $subjectTarget );
796 $revision = Revision
::newFromTitle( $title );
798 $rc = RecentChange
::newForCategorization(
799 $revision->getTimestamp(),
800 Title
::newFromLinkTarget( $categoryTarget ),
802 $revision->getComment(),
811 $result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'categorize' ] );
816 'type' => 'categorize',
817 'ns' => $categoryTarget->getNamespace(),
818 'title' => $this->getPrefixedText( $categoryTarget ),
821 $this->getItemsFromApiResponse( $result )
825 public function testLimitParam() {
826 $target1 = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
827 $target2 = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
828 $target3 = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage2' );
830 $this->getLoggedInTestUser(),
833 'target' => $target1,
834 'content' => 'Some Content',
835 'summary' => 'Create the page',
838 'target' => $target2,
839 'content' => 'Some Talk Page Content',
840 'summary' => 'Create Talk page',
843 'target' => $target3,
844 'content' => 'Some Other Content',
845 'summary' => 'Create the page',
850 $resultWithoutLimit = $this->doListRecentChangesRequest( [ 'rcprop' => 'title' ] );
851 $resultWithLimit = $this->doListRecentChangesRequest( [ 'rclimit' => 2, 'rcprop' => 'title' ] );
857 'ns' => $target3->getNamespace(),
858 'title' => $this->getPrefixedText( $target3 )
862 'ns' => $target2->getNamespace(),
863 'title' => $this->getPrefixedText( $target2 )
867 'ns' => $target1->getNamespace(),
868 'title' => $this->getPrefixedText( $target1 )
871 $this->getItemsFromApiResponse( $resultWithoutLimit )
877 'ns' => $target3->getNamespace(),
878 'title' => $this->getPrefixedText( $target3 )
882 'ns' => $target2->getNamespace(),
883 'title' => $this->getPrefixedText( $target2 )
886 $this->getItemsFromApiResponse( $resultWithLimit )
888 $this->assertArrayHasKey( 'continue', $resultWithLimit[0] );
889 $this->assertArrayHasKey( 'rccontinue', $resultWithLimit[0]['continue'] );
892 public function testAllRevParam() {
893 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
895 $this->getLoggedInTestUser(),
899 'content' => 'Some Content',
900 'summary' => 'Create the page',
904 'content' => 'Some Other Content',
905 'summary' => 'Change the content',
910 $resultAllRev = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rcallrev' => '', ] );
911 $resultNoAllRev = $this->doListRecentChangesRequest( [ 'rcprop' => 'title' ] );
917 'ns' => $target->getNamespace(),
918 'title' => $this->getPrefixedText( $target ),
922 'ns' => $target->getNamespace(),
923 'title' => $this->getPrefixedText( $target ),
926 $this->getItemsFromApiResponse( $resultNoAllRev )
932 'ns' => $target->getNamespace(),
933 'title' => $this->getPrefixedText( $target ),
937 'ns' => $target->getNamespace(),
938 'title' => $this->getPrefixedText( $target ),
941 $this->getItemsFromApiResponse( $resultAllRev )
945 public function testDirParams() {
946 $subjectTarget = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
947 $talkTarget = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
949 $this->getLoggedInTestUser(),
952 'target' => $subjectTarget,
953 'content' => 'Some Content',
954 'summary' => 'Create the page',
957 'target' => $talkTarget,
958 'content' => 'Some Talk Page Content',
959 'summary' => 'Create Talk page',
964 $resultDirOlder = $this->doListRecentChangesRequest(
965 [ 'rcdir' => 'older', 'rcprop' => 'title' ]
967 $resultDirNewer = $this->doListRecentChangesRequest(
968 [ 'rcdir' => 'newer', 'rcprop' => 'title' ]
975 'ns' => $talkTarget->getNamespace(),
976 'title' => $this->getPrefixedText( $talkTarget )
980 'ns' => $subjectTarget->getNamespace(),
981 'title' => $this->getPrefixedText( $subjectTarget )
984 $this->getItemsFromApiResponse( $resultDirOlder )
990 'ns' => $subjectTarget->getNamespace(),
991 'title' => $this->getPrefixedText( $subjectTarget )
995 'ns' => $talkTarget->getNamespace(),
996 'title' => $this->getPrefixedText( $talkTarget )
999 $this->getItemsFromApiResponse( $resultDirNewer )
1003 public function testStartEndParams() {
1004 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
1006 $this->getLoggedInTestUser(),
1012 $resultStart = $this->doListRecentChangesRequest( [
1013 'rcstart' => '20010115000000',
1015 'rcprop' => 'title',
1017 $resultEnd = $this->doListRecentChangesRequest( [
1018 'rcend' => '20010115000000',
1020 'rcprop' => 'title',
1023 $this->assertEquals(
1027 'ns' => $target->getNamespace(),
1028 'title' => $this->getPrefixedText( $target ),
1031 $this->getItemsFromApiResponse( $resultStart )
1033 $this->assertEmpty( $this->getItemsFromApiResponse( $resultEnd ) );
1036 public function testContinueParam() {
1037 $target1 = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
1038 $target2 = new TitleValue( 1, 'ApiQueryRecentChangesIntegrationTestPage' );
1039 $target3 = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage2' );
1041 $this->getLoggedInTestUser(),
1044 'target' => $target1,
1045 'content' => 'Some Content',
1046 'summary' => 'Create the page',
1049 'target' => $target2,
1050 'content' => 'Some Talk Page Content',
1051 'summary' => 'Create Talk page',
1054 'target' => $target3,
1055 'content' => 'Some Other Content',
1056 'summary' => 'Create the page',
1061 $firstResult = $this->doListRecentChangesRequest( [ 'rclimit' => 2, 'rcprop' => 'title' ] );
1062 $this->assertArrayHasKey( 'continue', $firstResult[0] );
1063 $this->assertArrayHasKey( 'rccontinue', $firstResult[0]['continue'] );
1065 $continuationParam = $firstResult[0]['continue']['rccontinue'];
1067 $continuedResult = $this->doListRecentChangesRequest(
1068 [ 'rccontinue' => $continuationParam, 'rcprop' => 'title' ]
1071 $this->assertEquals(
1075 'ns' => $target3->getNamespace(),
1076 'title' => $this->getPrefixedText( $target3 ),
1080 'ns' => $target2->getNamespace(),
1081 'title' => $this->getPrefixedText( $target2 ),
1084 $this->getItemsFromApiResponse( $firstResult )
1086 $this->assertEquals(
1090 'ns' => $target1->getNamespace(),
1091 'title' => $this->getPrefixedText( $target1 )
1094 $this->getItemsFromApiResponse( $continuedResult )
1098 public function testGeneratorRecentChangesPropInfo_returnsRCPages() {
1099 $target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
1101 $this->getLoggedInTestUser(),
1107 $result = $this->doGeneratorRecentChangesRequest( [ 'prop' => 'info' ] );
1109 $this->assertArrayHasKey( 'query', $result[0] );
1110 $this->assertArrayHasKey( 'pages', $result[0]['query'] );
1112 // $result[0]['query']['pages'] uses page ids as keys. Page ids don't matter here, so drop them
1113 $pages = array_values( $result[0]['query']['pages'] );
1115 $this->assertArraySubsetsEqual(
1119 'ns' => $target->getNamespace(),
1120 'title' => $this->getPrefixedText( $target ),
1124 [ 'ns', 'title', 'new' ]