16 parent::__construct(
$name, $data, $dataName );
17 $this->tablesUsed = array_unique(
18 array_merge( $this->tablesUsed, [
'watchlist',
'recentchanges',
'page' ] )
29 return self::$users[
'ApiQueryWatchlistIntegrationTestUser']->getUser();
33 return self::$users[
'ApiQueryWatchlistIntegrationTestUser2']->getUser();
102 $rc =
$rev->getRecentChange();
103 $rc->doMarkPatrolled( $patrollingUser,
false, [] );
109 $page->doDeleteArticleReal( $reason );
123 foreach ( $editData
as $singleEditData ) {
124 if ( array_key_exists(
'minorEdit', $singleEditData ) && $singleEditData[
'minorEdit'] ) {
127 $singleEditData[
'target'],
128 $singleEditData[
'content'],
129 $singleEditData[
'summary']
133 if ( array_key_exists(
'botEdit', $singleEditData ) && $singleEditData[
'botEdit'] ) {
136 $singleEditData[
'target'],
137 $singleEditData[
'content'],
138 $singleEditData[
'summary']
144 $singleEditData[
'target'],
145 $singleEditData[
'content'],
146 $singleEditData[
'summary']
152 return MediaWikiServices::getInstance()->getWatchedItemStore();
161 $store->addWatchBatchForUser(
$user, $targets );
165 if (
$user ===
null ) {
170 [
'action' =>
'query',
'list' =>
'watchlist' ],
172 ),
null,
false,
$user
179 [
'action' =>
'query',
'generator' =>
'watchlist' ],
186 return $response[0][
'query'][
'watchlist'];
207 array $expectedItems,
208 array $keysUsedInValueComparison,
209 array $requiredKeys = []
211 $this->assertCount(
count( $expectedItems ), $actualItems );
214 $actualItemsOnlyComparedValues = array_map(
215 function (
array $item )
use ( $keysUsedInValueComparison ) {
216 return array_intersect_key( $item, array_flip( $keysUsedInValueComparison ) );
223 $actualItemsOnlyComparedValues
227 $actualItemsKeysOnly = array_map(
'array_keys', $actualItems );
228 foreach ( $actualItemsKeysOnly
as $keysOfTheItem ) {
229 $this->assertEmpty( array_diff( $requiredKeys, $keysOfTheItem ) );
236 MediaWikiServices::getInstance()->getGenderCache()
242 return $formatter->getPrefixedText( $target );
248 $items = $store->getWatchedItemsForUser(
$user );
249 foreach ( $items
as $item ) {
250 $store->removeWatch(
$user, $item->getLinkTarget() );
260 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
271 $this->assertArrayHasKey(
'query',
$result[0] );
272 $this->assertArrayHasKey(
'watchlist',
$result[0][
'query'] );
279 'ns' => $target->getNamespace(),
286 [
'type',
'ns',
'title',
'bot',
'new',
'minor' ],
287 [
'pageid',
'revid',
'old_revid' ]
293 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
305 $this->assertCount( 1, $items );
306 $this->assertArrayHasKey(
'pageid', $items[0] );
307 $this->assertArrayHasKey(
'revid', $items[0] );
308 $this->assertArrayHasKey(
'old_revid', $items[0] );
309 $this->assertEquals(
'new', $items[0][
'type'] );
314 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
315 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
320 'target' => $subjectTarget,
321 'content' =>
'Some Content',
322 'summary' =>
'Create the page',
325 'target' => $talkTarget,
326 'content' =>
'Some Talk Page Content',
327 'summary' =>
'Create Talk page',
339 'ns' => $talkTarget->getNamespace(),
344 'ns' => $subjectTarget->getNamespace(),
354 $normalEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
355 $minorEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageM' );
356 $botEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageB' );
361 'target' => $normalEditTarget,
362 'content' =>
'Some Content',
363 'summary' =>
'Create the page',
366 'target' => $minorEditTarget,
367 'content' =>
'Some Content',
368 'summary' =>
'Create the page',
371 'target' => $minorEditTarget,
372 'content' =>
'Slightly Better Content',
373 'summary' =>
'Change content',
377 'target' => $botEditTarget,
378 'content' =>
'Some Content',
379 'summary' =>
'Create the page with a bot',
384 $this->
watchPages(
$user, [ $normalEditTarget, $minorEditTarget, $botEditTarget ] );
415 $userEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
416 $anonEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageA' );
441 'user' =>
$user->getName(),
450 $userEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
451 $anonEditTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPageA' );
477 'user' =>
$user->getId(),
478 'userid' =>
$user->getId(),
487 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
492 'Create the <b>page</b>'
502 'comment' =>
'Create the <b>page</b>',
511 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
516 'Create the <b>page</b>'
526 'parsedcomment' =>
'Create the <b>page</b>',
535 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
547 $this->assertCount( 1, $items );
548 $this->assertArrayHasKey(
'timestamp', $items[0] );
549 $this->assertInternalType(
'string', $items[0][
'timestamp'] );
554 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
579 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
588 $store->updateNotificationTimestamp(
600 'notificationtimestamp' =>
'2015-12-12T01:01:01Z',
608 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
614 'Create the page (this gets patrolled)',
622 $testUser = static::getTestSysop();
623 $user = $testUser->getUser();
633 'unpatrolled' =>
false,
634 'autopatrolled' =>
false,
646 'Create the page that will be deleted'
648 $this->
deletePage( $target,
'Important Reason' );
652 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
664 'logtype' =>
'delete',
665 'logaction' =>
'delete',
669 [
'type',
'logtype',
'logaction',
'logparams' ],
676 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
699 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
700 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
705 'target' => $subjectTarget,
706 'content' =>
'Some Content',
707 'summary' =>
'Create the page',
710 'target' => $talkTarget,
711 'content' =>
'Some Content',
712 'summary' =>
'Create the talk page',
735 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
736 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
746 'What is this page about?',
747 'Create the talk page'
752 'wlprop' =>
'user|title',
753 'wluser' => $otherUser->getName(),
760 'ns' => $talkTarget->getNamespace(),
762 'user' => $otherUser->getName(),
772 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
773 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
783 'What is this page about?',
784 'Create the talk page'
789 'wlprop' =>
'user|title',
790 'wlexcludeuser' => $otherUser->getName(),
797 'ns' => $subjectTarget->getNamespace(),
799 'user' =>
$user->getName(),
808 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
814 'content' =>
'Some Content',
815 'summary' =>
'Create the page',
819 'content' =>
'Slightly Better Content',
820 'summary' =>
'Change content',
847 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
875 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
905 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
906 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
917 'Create the talk page'
920 $store->addWatchBatchForUser(
$user, [ $subjectTarget, $talkTarget ] );
921 $store->updateNotificationTimestamp(
928 'wlprop' =>
'notificationtimestamp|title',
932 'wlprop' =>
'notificationtimestamp|title',
940 'notificationtimestamp' =>
'2015-12-12T01:01:01Z',
941 'ns' => $talkTarget->getNamespace(),
951 'notificationtimestamp' =>
'',
952 'ns' => $subjectTarget->getNamespace(),
961 $user = static::getTestSysop()->getUser();
965 'wlprop' =>
'patrol',
969 'wlprop' =>
'patrol',
978 'unpatrolled' =>
false,
979 'autopatrolled' =>
false,
989 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
990 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
995 'target' => $subjectTarget,
996 'content' =>
'Some Content',
997 'summary' =>
'Create the page',
1000 'target' => $subjectTarget,
1001 'content' =>
'Some Other Content',
1002 'summary' =>
'Change the content',
1005 'target' => $talkTarget,
1006 'content' =>
'Some Talk Page Content',
1007 'summary' =>
'Create Talk page',
1016 $this->assertEquals(
1020 'ns' => $talkTarget->getNamespace(),
1026 $this->assertEquals(
1030 'ns' => $subjectTarget->getNamespace(),
1040 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1041 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1046 'Some Talk Page Content',
1053 $this->assertEquals(
1057 'ns' => $subjectTarget->getNamespace(),
1072 'rc_namespace' =>
$title->getNamespace(),
1073 'rc_title' =>
$title->getDBkey(),
1075 'rc_source' =>
'foo',
1077 'rc_cur_id' =>
$title->getArticleID(),
1079 'rc_user_text' =>
'ext>External User',
1081 'rc_comment_text' =>
'',
1082 'rc_comment_data' =>
null,
1083 'rc_this_oldid' =>
$title->getLatestRevID(),
1084 'rc_last_oldid' =>
$title->getLatestRevID(),
1087 'rc_patrolled' => 0,
1089 'rc_old_len' =>
$title->getLength(),
1090 'rc_new_len' =>
$title->getLength(),
1093 'rc_log_type' =>
null,
1094 'rc_log_action' =>
'',
1098 'prefixedDBkey' =>
$title->getPrefixedDBkey(),
1099 'lastTimestamp' => 0,
1100 'oldSize' =>
$title->getLength(),
1101 'newSize' =>
$title->getLength(),
1102 'pageStatus' =>
'changed'
1110 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1111 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1121 'Some Talk Page Content',
1132 $this->assertEquals(
1135 'type' =>
'external',
1136 'ns' => $subjectTarget->getNamespace(),
1146 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1152 'target' => $categoryTarget,
1153 'content' =>
'Some Content',
1154 'summary' =>
'Create the category',
1157 'target' => $subjectTarget,
1158 'content' =>
'Some Content [[Category:ApiQueryWatchlistIntegrationTestCategory]]t',
1159 'summary' =>
'Create the page and add it to the category',
1167 $revision->getTimestamp(),
1170 $revision->getComment(),
1183 $this->assertEquals(
1186 'type' =>
'categorize',
1187 'ns' => $categoryTarget->getNamespace(),
1197 $target1 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1198 $target2 =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1199 $target3 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage2' );
1204 'target' => $target1,
1205 'content' =>
'Some Content',
1206 'summary' =>
'Create the page',
1209 'target' => $target2,
1210 'content' =>
'Some Talk Page Content',
1211 'summary' =>
'Create Talk page',
1214 'target' => $target3,
1215 'content' =>
'Some Other Content',
1216 'summary' =>
'Create the page',
1225 $this->assertEquals(
1229 'ns' => $target3->getNamespace(),
1234 'ns' => $target2->getNamespace(),
1239 'ns' => $target1->getNamespace(),
1245 $this->assertEquals(
1249 'ns' => $target3->getNamespace(),
1254 'ns' => $target2->getNamespace(),
1260 $this->assertArrayHasKey(
'continue', $resultWithLimit[0] );
1261 $this->assertArrayHasKey(
'wlcontinue', $resultWithLimit[0][
'continue'] );
1266 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1271 'target' => $target,
1272 'content' =>
'Some Content',
1273 'summary' =>
'Create the page',
1276 'target' => $target,
1277 'content' =>
'Some Other Content',
1278 'summary' =>
'Change the content',
1287 $this->assertEquals(
1291 'ns' => $target->getNamespace(),
1297 $this->assertEquals(
1301 'ns' => $target->getNamespace(),
1306 'ns' => $target->getNamespace(),
1316 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1317 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1322 'target' => $subjectTarget,
1323 'content' =>
'Some Content',
1324 'summary' =>
'Create the page',
1327 'target' => $talkTarget,
1328 'content' =>
'Some Talk Page Content',
1329 'summary' =>
'Create Talk page',
1338 $this->assertEquals(
1342 'ns' => $talkTarget->getNamespace(),
1347 'ns' => $subjectTarget->getNamespace(),
1353 $this->assertEquals(
1357 'ns' => $subjectTarget->getNamespace(),
1362 'ns' => $talkTarget->getNamespace(),
1372 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1382 'wlstart' =>
'20010115000000',
1384 'wlprop' =>
'title',
1387 'wlend' =>
'20010115000000',
1389 'wlprop' =>
'title',
1392 $this->assertEquals(
1396 'ns' => $target->getNamespace(),
1407 $target1 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1408 $target2 =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1409 $target3 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage2' );
1414 'target' => $target1,
1415 'content' =>
'Some Content',
1416 'summary' =>
'Create the page',
1419 'target' => $target2,
1420 'content' =>
'Some Talk Page Content',
1421 'summary' =>
'Create Talk page',
1424 'target' => $target3,
1425 'content' =>
'Some Other Content',
1426 'summary' =>
'Create the page',
1433 $this->assertArrayHasKey(
'continue', $firstResult[0] );
1434 $this->assertArrayHasKey(
'wlcontinue', $firstResult[0][
'continue'] );
1436 $continuationParam = $firstResult[0][
'continue'][
'wlcontinue'];
1439 [
'wlcontinue' => $continuationParam,
'wlprop' =>
'title' ]
1442 $this->assertEquals(
1446 'ns' => $target3->getNamespace(),
1451 'ns' => $target2->getNamespace(),
1457 $this->assertEquals(
1461 'ns' => $target1->getNamespace(),
1470 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1479 $otherUser->setOption(
'watchlisttoken',
'1234567890' );
1480 $otherUser->saveSettings();
1482 $this->
watchPages( $otherUser, [ $target ] );
1485 $this->assertEquals(
'1234567890', $reloadedUser->getOption(
'watchlisttoken' ) );
1488 'wlowner' => $otherUser->getName(),
1489 'wltoken' =>
'1234567890',
1490 'wlprop' =>
'title',
1493 $this->assertEquals(
1497 'ns' => $target->getNamespace(),
1507 $otherUser->setOption(
'watchlisttoken',
'1234567890' );
1508 $otherUser->saveSettings();
1513 'wlowner' => $otherUser->getName(),
1514 'wltoken' =>
'wrong-token',
1523 'wltoken' =>
'some-token',
1529 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1540 $this->assertArrayHasKey(
'query',
$result[0] );
1541 $this->assertArrayHasKey(
'pages',
$result[0][
'query'] );
1544 $pages = array_values(
$result[0][
'query'][
'pages'] );
1550 'ns' => $target->getNamespace(),
1555 [
'ns',
'title',
'new' ]
1561 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1566 'target' => $target,
1567 'content' =>
'Some Content',
1568 'summary' =>
'Create the page',
1571 'target' => $target,
1572 'content' =>
'Some Other Content',
1573 'summary' =>
'Change the content',
1581 $this->assertArrayHasKey(
'query',
$result[0] );
1582 $this->assertArrayHasKey(
'pages',
$result[0][
'query'] );
1585 $pages = array_values(
$result[0][
'query'][
'pages'] );
1587 $this->assertCount( 1, $pages );
1588 $this->assertEquals( 0, $pages[0][
'ns'] );
1589 $this->assertEquals( $this->
getPrefixedText( $target ), $pages[0][
'title'] );
1591 $pages[0][
'revisions'],
1594 'comment' =>
'Create the page',
1595 'user' =>
$user->getName(),
1599 'comment' =>
'Change the content',
1600 'user' =>
$user->getName(),
1604 [
'comment',
'user',
'minor' ]