24 $expectedConnectionType = null,
25 $readOnlyReason =
false
28 ->disableOriginalConstructor()
30 if ( $expectedConnectionType !== null ) {
31 $mock->expects( $this->any() )
32 ->method(
'getConnectionRef' )
33 ->with( $expectedConnectionType )
34 ->will( $this->returnValue( $mockDb ) );
36 $mock->expects( $this->any() )
37 ->method(
'getConnectionRef' )
38 ->will( $this->returnValue( $mockDb ) );
40 $mock->expects( $this->any() )
41 ->method(
'getReadOnlyReason' )
42 ->will( $this->returnValue( $readOnlyReason ) );
51 ->disableOriginalConstructor()
53 $mock->expects( $this->any() )
55 ->will( $this->returnCallback(
function() {
56 return implode(
':', func_get_args() );
67 $mock->expects( $this->any() )
69 ->will( $this->returnValue(
false ) );
70 $mock->expects( $this->any() )
72 ->will( $this->returnValue( $id ) );
84 $fakeRow =
new stdClass();
85 foreach ( $rowValues
as $valueName =>
$value ) {
86 $fakeRow->$valueName =
$value;
102 $mockDb->expects( $this->exactly( 1 ) )
103 ->method(
'selectField' )
108 'wl_user' =>
$user->getId(),
110 $this->isType(
'string' )
112 ->
will( $this->returnValue( 12 ) );
115 $mockCache->expects( $this->never() )->method(
'get' );
116 $mockCache->expects( $this->never() )->method(
'set' );
117 $mockCache->expects( $this->never() )->method(
'delete' );
124 $this->assertEquals( 12, $store->countWatchedItems(
$user ) );
128 $titleValue =
new TitleValue( 0,
'SomeDbKey' );
131 $mockDb->expects( $this->exactly( 1 ) )
132 ->method(
'selectField' )
137 'wl_namespace' => $titleValue->getNamespace(),
138 'wl_title' => $titleValue->getDBkey(),
140 $this->isType(
'string' )
142 ->
will( $this->returnValue( 7 ) );
145 $mockCache->expects( $this->never() )->method(
'get' );
146 $mockCache->expects( $this->never() )->method(
'set' );
147 $mockCache->expects( $this->never() )->method(
'delete' );
154 $this->assertEquals( 7, $store->countWatchers( $titleValue ) );
167 $this->
getFakeRow( [
'wl_title' =>
'SomeDbKey',
'wl_namespace' => 0,
'watchers' => 100 ] ),
168 $this->
getFakeRow( [
'wl_title' =>
'OtherDbKey',
'wl_namespace' => 0,
'watchers' => 300 ] ),
169 $this->
getFakeRow( [
'wl_title' =>
'AnotherDbKey',
'wl_namespace' => 1,
'watchers' => 500 ]
172 $mockDb->expects( $this->once() )
173 ->method(
'makeWhereFrom2d' )
175 [ [
'SomeDbKey' => 1,
'OtherDbKey' => 1 ], [
'AnotherDbKey' => 1 ] ],
176 $this->isType(
'string' ),
177 $this->isType(
'string' )
179 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
180 $mockDb->expects( $this->once() )
184 [
'wl_title',
'wl_namespace',
'watchers' =>
'COUNT(*)' ],
185 [
'makeWhereFrom2d return value' ],
186 $this->isType(
'string' ),
188 'GROUP BY' => [
'wl_namespace',
'wl_title' ],
192 $this->returnValue( $dbResult )
196 $mockCache->expects( $this->never() )->method(
'get' );
197 $mockCache->expects( $this->never() )->method(
'set' );
198 $mockCache->expects( $this->never() )->method(
'delete' );
206 0 => [
'SomeDbKey' => 100,
'OtherDbKey' => 300 ],
207 1 => [
'AnotherDbKey' => 500 ],
209 $this->assertEquals( $expected, $store->countWatchersMultiple( $titleValues ) );
215 [
"50; DROP TABLE watchlist;\n--" ],
232 $this->
getFakeRow( [
'wl_title' =>
'SomeDbKey',
'wl_namespace' => 0,
'watchers' => 100 ] ),
233 $this->
getFakeRow( [
'wl_title' =>
'OtherDbKey',
'wl_namespace' => 0,
'watchers' => 300 ] ),
234 $this->
getFakeRow( [
'wl_title' =>
'AnotherDbKey',
'wl_namespace' => 1,
'watchers' => 500 ]
237 $mockDb->expects( $this->once() )
238 ->method(
'makeWhereFrom2d' )
240 [ [
'SomeDbKey' => 1,
'OtherDbKey' => 1 ], [
'AnotherDbKey' => 1 ] ],
241 $this->isType(
'string' ),
242 $this->isType(
'string' )
244 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
245 $mockDb->expects( $this->once() )
249 [
'wl_title',
'wl_namespace',
'watchers' =>
'COUNT(*)' ],
250 [
'makeWhereFrom2d return value' ],
251 $this->isType(
'string' ),
253 'GROUP BY' => [
'wl_namespace',
'wl_title' ],
254 'HAVING' =>
'COUNT(*) >= 50',
258 $this->returnValue( $dbResult )
262 $mockCache->expects( $this->never() )->method(
'get' );
263 $mockCache->expects( $this->never() )->method(
'set' );
264 $mockCache->expects( $this->never() )->method(
'delete' );
272 0 => [
'SomeDbKey' => 100,
'OtherDbKey' => 300 ],
273 1 => [
'AnotherDbKey' => 500 ],
277 $store->countWatchersMultiple( $titleValues, [
'minimumWatchers' => $minWatchers ] )
282 $titleValue =
new TitleValue( 0,
'SomeDbKey' );
285 $mockDb->expects( $this->exactly( 1 ) )
286 ->method(
'selectField' )
291 'wl_namespace' => $titleValue->getNamespace(),
292 'wl_title' => $titleValue->getDBkey(),
293 'wl_notificationtimestamp >= \'TS111TS\' OR wl_notificationtimestamp IS NULL',
295 $this->isType(
'string' )
297 ->
will( $this->returnValue( 7 ) );
298 $mockDb->expects( $this->exactly( 1 ) )
299 ->method(
'addQuotes' )
300 ->will( $this->returnCallback(
function(
$value ) {
303 $mockDb->expects( $this->exactly( 1 ) )
304 ->method(
'timestamp' )
305 ->will( $this->returnCallback(
function(
$value ) {
306 return 'TS' .
$value .
'TS';
310 $mockCache->expects( $this->never() )->method(
'set' );
311 $mockCache->expects( $this->never() )->method(
'get' );
312 $mockCache->expects( $this->never() )->method(
'delete' );
319 $this->assertEquals( 7, $store->countVisitingWatchers( $titleValue,
'111' ) );
323 $titleValuesWithThresholds = [
326 [
new TitleValue( 1,
'AnotherDbKey' ),
'123' ],
330 $this->
getFakeRow( [
'wl_title' =>
'SomeDbKey',
'wl_namespace' => 0,
'watchers' => 100 ] ),
331 $this->
getFakeRow( [
'wl_title' =>
'OtherDbKey',
'wl_namespace' => 0,
'watchers' => 300 ] ),
332 $this->
getFakeRow( [
'wl_title' =>
'AnotherDbKey',
'wl_namespace' => 1,
'watchers' => 500 ] ),
335 $mockDb->expects( $this->exactly( 2 * 3 ) )
336 ->method(
'addQuotes' )
337 ->will( $this->returnCallback(
function(
$value ) {
340 $mockDb->expects( $this->exactly( 3 ) )
341 ->method(
'timestamp' )
342 ->will( $this->returnCallback(
function(
$value ) {
343 return 'TS' .
$value .
'TS';
345 $mockDb->expects( $this->any() )
346 ->method(
'makeList' )
348 $this->isType(
'array' ),
349 $this->isType(
'int' )
351 ->will( $this->returnCallback(
function( $a, $conj ) {
352 $sqlConj = $conj ===
LIST_AND ?
' AND ' :
' OR ';
353 return join( $sqlConj, array_map(
function(
$s ) {
354 return '(' .
$s .
')';
358 $mockDb->expects( $this->never() )
359 ->method(
'makeWhereFrom2d' );
362 '((wl_namespace = 0) AND (' .
363 "(((wl_title = 'SomeDbKey') AND (" .
364 "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
366 "(wl_title = 'OtherDbKey') AND (" .
367 "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
369 ') OR ((wl_namespace = 1) AND (' .
370 "(((wl_title = 'AnotherDbKey') AND (".
371 "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" .
373 $mockDb->expects( $this->once() )
377 [
'wl_namespace',
'wl_title',
'watchers' =>
'COUNT(*)' ],
379 $this->isType(
'string' ),
381 'GROUP BY' => [
'wl_namespace',
'wl_title' ],
385 $this->returnValue( $dbResult )
389 $mockCache->expects( $this->never() )->method(
'get' );
390 $mockCache->expects( $this->never() )->method(
'set' );
391 $mockCache->expects( $this->never() )->method(
'delete' );
399 0 => [
'SomeDbKey' => 100,
'OtherDbKey' => 300 ],
400 1 => [
'AnotherDbKey' => 500 ],
404 $store->countVisitingWatchersMultiple( $titleValuesWithThresholds )
409 $titleValuesWithThresholds = [
412 [
new TitleValue( 1,
'AnotherDbKey' ),
'123' ],
413 [
new TitleValue( 0,
'SomeNotExisitingDbKey' ), null ],
414 [
new TitleValue( 0,
'OtherNotExisitingDbKey' ), null ],
418 $this->
getFakeRow( [
'wl_title' =>
'SomeDbKey',
'wl_namespace' => 0,
'watchers' => 100 ] ),
419 $this->
getFakeRow( [
'wl_title' =>
'OtherDbKey',
'wl_namespace' => 0,
'watchers' => 300 ] ),
420 $this->
getFakeRow( [
'wl_title' =>
'AnotherDbKey',
'wl_namespace' => 1,
'watchers' => 500 ] ),
422 [
'wl_title' =>
'SomeNotExisitingDbKey',
'wl_namespace' => 0,
'watchers' => 100 ]
425 [
'wl_title' =>
'OtherNotExisitingDbKey',
'wl_namespace' => 0,
'watchers' => 200 ]
429 $mockDb->expects( $this->exactly( 2 * 3 ) )
430 ->method(
'addQuotes' )
431 ->will( $this->returnCallback(
function(
$value ) {
434 $mockDb->expects( $this->exactly( 3 ) )
435 ->method(
'timestamp' )
436 ->will( $this->returnCallback(
function(
$value ) {
437 return 'TS' .
$value .
'TS';
439 $mockDb->expects( $this->any() )
440 ->method(
'makeList' )
442 $this->isType(
'array' ),
443 $this->isType(
'int' )
445 ->will( $this->returnCallback(
function( $a, $conj ) {
446 $sqlConj = $conj ===
LIST_AND ?
' AND ' :
' OR ';
447 return join( $sqlConj, array_map(
function(
$s ) {
448 return '(' .
$s .
')';
452 $mockDb->expects( $this->once() )
453 ->method(
'makeWhereFrom2d' )
455 [ [
'SomeNotExisitingDbKey' => 1,
'OtherNotExisitingDbKey' => 1 ] ],
456 $this->isType(
'string' ),
457 $this->isType(
'string' )
459 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
462 '((wl_namespace = 0) AND (' .
463 "(((wl_title = 'SomeDbKey') AND (" .
464 "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
466 "(wl_title = 'OtherDbKey') AND (" .
467 "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
469 ') OR ((wl_namespace = 1) AND (' .
470 "(((wl_title = 'AnotherDbKey') AND (".
471 "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" .
474 '(makeWhereFrom2d return value)';
475 $mockDb->expects( $this->once() )
479 [
'wl_namespace',
'wl_title',
'watchers' =>
'COUNT(*)' ],
481 $this->isType(
'string' ),
483 'GROUP BY' => [
'wl_namespace',
'wl_title' ],
487 $this->returnValue( $dbResult )
491 $mockCache->expects( $this->never() )->method(
'get' );
492 $mockCache->expects( $this->never() )->method(
'set' );
493 $mockCache->expects( $this->never() )->method(
'delete' );
502 'SomeDbKey' => 100,
'OtherDbKey' => 300,
503 'SomeNotExisitingDbKey' => 100,
'OtherNotExisitingDbKey' => 200
505 1 => [
'AnotherDbKey' => 500 ],
509 $store->countVisitingWatchersMultiple( $titleValuesWithThresholds )
517 $titleValuesWithThresholds = [
520 [
new TitleValue( 1,
'AnotherDbKey' ),
'123' ],
524 $mockDb->expects( $this->any() )
525 ->method(
'makeList' )
526 ->will( $this->returnValue(
'makeList return value' ) );
527 $mockDb->expects( $this->once() )
531 [
'wl_namespace',
'wl_title',
'watchers' =>
'COUNT(*)' ],
532 'makeList return value',
533 $this->isType(
'string' ),
535 'GROUP BY' => [
'wl_namespace',
'wl_title' ],
536 'HAVING' =>
'COUNT(*) >= 50',
540 $this->returnValue( [] )
544 $mockCache->expects( $this->never() )->method(
'get' );
545 $mockCache->expects( $this->never() )->method(
'set' );
546 $mockCache->expects( $this->never() )->method(
'delete' );
554 0 => [
'SomeDbKey' => 0,
'OtherDbKey' => 0 ],
555 1 => [
'AnotherDbKey' => 0 ],
559 $store->countVisitingWatchersMultiple( $titleValuesWithThresholds, $minWatchers )
567 $mockDb->expects( $this->exactly( 1 ) )
568 ->method(
'selectRowCount' )
573 "wl_notificationtimestamp IS NOT NULL",
576 $this->isType(
'string' )
578 ->will( $this->returnValue( 9 ) );
581 $mockCache->expects( $this->never() )->method(
'set' );
582 $mockCache->expects( $this->never() )->method(
'get' );
583 $mockCache->expects( $this->never() )->method(
'delete' );
590 $this->assertEquals( 9, $store->countUnreadNotifications(
$user ) );
600 $mockDb->expects( $this->exactly( 1 ) )
601 ->method(
'selectRowCount' )
606 "wl_notificationtimestamp IS NOT NULL",
609 $this->isType(
'string' ),
612 ->will( $this->returnValue( 50 ) );
615 $mockCache->expects( $this->never() )->method(
'set' );
616 $mockCache->expects( $this->never() )->method(
'get' );
617 $mockCache->expects( $this->never() )->method(
'delete' );
637 $mockDb->expects( $this->exactly( 1 ) )
638 ->method(
'selectRowCount' )
643 "wl_notificationtimestamp IS NOT NULL",
646 $this->isType(
'string' ),
649 ->will( $this->returnValue( 9 ) );
652 $mockCache->expects( $this->never() )->method(
'set' );
653 $mockCache->expects( $this->never() )->method(
'get' );
654 $mockCache->expects( $this->never() )->method(
'delete' );
669 $mockDb->expects( $this->once() )
675 'wl_notificationtimestamp',
679 'wl_title' =>
'Old_Title',
681 'WatchedItemStore::duplicateEntry',
691 $store->duplicateEntry(
699 $this->
getFakeRow( [
'wl_user' => 1,
'wl_notificationtimestamp' =>
'20151212010101' ] ),
700 $this->
getFakeRow( [
'wl_user' => 2,
'wl_notificationtimestamp' => null ] ),
704 $mockDb->expects( $this->at( 0 ) )
710 'wl_notificationtimestamp',
714 'wl_title' =>
'Old_Title',
718 $mockDb->expects( $this->at( 1 ) )
719 ->method(
'replace' )
722 [ [
'wl_user',
'wl_namespace',
'wl_title' ] ],
727 'wl_title' =>
'New_Title',
728 'wl_notificationtimestamp' =>
'20151212010101',
733 'wl_title' =>
'New_Title',
734 'wl_notificationtimestamp' => null,
737 $this->isType(
'string' )
741 $mockCache->expects( $this->never() )->method(
'get' );
742 $mockCache->expects( $this->never() )->method(
'delete' );
749 $store->duplicateEntry(
757 $mockDb->expects( $this->at( 0 ) )
763 'wl_notificationtimestamp',
767 'wl_title' =>
'Old_Title',
771 $mockDb->expects( $this->at( 1 ) )
777 'wl_notificationtimestamp',
781 'wl_title' =>
'Old_Title',
787 $mockCache->expects( $this->never() )->method(
'get' );
788 $mockCache->expects( $this->never() )->method(
'delete' );
795 $store->duplicateAllAssociatedEntries(
816 $this->
getFakeRow( [
'wl_user' => 1,
'wl_notificationtimestamp' =>
'20151212010101' ] ),
820 $mockDb->expects( $this->at( 0 ) )
826 'wl_notificationtimestamp',
830 'wl_title' => $oldTarget->
getDBkey(),
834 $mockDb->expects( $this->at( 1 ) )
835 ->method(
'replace' )
838 [ [
'wl_user',
'wl_namespace',
'wl_title' ] ],
843 'wl_title' => $newTarget->
getDBkey(),
844 'wl_notificationtimestamp' =>
'20151212010101',
847 $this->isType(
'string' )
849 $mockDb->expects( $this->at( 2 ) )
855 'wl_notificationtimestamp',
859 'wl_title' => $oldTarget->
getDBkey(),
863 $mockDb->expects( $this->at( 3 ) )
864 ->method(
'replace' )
867 [ [
'wl_user',
'wl_namespace',
'wl_title' ] ],
872 'wl_title' => $newTarget->
getDBkey(),
873 'wl_notificationtimestamp' =>
'20151212010101',
876 $this->isType(
'string' )
880 $mockCache->expects( $this->never() )->method(
'get' );
881 $mockCache->expects( $this->never() )->method(
'delete' );
888 $store->duplicateAllAssociatedEntries(
896 $mockDb->expects( $this->once() )
904 'wl_title' =>
'Some_Page',
905 'wl_notificationtimestamp' => null,
911 $mockCache->expects( $this->once() )
913 ->with(
'0:Some_Page:1' );
928 $mockDb->expects( $this->never() )
929 ->method(
'insert' );
932 $mockCache->expects( $this->never() )
933 ->method(
'delete' );
953 $store->addWatchBatchForUser(
954 $this->getMockNonAnonUserWithId( 1 ),
962 $mockDb->expects( $this->once() )
970 'wl_title' =>
'Some_Page',
971 'wl_notificationtimestamp' => null,
976 'wl_title' =>
'Some_Page',
977 'wl_notificationtimestamp' => null,
983 $mockCache->expects( $this->exactly( 2 ) )
984 ->method(
'delete' );
985 $mockCache->expects( $this->at( 1 ) )
987 ->with(
'0:Some_Page:1' );
988 $mockCache->expects( $this->at( 3 ) )
990 ->with(
'1:Some_Page:1' );
1000 $store->addWatchBatchForUser(
1009 $mockDb->expects( $this->never() )
1010 ->method(
'insert' );
1013 $mockCache->expects( $this->never() )
1014 ->method(
'delete' );
1022 $store->addWatchBatchForUser(
1023 $this->getAnonUser(),
1032 $mockDb->expects( $this->never() )
1033 ->method(
'insert' );
1036 $mockCache->expects( $this->never() )
1037 ->method(
'delete' );
1045 $store->addWatchBatchForUser(
$user, [] )
1051 $mockDb->expects( $this->once() )
1052 ->method(
'selectRow' )
1055 'wl_notificationtimestamp',
1058 'wl_namespace' => 0,
1059 'wl_title' =>
'SomeDbKey',
1062 ->will( $this->returnValue(
1063 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'20151212010101' ] )
1067 $mockCache->expects( $this->once() )
1078 $watchedItem = $store->loadWatchedItem(
1082 $this->assertInstanceOf(
'WatchedItem', $watchedItem );
1083 $this->assertEquals( 1, $watchedItem->getUser()->getId() );
1084 $this->assertEquals(
'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
1085 $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
1090 $mockDb->expects( $this->once() )
1091 ->method(
'selectRow' )
1094 'wl_notificationtimestamp',
1097 'wl_namespace' => 0,
1098 'wl_title' =>
'SomeDbKey',
1101 ->will( $this->returnValue( [] ) );
1104 $mockCache->expects( $this->never() )->method(
'get' );
1105 $mockCache->expects( $this->never() )->method(
'delete' );
1113 $store->loadWatchedItem(
1114 $this->getMockNonAnonUserWithId( 1 ),
1122 $mockDb->expects( $this->never() )
1123 ->method(
'selectRow' );
1126 $mockCache->expects( $this->never() )->method(
'get' );
1127 $mockCache->expects( $this->never() )->method(
'delete' );
1135 $store->loadWatchedItem(
1136 $this->getAnonUser(),
1144 $mockDb->expects( $this->once() )
1145 ->method(
'delete' )
1150 'wl_namespace' => 0,
1151 'wl_title' =>
'SomeDbKey',
1154 $mockDb->expects( $this->once() )
1155 ->method(
'affectedRows' )
1156 ->will( $this->returnValue( 1 ) );
1159 $mockCache->expects( $this->never() )->method(
'get' );
1160 $mockCache->expects( $this->once() )
1161 ->method(
'delete' )
1162 ->with(
'0:SomeDbKey:1' );
1170 $store->removeWatch(
1171 $this->getMockNonAnonUserWithId( 1 ),
1179 $mockDb->expects( $this->once() )
1180 ->method(
'delete' )
1185 'wl_namespace' => 0,
1186 'wl_title' =>
'SomeDbKey',
1189 $mockDb->expects( $this->once() )
1190 ->method(
'affectedRows' )
1191 ->will( $this->returnValue( 0 ) );
1194 $mockCache->expects( $this->never() )->method(
'get' );
1195 $mockCache->expects( $this->once() )
1196 ->method(
'delete' )
1197 ->with(
'0:SomeDbKey:1' );
1205 $store->removeWatch(
1206 $this->getMockNonAnonUserWithId( 1 ),
1214 $mockDb->expects( $this->never() )
1215 ->method(
'delete' );
1218 $mockCache->expects( $this->never() )->method(
'get' );
1219 $mockCache->expects( $this->never() )
1220 ->method(
'delete' );
1228 $store->removeWatch(
1229 $this->getAnonUser(),
1237 $mockDb->expects( $this->once() )
1238 ->method(
'selectRow' )
1241 'wl_notificationtimestamp',
1244 'wl_namespace' => 0,
1245 'wl_title' =>
'SomeDbKey',
1248 ->will( $this->returnValue(
1249 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'20151212010101' ] )
1253 $mockCache->expects( $this->never() )->method(
'delete' );
1254 $mockCache->expects( $this->once() )
1259 ->will( $this->returnValue( null ) );
1260 $mockCache->expects( $this->once() )
1271 $watchedItem = $store->getWatchedItem(
1275 $this->assertInstanceOf(
'WatchedItem', $watchedItem );
1276 $this->assertEquals( 1, $watchedItem->getUser()->getId() );
1277 $this->assertEquals(
'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
1278 $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
1283 $mockDb->expects( $this->never() )
1284 ->method(
'selectRow' );
1287 $linkTarget =
new TitleValue( 0,
'SomeDbKey' );
1288 $cachedItem =
new WatchedItem( $mockUser, $linkTarget,
'20151212010101' );
1291 $mockCache->expects( $this->never() )->method(
'delete' );
1292 $mockCache->expects( $this->never() )->method(
'set' );
1293 $mockCache->expects( $this->once() )
1298 ->will( $this->returnValue( $cachedItem ) );
1305 $this->assertEquals(
1307 $store->getWatchedItem(
1316 $mockDb->expects( $this->once() )
1317 ->method(
'selectRow' )
1320 'wl_notificationtimestamp',
1323 'wl_namespace' => 0,
1324 'wl_title' =>
'SomeDbKey',
1327 ->will( $this->returnValue( [] ) );
1330 $mockCache->expects( $this->never() )->method(
'set' );
1331 $mockCache->expects( $this->never() )->method(
'delete' );
1332 $mockCache->expects( $this->once() )
1334 ->with(
'0:SomeDbKey:1' )
1335 ->will( $this->returnValue(
false ) );
1343 $store->getWatchedItem(
1344 $this->getMockNonAnonUserWithId( 1 ),
1352 $mockDb->expects( $this->never() )
1353 ->method(
'selectRow' );
1356 $mockCache->expects( $this->never() )->method(
'set' );
1357 $mockCache->expects( $this->never() )->method(
'get' );
1358 $mockCache->expects( $this->never() )->method(
'delete' );
1366 $store->getWatchedItem(
1367 $this->getAnonUser(),
1375 $mockDb->expects( $this->once() )
1376 ->method(
'select' )
1379 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
1382 ->will( $this->returnValue( [
1384 'wl_namespace' => 0,
1385 'wl_title' =>
'Foo1',
1386 'wl_notificationtimestamp' =>
'20151212010101',
1389 'wl_namespace' => 1,
1390 'wl_title' =>
'Foo2',
1391 'wl_notificationtimestamp' => null,
1396 $mockCache->expects( $this->never() )->method(
'delete' );
1397 $mockCache->expects( $this->never() )->method(
'get' );
1398 $mockCache->expects( $this->never() )->method(
'set' );
1406 $watchedItems = $store->getWatchedItemsForUser(
$user );
1408 $this->assertInternalType(
'array', $watchedItems );
1409 $this->assertCount( 2, $watchedItems );
1410 foreach ( $watchedItems
as $watchedItem ) {
1411 $this->assertInstanceOf(
'WatchedItem', $watchedItem );
1413 $this->assertEquals(
1417 $this->assertEquals(
1439 $mockDb->expects( $this->once() )
1440 ->method(
'select' )
1443 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
1445 $this->isType(
'string' ),
1446 [
'ORDER BY' => [
'wl_namespace ASC',
'wl_title ASC' ] ]
1448 ->will( $this->returnValue( [] ) );
1455 $watchedItems = $store->getWatchedItemsForUser(
1459 $this->assertEquals( [], $watchedItems );
1468 $this->setExpectedException(
'InvalidArgumentException' );
1469 $store->getWatchedItemsForUser(
1477 $mockDb->expects( $this->once() )
1478 ->method(
'selectRow' )
1481 'wl_notificationtimestamp',
1484 'wl_namespace' => 0,
1485 'wl_title' =>
'SomeDbKey',
1488 ->will( $this->returnValue(
1489 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'20151212010101' ] )
1493 $mockCache->expects( $this->never() )->method(
'delete' );
1494 $mockCache->expects( $this->once() )
1496 ->with(
'0:SomeDbKey:1' )
1497 ->will( $this->returnValue(
false ) );
1498 $mockCache->expects( $this->once() )
1511 $this->getMockNonAnonUserWithId( 1 ),
1519 $mockDb->expects( $this->once() )
1520 ->method(
'selectRow' )
1523 'wl_notificationtimestamp',
1526 'wl_namespace' => 0,
1527 'wl_title' =>
'SomeDbKey',
1530 ->will( $this->returnValue( [] ) );
1533 $mockCache->expects( $this->never() )->method(
'set' );
1534 $mockCache->expects( $this->never() )->method(
'delete' );
1535 $mockCache->expects( $this->once() )
1537 ->with(
'0:SomeDbKey:1' )
1538 ->will( $this->returnValue(
false ) );
1547 $this->getMockNonAnonUserWithId( 1 ),
1555 $mockDb->expects( $this->never() )
1556 ->method(
'selectRow' );
1559 $mockCache->expects( $this->never() )->method(
'set' );
1560 $mockCache->expects( $this->never() )->method(
'get' );
1561 $mockCache->expects( $this->never() )->method(
'delete' );
1570 $this->getAnonUser(),
1585 'wl_namespace' => 0,
1586 'wl_title' =>
'SomeDbKey',
1587 'wl_notificationtimestamp' =>
'20151212010101',
1591 'wl_namespace' => 1,
1592 'wl_title' =>
'AnotherDbKey',
1593 'wl_notificationtimestamp' => null,
1598 $mockDb->expects( $this->once() )
1599 ->method(
'makeWhereFrom2d' )
1601 [ [
'SomeDbKey' => 1 ], [
'AnotherDbKey' => 1 ] ],
1602 $this->isType(
'string' ),
1603 $this->isType(
'string' )
1605 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
1606 $mockDb->expects( $this->once() )
1607 ->method(
'select' )
1610 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
1612 'makeWhereFrom2d return value',
1615 $this->isType(
'string' )
1617 ->will( $this->returnValue( $dbResult ) );
1620 $mockCache->expects( $this->exactly( 2 ) )
1623 [
'0:SomeDbKey:1' ],
1624 [
'1:AnotherDbKey:1' ]
1626 ->will( $this->returnValue( null ) );
1627 $mockCache->expects( $this->never() )->method(
'set' );
1628 $mockCache->expects( $this->never() )->method(
'delete' );
1635 $this->assertEquals(
1637 0 => [
'SomeDbKey' =>
'20151212010101', ],
1638 1 => [
'AnotherDbKey' => null, ],
1640 $store->getNotificationTimestampsBatch( $this->getMockNonAnonUserWithId( 1 ), $targets )
1651 $mockDb->expects( $this->once() )
1652 ->method(
'makeWhereFrom2d' )
1654 [ [
'OtherDbKey' => 1 ] ],
1655 $this->isType(
'string' ),
1656 $this->isType(
'string' )
1658 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
1659 $mockDb->expects( $this->once() )
1660 ->method(
'select' )
1663 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
1665 'makeWhereFrom2d return value',
1668 $this->isType(
'string' )
1670 ->will( $this->returnValue( $this->
getFakeRow( [] ) ) );
1673 $mockCache->expects( $this->once() )
1675 ->with(
'0:OtherDbKey:1' )
1676 ->will( $this->returnValue( null ) );
1677 $mockCache->expects( $this->never() )->method(
'set' );
1678 $mockCache->expects( $this->never() )->method(
'delete' );
1685 $this->assertEquals(
1687 0 => [
'OtherDbKey' =>
false, ],
1689 $store->getNotificationTimestampsBatch( $this->getMockNonAnonUserWithId( 1 ), $targets )
1704 $mockDb->expects( $this->once() )
1705 ->method(
'makeWhereFrom2d' )
1707 [ 1 => [
'AnotherDbKey' => 1 ] ],
1708 $this->isType(
'string' ),
1709 $this->isType(
'string' )
1711 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
1712 $mockDb->expects( $this->once() )
1713 ->method(
'select' )
1716 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
1718 'makeWhereFrom2d return value',
1721 $this->isType(
'string' )
1723 ->will( $this->returnValue( [
1725 [
'wl_namespace' => 1,
'wl_title' =>
'AnotherDbKey',
'wl_notificationtimestamp' => null, ]
1730 $mockCache->expects( $this->at( 1 ) )
1732 ->with(
'0:SomeDbKey:1' )
1733 ->will( $this->returnValue( $cachedItem ) );
1734 $mockCache->expects( $this->at( 3 ) )
1736 ->with(
'1:AnotherDbKey:1' )
1737 ->will( $this->returnValue( null ) );
1738 $mockCache->expects( $this->never() )->method(
'set' );
1739 $mockCache->expects( $this->never() )->method(
'delete' );
1746 $this->assertEquals(
1748 0 => [
'SomeDbKey' =>
'20151212010101', ],
1749 1 => [
'AnotherDbKey' => null, ],
1751 $store->getNotificationTimestampsBatch(
$user, $targets )
1767 $mockDb->expects( $this->never() )->method( $this->
anything() );
1770 $mockCache->expects( $this->at( 1 ) )
1772 ->with(
'0:SomeDbKey:1' )
1773 ->will( $this->returnValue( $cachedItems[0] ) );
1774 $mockCache->expects( $this->at( 3 ) )
1776 ->with(
'1:AnotherDbKey:1' )
1777 ->will( $this->returnValue( $cachedItems[1] ) );
1778 $mockCache->expects( $this->never() )->method(
'set' );
1779 $mockCache->expects( $this->never() )->method(
'delete' );
1786 $this->assertEquals(
1788 0 => [
'SomeDbKey' =>
'20151212010101', ],
1789 1 => [
'AnotherDbKey' => null, ],
1791 $store->getNotificationTimestampsBatch(
$user, $targets )
1802 $mockDb->expects( $this->never() )->method( $this->
anything() );
1805 $mockCache->expects( $this->never() )->method( $this->
anything() );
1812 $this->assertEquals(
1814 0 => [
'SomeDbKey' =>
false, ],
1815 1 => [
'AnotherDbKey' =>
false, ],
1817 $store->getNotificationTimestampsBatch( $this->getAnonUser(), $targets )
1823 $mockDb->expects( $this->never() )
1824 ->method(
'selectRow' );
1827 $mockCache->expects( $this->never() )->method(
'get' );
1828 $mockCache->expects( $this->never() )->method(
'set' );
1829 $mockCache->expects( $this->never() )->method(
'delete' );
1837 $store->resetNotificationTimestamp(
1838 $this->getAnonUser(),
1846 $mockDb->expects( $this->once() )
1847 ->method(
'selectRow' )
1850 'wl_notificationtimestamp',
1853 'wl_namespace' => 0,
1854 'wl_title' =>
'SomeDbKey',
1857 ->will( $this->returnValue( [] ) );
1860 $mockCache->expects( $this->never() )->method(
'get' );
1861 $mockCache->expects( $this->never() )->method(
'set' );
1862 $mockCache->expects( $this->never() )->method(
'delete' );
1870 $store->resetNotificationTimestamp(
1871 $this->getMockNonAnonUserWithId( 1 ),
1882 $mockDb->expects( $this->once() )
1883 ->method(
'selectRow' )
1886 'wl_notificationtimestamp',
1889 'wl_namespace' => 0,
1890 'wl_title' =>
'SomeDbKey',
1893 ->will( $this->returnValue(
1894 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'20151212010101' ] )
1898 $mockCache->expects( $this->never() )->method(
'get' );
1899 $mockCache->expects( $this->once() )
1905 $mockCache->expects( $this->once() )
1906 ->method(
'delete' )
1907 ->with(
'0:SomeDbKey:1' );
1915 $callableCallCounter = 0;
1916 $mockCallback =
function( $callable )
use ( &$callableCallCounter ) {
1917 $callableCallCounter++;
1918 $this->assertInternalType(
'callable', $callable );
1920 $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( $mockCallback );
1923 $store->resetNotificationTimestamp(
1928 $this->assertEquals( 1, $callableCallCounter );
1930 ScopedCallback::consume( $scopedOverride );
1938 $mockDb->expects( $this->never() )
1939 ->method(
'selectRow' );
1942 $mockDb->expects( $this->never() )
1944 $mockDb->expects( $this->never() )
1946 $mockDb->expects( $this->never() )
1947 ->method(
'delete' );
1955 $callableCallCounter = 0;
1956 $mockCallback =
function( $callable )
use ( &$callableCallCounter ) {
1957 $callableCallCounter++;
1958 $this->assertInternalType(
'callable', $callable );
1960 $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( $mockCallback );
1963 $store->resetNotificationTimestamp(
1969 $this->assertEquals( 1, $callableCallCounter );
1971 ScopedCallback::consume( $scopedOverride );
1982 $title->expects( $this->any() )
1983 ->method(
'getText' )
1984 ->will( $this->returnValue( str_replace(
'_',
' ', $text ) ) );
1985 $title->expects( $this->any() )
1986 ->method(
'getDbKey' )
1987 ->will( $this->returnValue( str_replace(
'_',
' ', $text ) ) );
1988 $title->expects( $this->any() )
1989 ->method(
'getNamespace' )
1990 ->will( $this->returnValue( $ns ) );
1998 callable $notificationTimestampCondition
2000 $this->assertInternalType(
'callable', $callback );
2002 $callbackReflector =
new ReflectionFunction( $callback );
2003 $vars = $callbackReflector->getStaticVariables();
2004 $this->assertArrayHasKey(
'job',
$vars );
2009 $this->assertEquals( $expectedTitle->
getDBkey(),
$job->getTitle()->getDBkey() );
2010 $this->assertEquals( $expectedTitle->
getNamespace(),
$job->getTitle()->getNamespace() );
2012 $jobParams =
$job->getParams();
2013 $this->assertArrayHasKey(
'type', $jobParams );
2014 $this->assertEquals(
'updateWatchlistNotification', $jobParams[
'type'] );
2015 $this->assertArrayHasKey(
'userid', $jobParams );
2016 $this->assertEquals( $expectedUserId, $jobParams[
'userid'] );
2017 $this->assertArrayHasKey(
'notifTime', $jobParams );
2018 $this->assertTrue( $notificationTimestampCondition( $jobParams[
'notifTime'] ) );
2025 $title->expects( $this->once() )
2026 ->method(
'getNextRevisionID' )
2028 ->will( $this->returnValue(
false ) );
2031 $mockDb->expects( $this->never() )
2032 ->method(
'selectRow' );
2035 $mockDb->expects( $this->never() )
2037 $mockDb->expects( $this->never() )
2039 $mockDb->expects( $this->never() )
2040 ->method(
'delete' );
2047 $callableCallCounter = 0;
2048 $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
2049 function( $callable )
use ( &$callableCallCounter,
$title,
$user ) {
2050 $callableCallCounter++;
2056 return $time === null;
2063 $store->resetNotificationTimestamp(
2070 $this->assertEquals( 1, $callableCallCounter );
2072 ScopedCallback::consume( $scopedOverride );
2079 $title->expects( $this->once() )
2080 ->method(
'getNextRevisionID' )
2082 ->will( $this->returnValue( 33 ) );
2085 $mockDb->expects( $this->once() )
2086 ->method(
'selectRow' )
2089 'wl_notificationtimestamp',
2092 'wl_namespace' => 0,
2093 'wl_title' =>
'SomeDbKey',
2096 ->will( $this->returnValue(
2097 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'20151212010101' ] )
2101 $mockDb->expects( $this->never() )
2103 $mockDb->expects( $this->never() )
2105 $mockDb->expects( $this->never() )
2106 ->method(
'delete' );
2113 $addUpdateCallCounter = 0;
2114 $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
2115 function( $callable )
use ( &$addUpdateCallCounter,
$title,
$user ) {
2116 $addUpdateCallCounter++;
2122 return $time !== null &&
$time >
'20151212010101';
2128 $getTimestampCallCounter = 0;
2129 $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
2130 function( $titleParam, $oldidParam )
use ( &$getTimestampCallCounter,
$title, $oldid ) {
2131 $getTimestampCallCounter++;
2132 $this->assertEquals(
$title, $titleParam );
2133 $this->assertEquals( $oldid, $oldidParam );
2138 $store->resetNotificationTimestamp(
2145 $this->assertEquals( 1, $addUpdateCallCounter );
2146 $this->assertEquals( 1, $getTimestampCallCounter );
2148 ScopedCallback::consume( $scopedOverrideDeferred );
2149 ScopedCallback::consume( $scopedOverrideRevision );
2156 $title->expects( $this->once() )
2157 ->method(
'getNextRevisionID' )
2159 ->will( $this->returnValue( 33 ) );
2162 $mockDb->expects( $this->once() )
2163 ->method(
'selectRow' )
2166 'wl_notificationtimestamp',
2169 'wl_namespace' => 0,
2170 'wl_title' =>
'SomeDbKey',
2173 ->will( $this->returnValue(
false ) );
2176 $mockDb->expects( $this->never() )
2178 $mockDb->expects( $this->never() )
2180 $mockDb->expects( $this->never() )
2181 ->method(
'delete' );
2188 $callableCallCounter = 0;
2189 $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
2190 function( $callable )
use ( &$callableCallCounter,
$title,
$user ) {
2191 $callableCallCounter++;
2197 return $time === null;
2204 $store->resetNotificationTimestamp(
2211 $this->assertEquals( 1, $callableCallCounter );
2213 ScopedCallback::consume( $scopedOverride );
2220 $title->expects( $this->once() )
2221 ->method(
'getNextRevisionID' )
2223 ->will( $this->returnValue( 33 ) );
2226 $mockDb->expects( $this->once() )
2227 ->method(
'selectRow' )
2230 'wl_notificationtimestamp',
2233 'wl_namespace' => 0,
2234 'wl_title' =>
'SomeDbKey',
2237 ->will( $this->returnValue(
2238 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'30151212010101' ] )
2242 $mockDb->expects( $this->never() )
2244 $mockDb->expects( $this->never() )
2246 $mockDb->expects( $this->never() )
2247 ->method(
'delete' );
2254 $addUpdateCallCounter = 0;
2255 $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
2256 function( $callable )
use ( &$addUpdateCallCounter,
$title,
$user ) {
2257 $addUpdateCallCounter++;
2263 return $time ===
'30151212010101';
2269 $getTimestampCallCounter = 0;
2270 $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
2271 function( $titleParam, $oldidParam )
use ( &$getTimestampCallCounter,
$title, $oldid ) {
2272 $getTimestampCallCounter++;
2273 $this->assertEquals(
$title, $titleParam );
2274 $this->assertEquals( $oldid, $oldidParam );
2279 $store->resetNotificationTimestamp(
2286 $this->assertEquals( 1, $addUpdateCallCounter );
2287 $this->assertEquals( 1, $getTimestampCallCounter );
2289 ScopedCallback::consume( $scopedOverrideDeferred );
2290 ScopedCallback::consume( $scopedOverrideRevision );
2297 $title->expects( $this->once() )
2298 ->method(
'getNextRevisionID' )
2300 ->will( $this->returnValue( 33 ) );
2303 $mockDb->expects( $this->once() )
2304 ->method(
'selectRow' )
2307 'wl_notificationtimestamp',
2310 'wl_namespace' => 0,
2311 'wl_title' =>
'SomeDbKey',
2314 ->will( $this->returnValue(
2315 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'30151212010101' ] )
2319 $mockDb->expects( $this->never() )
2321 $mockDb->expects( $this->never() )
2323 $mockDb->expects( $this->never() )
2324 ->method(
'delete' );
2331 $addUpdateCallCounter = 0;
2332 $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
2333 function( $callable )
use ( &$addUpdateCallCounter,
$title,
$user ) {
2334 $addUpdateCallCounter++;
2340 return $time ===
false;
2346 $getTimestampCallCounter = 0;
2347 $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
2348 function( $titleParam, $oldidParam )
use ( &$getTimestampCallCounter,
$title, $oldid ) {
2349 $getTimestampCallCounter++;
2350 $this->assertEquals(
$title, $titleParam );
2351 $this->assertEquals( $oldid, $oldidParam );
2356 $store->resetNotificationTimestamp(
2363 $this->assertEquals( 1, $addUpdateCallCounter );
2364 $this->assertEquals( 1, $getTimestampCallCounter );
2366 ScopedCallback::consume( $scopedOverrideDeferred );
2367 ScopedCallback::consume( $scopedOverrideRevision );
2375 $this->assertFalse( $store->setNotificationTimestampsForUser( $this->getAnonUser(),
'' ) );
2383 $mockDb->expects( $this->once() )
2384 ->method(
'update' )
2387 [
'wl_notificationtimestamp' =>
'TS' .
$timestamp .
'TS' ],
2390 ->will( $this->returnValue(
true ) );
2391 $mockDb->expects( $this->exactly( 1 ) )
2392 ->method(
'timestamp' )
2393 ->will( $this->returnCallback(
function(
$value ) {
2394 return 'TS' .
$value .
'TS';
2413 $mockDb->expects( $this->once() )
2414 ->method(
'update' )
2417 [
'wl_notificationtimestamp' =>
'TS' .
$timestamp .
'TS' ],
2418 [
'wl_user' => 1, 0 =>
'makeWhereFrom2d return value' ]
2420 ->will( $this->returnValue(
true ) );
2421 $mockDb->expects( $this->exactly( 1 ) )
2422 ->method(
'timestamp' )
2423 ->will( $this->returnCallback(
function(
$value ) {
2424 return 'TS' .
$value .
'TS';
2426 $mockDb->expects( $this->once() )
2427 ->method(
'makeWhereFrom2d' )
2429 [ [
'Foo' => 1,
'Bar' => 1 ] ],
2430 $this->isType(
'string' ),
2431 $this->isType(
'string' )
2433 ->will( $this->returnValue(
'makeWhereFrom2d return value' ) );
2441 $store->setNotificationTimestampsForUser(
$user,
$timestamp, $targets )
2447 $mockDb->expects( $this->once() )
2448 ->method(
'selectFieldValues' )
2454 'wl_namespace' => 0,
2455 'wl_title' =>
'SomeDbKey',
2456 'wl_notificationtimestamp IS NULL'
2459 ->will( $this->returnValue( [
'2',
'3' ] ) );
2460 $mockDb->expects( $this->once() )
2461 ->method(
'update' )
2464 [
'wl_notificationtimestamp' => null ],
2466 'wl_user' => [ 2, 3 ],
2467 'wl_namespace' => 0,
2468 'wl_title' =>
'SomeDbKey',
2473 $mockCache->expects( $this->never() )->method(
'set' );
2474 $mockCache->expects( $this->never() )->method(
'get' );
2475 $mockCache->expects( $this->never() )->method(
'delete' );
2482 $this->assertEquals(
2484 $store->updateNotificationTimestamp(
2485 $this->getMockNonAnonUserWithId( 1 ),
2494 $mockDb->expects( $this->once() )
2495 ->method(
'selectFieldValues' )
2501 'wl_namespace' => 0,
2502 'wl_title' =>
'SomeDbKey',
2503 'wl_notificationtimestamp IS NULL'
2507 $this->returnValue( [] )
2509 $mockDb->expects( $this->never() )
2510 ->method(
'update' );
2513 $mockCache->expects( $this->never() )->method(
'set' );
2514 $mockCache->expects( $this->never() )->method(
'get' );
2515 $mockCache->expects( $this->never() )->method(
'delete' );
2522 $watchers = $store->updateNotificationTimestamp(
2527 $this->assertInternalType(
'array', $watchers );
2528 $this->assertEmpty( $watchers );
2533 $titleValue =
new TitleValue( 0,
'SomeDbKey' );
2536 $mockDb->expects( $this->once() )
2537 ->method(
'selectRow' )
2538 ->will( $this->returnValue(
2539 $this->
getFakeRow( [
'wl_notificationtimestamp' =>
'20151212010101' ] )
2541 $mockDb->expects( $this->once() )
2542 ->method(
'selectFieldValues' )
2544 $this->returnValue( [
'2',
'3' ] )
2546 $mockDb->expects( $this->once() )
2547 ->method(
'update' );
2550 $mockCache->expects( $this->once() )
2552 ->with(
'0:SomeDbKey:1', $this->isType(
'object' ) );
2553 $mockCache->expects( $this->once() )
2555 ->with(
'0:SomeDbKey:1' );
2556 $mockCache->expects( $this->once() )
2557 ->method(
'delete' )
2558 ->with(
'0:SomeDbKey:1' );
2566 $store->getWatchedItem(
$user, $titleValue );
2568 $store->updateNotificationTimestamp(
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
testIsWatchedItem_anonymousUser()
testSetNotificationTimestampsForUser_anonUser()
testResetNotificationTimestamp_futureNotificationTimestampForced()
testRemoveWatch_existingItem()
testCountUnreadNotifications_withUnreadLimit_underLimit($limit)
provideIntWithDbUnsafeVersion
testGetWatchedItem_cachedItem()
the array() calling protocol came about after MediaWiki 1.4rc1.
getMockLoadBalancer($mockDb, $expectedConnectionType=null, $readOnlyReason=false)
testAddWatch_nonAnonymousUser()
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
testGetNotificationTimestampsBatch_notWatchedTarget()
testDuplicateEntry_somethingToDuplicate()
testIsWatchedItem_noItem()
Represents a page (or page fragment) title within MediaWiki.
testResetNotificationTimestamp_oldidSpecifiedLatestRevisionForced()
testResetNotificationTimestamp_noItemForced()
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testAddWatchBatchForUser_anonymousUsersAreSkipped()
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same so they can t rely on Unix and must forbid reads to even standard directories like tmp lest users read each others files We cannot assume that the user has the ability to install or run any programs not written as web accessible PHP scripts Since anything that works on cheap shared hosting will work if you have shell or root access MediaWiki s design is based around catering to the lowest common denominator Although we support higher end setups as the way many things work by default is tailored toward shared hosting These defaults are unconventional from the point of view of and they certainly aren t ideal for someone who s installing MediaWiki as MediaWiki does not conform to normal Unix filesystem layout Hopefully we ll offer direct support for standard layouts in the but for now *any change to the location of files is unsupported *Moving things and leaving symlinks will *probably *not break anything
testLoadWatchedItem_anonymousUser()
testDuplicateAllAssociatedEntries_nothingToDuplicate()
testAddWatchBatchReturnsTrue_whenGivenEmptyList()
testGetNotificationTimestampsBatch_anonymousUser()
getMockTitle($text, $ns=0)
testDuplicateAllAssociatedEntries_somethingToDuplicate(LinkTarget $oldTarget, LinkTarget $newTarget)
provideLinkTargetPairs
testGetNotificationTimestampsBatch()
testSetNotificationTimestampsForUser_allRows()
verifyCallbackJob($callback, LinkTarget $expectedTitle, $expectedUserId, callable $notificationTimestampCondition)
testCountVisitingWatchers()
testRemoveWatch_anonymousUser()
testResetNotificationTimestamp_oldidSpecifiedNotLatestRevisionForced()
testGetWatchedItem_existingItem()
testGetWatchedItemsForUser_badSortOptionThrowsException()
testIsWatchedItem_existingItem()
testResetNotificationTimestamp_noItem()
getMockNonAnonUserWithId($id)
Representation of a pair of user and title for watchlist entries.
namespace and then decline to actually register it file or subcat img or subcat $title
testAddWatch_anonymousUser()
testCountWatchersMultiple()
testCountVisitingWatchersMultiple_withMinimumWatchers($minWatchers)
provideIntWithDbUnsafeVersion
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
testLoadWatchedItem_existingItem()
testCountUnreadNotifications_withUnreadLimit_overLimit($limit)
provideIntWithDbUnsafeVersion
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
getFakeRow(array $rowValues)
testUpdateNotificationTimestamp_noWatchers()
testGetWatchedItem_noItem()
testCountUnreadNotifications()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
testGetWatchedItemsForUser_optionsAndEmptyResult($forWrite, $dbType)
provideDbTypes
testAddWatchBatchForUser_readOnlyDBReturnsFalse()
testDuplicateEntry_nothingToDuplicate()
testCountVisitingWatchersMultiple()
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
testResetNotificationTimestamp_futureNotificationTimestampNotForced()
testUpdateNotificationTimestamp_watchersExist()
testResetNotificationTimestamp_notWatchedPageForced()
testGetWatchedItem_anonymousUser()
provideIntWithDbUnsafeVersion()
testGetNotificationTimestampsBatch_cachedItem()
newWatchedItemStore(LoadBalancer $loadBalancer, HashBagOStuff $cache)
</td >< td > &</td >< td > t want your writing to be edited mercilessly and redistributed at will
testAddWatchBatchForUser_nonAnonymousUser()
testCountVisitingWatchersMultiple_withMissingTargets()
testCountWatchersMultiple_withMinimumWatchers($minWatchers)
provideIntWithDbUnsafeVersion
testLoadWatchedItem_noItem()
testGetWatchedItemsForUser()
testUpdateNotificationTimestamp_clearsCachedItems()
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
testSetNotificationTimestampsForUser_specificTargets()
see documentation in includes Linker php for Linker::makeImageLink & $time
testResetNotificationTimestamp_anonymousUser()
testGetNotificationTimestampsBatch_allItemsCached()
testResetNotificationTimestamp_item()