17 parent::__construct(
$name, $data, $dataName );
18 $this->tablesUsed = array_unique(
19 array_merge( $this->tablesUsed, [
'watchlist',
'recentchanges',
'page' ] )
30 return self::$users[
'ApiQueryWatchlistIntegrationTestUser']->getUser();
34 return self::$users[
'ApiQueryWatchlistIntegrationTestUser2']->getUser();
100 $rc = MediaWikiServices::getInstance()->getRevisionStore()->getRecentChange(
$rev );
101 $rc->doMarkPatrolled( $patrollingUser,
false, [] );
107 $page->doDeleteArticleReal( $reason );
121 foreach ( $editData
as $singleEditData ) {
122 if ( array_key_exists(
'minorEdit', $singleEditData ) && $singleEditData[
'minorEdit'] ) {
125 $singleEditData[
'target'],
126 $singleEditData[
'content'],
127 $singleEditData[
'summary']
131 if ( array_key_exists(
'botEdit', $singleEditData ) && $singleEditData[
'botEdit'] ) {
134 $singleEditData[
'target'],
135 $singleEditData[
'content'],
136 $singleEditData[
'summary']
142 $singleEditData[
'target'],
143 $singleEditData[
'content'],
144 $singleEditData[
'summary']
150 return MediaWikiServices::getInstance()->getWatchedItemStore();
159 $store->addWatchBatchForUser(
$user, $targets );
163 if (
$user ===
null ) {
168 [
'action' =>
'query',
'list' =>
'watchlist' ],
170 ),
null,
false,
$user
177 [
'action' =>
'query',
'generator' =>
'watchlist' ],
184 return $response[0][
'query'][
'watchlist'];
205 array $expectedItems,
206 array $keysUsedInValueComparison,
207 array $requiredKeys = []
209 $this->assertCount(
count( $expectedItems ), $actualItems );
212 $actualItemsOnlyComparedValues = array_map(
213 function (
array $item )
use ( $keysUsedInValueComparison ) {
214 return array_intersect_key( $item, array_flip( $keysUsedInValueComparison ) );
221 $actualItemsOnlyComparedValues
225 $actualItemsKeysOnly = array_map(
'array_keys', $actualItems );
226 foreach ( $actualItemsKeysOnly
as $keysOfTheItem ) {
227 $this->assertEmpty( array_diff( $requiredKeys, $keysOfTheItem ) );
234 MediaWikiServices::getInstance()->getGenderCache()
240 return $formatter->getPrefixedText( $target );
246 $items = $store->getWatchedItemsForUser(
$user );
247 foreach ( $items
as $item ) {
248 $store->removeWatch(
$user, $item->getLinkTarget() );
258 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
269 $this->assertArrayHasKey(
'query',
$result[0] );
270 $this->assertArrayHasKey(
'watchlist',
$result[0][
'query'] );
277 'ns' => $target->getNamespace(),
284 [
'type',
'ns',
'title',
'bot',
'new',
'minor' ],
285 [
'pageid',
'revid',
'old_revid' ]
291 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
303 $this->assertCount( 1, $items );
304 $this->assertArrayHasKey(
'pageid', $items[0] );
305 $this->assertArrayHasKey(
'revid', $items[0] );
306 $this->assertArrayHasKey(
'old_revid', $items[0] );
307 $this->assertEquals(
'new', $items[0][
'type'] );
312 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
313 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
318 'target' => $subjectTarget,
319 'content' =>
'Some Content',
320 'summary' =>
'Create the page',
323 'target' => $talkTarget,
324 'content' =>
'Some Talk Page Content',
325 'summary' =>
'Create Talk page',
337 'ns' => $talkTarget->getNamespace(),
342 'ns' => $subjectTarget->getNamespace(),
352 $normalEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
353 $minorEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageM' );
354 $botEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageB' );
359 'target' => $normalEditTarget,
360 'content' =>
'Some Content',
361 'summary' =>
'Create the page',
364 'target' => $minorEditTarget,
365 'content' =>
'Some Content',
366 'summary' =>
'Create the page',
369 'target' => $minorEditTarget,
370 'content' =>
'Slightly Better Content',
371 'summary' =>
'Change content',
375 'target' => $botEditTarget,
376 'content' =>
'Some Content',
377 'summary' =>
'Create the page with a bot',
382 $this->
watchPages(
$user, [ $normalEditTarget, $minorEditTarget, $botEditTarget ] );
413 $userEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
414 $anonEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageA' );
439 'user' =>
$user->getName(),
448 $userEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
449 $anonEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageA' );
475 'user' =>
$user->getId(),
476 'userid' =>
$user->getId(),
485 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
490 'Create the <b>page</b>'
500 'comment' =>
'Create the <b>page</b>',
509 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
514 'Create the <b>page</b>'
524 'parsedcomment' =>
'Create the <b>page</b>',
533 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
545 $this->assertCount( 1, $items );
546 $this->assertArrayHasKey(
'timestamp', $items[0] );
547 $this->assertInternalType(
'string', $items[0][
'timestamp'] );
552 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
577 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
586 $store->updateNotificationTimestamp(
598 'notificationtimestamp' =>
'2015-12-12T01:01:01Z',
606 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
612 'Create the page (this gets patrolled)',
620 $testUser = static::getTestSysop();
621 $user = $testUser->getUser();
631 'unpatrolled' =>
false,
632 'autopatrolled' =>
false,
644 'Create the page that will be deleted'
646 $this->
deletePage( $target,
'Important Reason' );
650 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
662 'logtype' =>
'delete',
663 'logaction' =>
'delete',
667 [
'type',
'logtype',
'logaction',
'logparams' ],
674 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
697 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
698 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
703 'target' => $subjectTarget,
704 'content' =>
'Some Content',
705 'summary' =>
'Create the page',
708 'target' => $talkTarget,
709 'content' =>
'Some Content',
710 'summary' =>
'Create the talk page',
733 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
734 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
744 'What is this page about?',
745 'Create the talk page'
750 'wlprop' =>
'user|title',
751 'wluser' => $otherUser->getName(),
758 'ns' => $talkTarget->getNamespace(),
760 'user' => $otherUser->getName(),
770 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
771 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
781 'What is this page about?',
782 'Create the talk page'
787 'wlprop' =>
'user|title',
788 'wlexcludeuser' => $otherUser->getName(),
795 'ns' => $subjectTarget->getNamespace(),
797 'user' =>
$user->getName(),
806 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
812 'content' =>
'Some Content',
813 'summary' =>
'Create the page',
817 'content' =>
'Slightly Better Content',
818 'summary' =>
'Change content',
845 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
873 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
903 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
904 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
915 'Create the talk page'
918 $store->addWatchBatchForUser(
$user, [ $subjectTarget, $talkTarget ] );
919 $store->updateNotificationTimestamp(
926 'wlprop' =>
'notificationtimestamp|title',
930 'wlprop' =>
'notificationtimestamp|title',
938 'notificationtimestamp' =>
'2015-12-12T01:01:01Z',
939 'ns' => $talkTarget->getNamespace(),
949 'notificationtimestamp' =>
'',
950 'ns' => $subjectTarget->getNamespace(),
959 $user = static::getTestSysop()->getUser();
963 'wlprop' =>
'patrol',
967 'wlprop' =>
'patrol',
976 'unpatrolled' =>
false,
977 'autopatrolled' =>
false,
987 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
988 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
993 'target' => $subjectTarget,
994 'content' =>
'Some Content',
995 'summary' =>
'Create the page',
998 'target' => $subjectTarget,
999 'content' =>
'Some Other Content',
1000 'summary' =>
'Change the content',
1003 'target' => $talkTarget,
1004 'content' =>
'Some Talk Page Content',
1005 'summary' =>
'Create Talk page',
1014 $this->assertEquals(
1018 'ns' => $talkTarget->getNamespace(),
1024 $this->assertEquals(
1028 'ns' => $subjectTarget->getNamespace(),
1038 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1039 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1044 'Some Talk Page Content',
1051 $this->assertEquals(
1055 'ns' => $subjectTarget->getNamespace(),
1070 'rc_namespace' =>
$title->getNamespace(),
1071 'rc_title' =>
$title->getDBkey(),
1073 'rc_source' =>
'foo',
1075 'rc_cur_id' =>
$title->getArticleID(),
1077 'rc_user_text' =>
'ext>External User',
1079 'rc_comment_text' =>
'',
1080 'rc_comment_data' =>
null,
1081 'rc_this_oldid' =>
$title->getLatestRevID(),
1082 'rc_last_oldid' =>
$title->getLatestRevID(),
1085 'rc_patrolled' => 0,
1087 'rc_old_len' =>
$title->getLength(),
1088 'rc_new_len' =>
$title->getLength(),
1091 'rc_log_type' =>
null,
1092 'rc_log_action' =>
'',
1096 'prefixedDBkey' =>
$title->getPrefixedDBkey(),
1097 'lastTimestamp' => 0,
1098 'oldSize' =>
$title->getLength(),
1099 'newSize' =>
$title->getLength(),
1100 'pageStatus' =>
'changed'
1108 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1109 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1119 'Some Talk Page Content',
1130 $this->assertEquals(
1133 'type' =>
'external',
1134 'ns' => $subjectTarget->getNamespace(),
1144 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1150 'target' => $categoryTarget,
1151 'content' =>
'Some Content',
1152 'summary' =>
'Create the category',
1155 'target' => $subjectTarget,
1156 'content' =>
'Some Content [[Category:ApiQueryWatchlistIntegrationTestCategory]]t',
1157 'summary' =>
'Create the page and add it to the category',
1165 $revision->getTimestamp(),
1168 $revision->getComment(),
1181 $this->assertEquals(
1184 'type' =>
'categorize',
1185 'ns' => $categoryTarget->getNamespace(),
1195 $target1 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1196 $target2 =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1197 $target3 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage2' );
1202 'target' => $target1,
1203 'content' =>
'Some Content',
1204 'summary' =>
'Create the page',
1207 'target' => $target2,
1208 'content' =>
'Some Talk Page Content',
1209 'summary' =>
'Create Talk page',
1212 'target' => $target3,
1213 'content' =>
'Some Other Content',
1214 'summary' =>
'Create the page',
1223 $this->assertEquals(
1227 'ns' => $target3->getNamespace(),
1232 'ns' => $target2->getNamespace(),
1237 'ns' => $target1->getNamespace(),
1243 $this->assertEquals(
1247 'ns' => $target3->getNamespace(),
1252 'ns' => $target2->getNamespace(),
1258 $this->assertArrayHasKey(
'continue', $resultWithLimit[0] );
1259 $this->assertArrayHasKey(
'wlcontinue', $resultWithLimit[0][
'continue'] );
1264 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1269 'target' => $target,
1270 'content' =>
'Some Content',
1271 'summary' =>
'Create the page',
1274 'target' => $target,
1275 'content' =>
'Some Other Content',
1276 'summary' =>
'Change the content',
1285 $this->assertEquals(
1289 'ns' => $target->getNamespace(),
1295 $this->assertEquals(
1299 'ns' => $target->getNamespace(),
1304 'ns' => $target->getNamespace(),
1314 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1315 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1320 'target' => $subjectTarget,
1321 'content' =>
'Some Content',
1322 'summary' =>
'Create the page',
1325 'target' => $talkTarget,
1326 'content' =>
'Some Talk Page Content',
1327 'summary' =>
'Create Talk page',
1336 $this->assertEquals(
1340 'ns' => $talkTarget->getNamespace(),
1345 'ns' => $subjectTarget->getNamespace(),
1351 $this->assertEquals(
1355 'ns' => $subjectTarget->getNamespace(),
1360 'ns' => $talkTarget->getNamespace(),
1370 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1380 'wlstart' =>
'20010115000000',
1382 'wlprop' =>
'title',
1385 'wlend' =>
'20010115000000',
1387 'wlprop' =>
'title',
1390 $this->assertEquals(
1394 'ns' => $target->getNamespace(),
1405 $target1 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1406 $target2 =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1407 $target3 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage2' );
1412 'target' => $target1,
1413 'content' =>
'Some Content',
1414 'summary' =>
'Create the page',
1417 'target' => $target2,
1418 'content' =>
'Some Talk Page Content',
1419 'summary' =>
'Create Talk page',
1422 'target' => $target3,
1423 'content' =>
'Some Other Content',
1424 'summary' =>
'Create the page',
1431 $this->assertArrayHasKey(
'continue', $firstResult[0] );
1432 $this->assertArrayHasKey(
'wlcontinue', $firstResult[0][
'continue'] );
1434 $continuationParam = $firstResult[0][
'continue'][
'wlcontinue'];
1437 [
'wlcontinue' => $continuationParam,
'wlprop' =>
'title' ]
1440 $this->assertEquals(
1444 'ns' => $target3->getNamespace(),
1449 'ns' => $target2->getNamespace(),
1455 $this->assertEquals(
1459 'ns' => $target1->getNamespace(),
1468 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1477 $otherUser->setOption(
'watchlisttoken',
'1234567890' );
1478 $otherUser->saveSettings();
1480 $this->
watchPages( $otherUser, [ $target ] );
1483 $this->assertEquals(
'1234567890', $reloadedUser->getOption(
'watchlisttoken' ) );
1486 'wlowner' => $otherUser->getName(),
1487 'wltoken' =>
'1234567890',
1488 'wlprop' =>
'title',
1491 $this->assertEquals(
1495 'ns' => $target->getNamespace(),
1505 $otherUser->setOption(
'watchlisttoken',
'1234567890' );
1506 $otherUser->saveSettings();
1511 'wlowner' => $otherUser->getName(),
1512 'wltoken' =>
'wrong-token',
1521 'wltoken' =>
'some-token',
1527 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1538 $this->assertArrayHasKey(
'query',
$result[0] );
1539 $this->assertArrayHasKey(
'pages',
$result[0][
'query'] );
1542 $pages = array_values(
$result[0][
'query'][
'pages'] );
1548 'ns' => $target->getNamespace(),
1553 [
'ns',
'title',
'new' ]
1559 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1564 'target' => $target,
1565 'content' =>
'Some Content',
1566 'summary' =>
'Create the page',
1569 'target' => $target,
1570 'content' =>
'Some Other Content',
1571 'summary' =>
'Change the content',
1579 $this->assertArrayHasKey(
'query',
$result[0] );
1580 $this->assertArrayHasKey(
'pages',
$result[0][
'query'] );
1583 $pages = array_values(
$result[0][
'query'][
'pages'] );
1585 $this->assertCount( 1, $pages );
1586 $this->assertEquals( 0, $pages[0][
'ns'] );
1587 $this->assertEquals( $this->
getPrefixedText( $target ), $pages[0][
'title'] );
1589 $pages[0][
'revisions'],
1592 'comment' =>
'Create the page',
1593 'user' =>
$user->getName(),
1597 'comment' =>
'Change the content',
1598 'user' =>
$user->getName(),
1602 [
'comment',
'user',
'minor' ]