16 parent::__construct(
$name, $data, $dataName );
17 $this->tablesUsed = array_unique(
18 array_merge( $this->tablesUsed, [
'watchlist',
'recentchanges',
'page' ] )
26 $this->
doLogin(
'ApiQueryWatchlistIntegrationTestUser' );
30 return self::$users[
'ApiQueryWatchlistIntegrationTestUser']->getUser();
34 return self::$users[
'ApiQueryWatchlistIntegrationTestUser2']->getUser();
103 $rc =
$rev->getRecentChange();
104 $rc->doMarkPatrolled( $patrollingUser,
false, [] );
110 $page->doDeleteArticleReal( $reason );
124 foreach ( $editData
as $singleEditData ) {
125 if ( array_key_exists(
'minorEdit', $singleEditData ) && $singleEditData[
'minorEdit'] ) {
128 $singleEditData[
'target'],
129 $singleEditData[
'content'],
130 $singleEditData[
'summary']
134 if ( array_key_exists(
'botEdit', $singleEditData ) && $singleEditData[
'botEdit'] ) {
137 $singleEditData[
'target'],
138 $singleEditData[
'content'],
139 $singleEditData[
'summary']
145 $singleEditData[
'target'],
146 $singleEditData[
'content'],
147 $singleEditData[
'summary']
153 return MediaWikiServices::getInstance()->getWatchedItemStore();
162 $store->addWatchBatchForUser(
$user, $targets );
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,
643 'Create the page that will be deleted'
645 $this->
deletePage( $target,
'Important Reason' );
649 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
661 'logtype' =>
'delete',
662 'logaction' =>
'delete',
666 [
'type',
'logtype',
'logaction',
'logparams' ],
673 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
696 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
697 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
702 'target' => $subjectTarget,
703 'content' =>
'Some Content',
704 'summary' =>
'Create the page',
707 'target' => $talkTarget,
708 'content' =>
'Some Content',
709 'summary' =>
'Create the talk page',
732 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
733 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
743 'What is this page about?',
744 'Create the talk page'
749 'wlprop' =>
'user|title',
750 'wluser' => $otherUser->getName(),
757 'ns' => $talkTarget->getNamespace(),
759 'user' => $otherUser->getName(),
769 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
770 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
780 'What is this page about?',
781 'Create the talk page'
786 'wlprop' =>
'user|title',
787 'wlexcludeuser' => $otherUser->getName(),
794 'ns' => $subjectTarget->getNamespace(),
796 'user' =>
$user->getName(),
805 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
811 'content' =>
'Some Content',
812 'summary' =>
'Create the page',
816 'content' =>
'Slightly Better Content',
817 'summary' =>
'Change content',
844 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
872 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
902 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
903 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
914 'Create the talk page'
917 $store->addWatchBatchForUser(
$user, [ $subjectTarget, $talkTarget ] );
918 $store->updateNotificationTimestamp(
925 'wlprop' =>
'notificationtimestamp|title',
929 'wlprop' =>
'notificationtimestamp|title',
937 'notificationtimestamp' =>
'2015-12-12T01:01:01Z',
938 'ns' => $talkTarget->getNamespace(),
948 'notificationtimestamp' =>
'',
949 'ns' => $subjectTarget->getNamespace(),
958 $user = static::getTestSysop()->getUser();
962 'wlprop' =>
'patrol',
966 'wlprop' =>
'patrol',
975 'unpatrolled' =>
false,
985 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
986 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
991 'target' => $subjectTarget,
992 'content' =>
'Some Content',
993 'summary' =>
'Create the page',
996 'target' => $subjectTarget,
997 'content' =>
'Some Other Content',
998 'summary' =>
'Change the content',
1001 'target' => $talkTarget,
1002 'content' =>
'Some Talk Page Content',
1003 'summary' =>
'Create Talk page',
1012 $this->assertEquals(
1016 'ns' => $talkTarget->getNamespace(),
1022 $this->assertEquals(
1026 'ns' => $subjectTarget->getNamespace(),
1036 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1037 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1042 'Some Talk Page Content',
1049 $this->assertEquals(
1053 'ns' => $subjectTarget->getNamespace(),
1068 'rc_namespace' =>
$title->getNamespace(),
1069 'rc_title' =>
$title->getDBkey(),
1071 'rc_source' =>
'foo',
1073 'rc_cur_id' =>
$title->getArticleID(),
1075 'rc_user_text' =>
'External User',
1077 'rc_comment_text' =>
'',
1078 'rc_comment_data' =>
null,
1079 'rc_this_oldid' =>
$title->getLatestRevID(),
1080 'rc_last_oldid' =>
$title->getLatestRevID(),
1083 'rc_patrolled' => 0,
1085 'rc_old_len' =>
$title->getLength(),
1086 'rc_new_len' =>
$title->getLength(),
1089 'rc_log_type' =>
null,
1090 'rc_log_action' =>
'',
1094 'prefixedDBkey' =>
$title->getPrefixedDBkey(),
1095 'lastTimestamp' => 0,
1096 'oldSize' =>
$title->getLength(),
1097 'newSize' =>
$title->getLength(),
1098 'pageStatus' =>
'changed'
1106 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1107 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1117 'Some Talk Page Content',
1128 $this->assertEquals(
1131 'type' =>
'external',
1132 'ns' => $subjectTarget->getNamespace(),
1142 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1148 'target' => $categoryTarget,
1149 'content' =>
'Some Content',
1150 'summary' =>
'Create the category',
1153 'target' => $subjectTarget,
1154 'content' =>
'Some Content [[Category:ApiQueryWatchlistIntegrationTestCategory]]t',
1155 'summary' =>
'Create the page and add it to the category',
1163 $revision->getTimestamp(),
1166 $revision->getComment(),
1179 $this->assertEquals(
1182 'type' =>
'categorize',
1183 'ns' => $categoryTarget->getNamespace(),
1193 $target1 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1194 $target2 =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1195 $target3 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage2' );
1200 'target' => $target1,
1201 'content' =>
'Some Content',
1202 'summary' =>
'Create the page',
1205 'target' => $target2,
1206 'content' =>
'Some Talk Page Content',
1207 'summary' =>
'Create Talk page',
1210 'target' => $target3,
1211 'content' =>
'Some Other Content',
1212 'summary' =>
'Create the page',
1221 $this->assertEquals(
1225 'ns' => $target3->getNamespace(),
1230 'ns' => $target2->getNamespace(),
1235 'ns' => $target1->getNamespace(),
1241 $this->assertEquals(
1245 'ns' => $target3->getNamespace(),
1250 'ns' => $target2->getNamespace(),
1256 $this->assertArrayHasKey(
'continue', $resultWithLimit[0] );
1257 $this->assertArrayHasKey(
'wlcontinue', $resultWithLimit[0][
'continue'] );
1262 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1267 'target' => $target,
1268 'content' =>
'Some Content',
1269 'summary' =>
'Create the page',
1272 'target' => $target,
1273 'content' =>
'Some Other Content',
1274 'summary' =>
'Change the content',
1283 $this->assertEquals(
1287 'ns' => $target->getNamespace(),
1293 $this->assertEquals(
1297 'ns' => $target->getNamespace(),
1302 'ns' => $target->getNamespace(),
1312 $subjectTarget =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1313 $talkTarget =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1318 'target' => $subjectTarget,
1319 'content' =>
'Some Content',
1320 'summary' =>
'Create the page',
1323 'target' => $talkTarget,
1324 'content' =>
'Some Talk Page Content',
1325 'summary' =>
'Create Talk page',
1334 $this->assertEquals(
1338 'ns' => $talkTarget->getNamespace(),
1343 'ns' => $subjectTarget->getNamespace(),
1349 $this->assertEquals(
1353 'ns' => $subjectTarget->getNamespace(),
1358 'ns' => $talkTarget->getNamespace(),
1368 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1378 'wlstart' =>
'20010115000000',
1380 'wlprop' =>
'title',
1383 'wlend' =>
'20010115000000',
1385 'wlprop' =>
'title',
1388 $this->assertEquals(
1392 'ns' => $target->getNamespace(),
1403 $target1 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1404 $target2 =
new TitleValue( 1,
'ApiQueryWatchlistIntegrationTestPage' );
1405 $target3 =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage2' );
1410 'target' => $target1,
1411 'content' =>
'Some Content',
1412 'summary' =>
'Create the page',
1415 'target' => $target2,
1416 'content' =>
'Some Talk Page Content',
1417 'summary' =>
'Create Talk page',
1420 'target' => $target3,
1421 'content' =>
'Some Other Content',
1422 'summary' =>
'Create the page',
1429 $this->assertArrayHasKey(
'continue', $firstResult[0] );
1430 $this->assertArrayHasKey(
'wlcontinue', $firstResult[0][
'continue'] );
1432 $continuationParam = $firstResult[0][
'continue'][
'wlcontinue'];
1435 [
'wlcontinue' => $continuationParam,
'wlprop' =>
'title' ]
1438 $this->assertEquals(
1442 'ns' => $target3->getNamespace(),
1447 'ns' => $target2->getNamespace(),
1453 $this->assertEquals(
1457 'ns' => $target1->getNamespace(),
1466 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1475 $otherUser->setOption(
'watchlisttoken',
'1234567890' );
1476 $otherUser->saveSettings();
1478 $this->
watchPages( $otherUser, [ $target ] );
1481 $this->assertEquals(
'1234567890', $reloadedUser->getOption(
'watchlisttoken' ) );
1484 'wlowner' => $otherUser->getName(),
1485 'wltoken' =>
'1234567890',
1486 'wlprop' =>
'title',
1489 $this->assertEquals(
1493 'ns' => $target->getNamespace(),
1503 $otherUser->setOption(
'watchlisttoken',
'1234567890' );
1504 $otherUser->saveSettings();
1509 'wlowner' => $otherUser->getName(),
1510 'wltoken' =>
'wrong-token',
1519 'wltoken' =>
'some-token',
1525 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1536 $this->assertArrayHasKey(
'query',
$result[0] );
1537 $this->assertArrayHasKey(
'pages',
$result[0][
'query'] );
1540 $pages = array_values(
$result[0][
'query'][
'pages'] );
1546 'ns' => $target->getNamespace(),
1551 [
'ns',
'title',
'new' ]
1557 $target =
new TitleValue( 0,
'ApiQueryWatchlistIntegrationTestPage' );
1562 'target' => $target,
1563 'content' =>
'Some Content',
1564 'summary' =>
'Create the page',
1567 'target' => $target,
1568 'content' =>
'Some Other Content',
1569 'summary' =>
'Change the content',
1577 $this->assertArrayHasKey(
'query',
$result[0] );
1578 $this->assertArrayHasKey(
'pages',
$result[0][
'query'] );
1581 $pages = array_values(
$result[0][
'query'][
'pages'] );
1583 $this->assertCount( 1, $pages );
1584 $this->assertEquals( 0, $pages[0][
'ns'] );
1585 $this->assertEquals( $this->
getPrefixedText( $target ), $pages[0][
'title'] );
1587 $pages[0][
'revisions'],
1590 'comment' =>
'Create the page',
1591 'user' =>
$user->getName(),
1595 'comment' =>
'Change the content',
1596 'user' =>
$user->getName(),
1600 [
'comment',
'user',
'minor' ]