16 self::$users[
'WatchedItemStoreIntegrationTestUser']
17 =
new TestUser(
'WatchedItemStoreIntegrationTestUser' );
21 return self::$users[
'WatchedItemStoreIntegrationTestUser']->getUser();
27 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
30 $initialWatchers = $store->countWatchers(
$title );
31 $initialUserWatchedItems = $store->countWatchedItems(
$user );
35 'Page should not initially be watched'
41 'Page should be watched'
43 $this->assertEquals( $initialUserWatchedItems + 1, $store->countWatchedItems(
$user ) );
44 $watchedItemsForUser = $store->getWatchedItemsForUser(
$user );
45 $this->assertCount( $initialUserWatchedItems + 1, $watchedItemsForUser );
46 $watchedItemsForUserHasExpectedItem =
false;
47 foreach ( $watchedItemsForUser
as $watchedItem ) {
49 $watchedItem->getUser()->equals(
$user ) &&
50 $watchedItem->getLinkTarget() ==
$title->getTitleValue()
52 $watchedItemsForUserHasExpectedItem =
true;
56 $watchedItemsForUserHasExpectedItem,
57 'getWatchedItemsForUser should contain the page'
59 $this->assertEquals( $initialWatchers + 1, $store->countWatchers(
$title ) );
62 $store->countWatchersMultiple( [
$title ] )[
$title->getNamespace()][
$title->getDBkey()]
65 [ 0 => [
'WatchedItemStoreIntegrationTestPage' => $initialWatchers + 1 ] ],
66 $store->countWatchersMultiple( [
$title ], [
'minimumWatchers' => $initialWatchers + 1 ] )
69 [ 0 => [
'WatchedItemStoreIntegrationTestPage' => 0 ] ],
70 $store->countWatchersMultiple( [
$title ], [
'minimumWatchers' => $initialWatchers + 2 ] )
73 [
$title->getNamespace() => [
$title->getDBkey() => null ] ],
74 $store->getNotificationTimestampsBatch(
$user, [
$title ] )
80 'Page should be unwatched'
82 $this->assertEquals( $initialUserWatchedItems, $store->countWatchedItems(
$user ) );
83 $watchedItemsForUser = $store->getWatchedItemsForUser(
$user );
84 $this->assertCount( $initialUserWatchedItems, $watchedItemsForUser );
85 $watchedItemsForUserHasExpectedItem =
false;
86 foreach ( $watchedItemsForUser
as $watchedItem ) {
88 $watchedItem->getUser()->equals(
$user ) &&
89 $watchedItem->getLinkTarget() ==
$title->getTitleValue()
91 $watchedItemsForUserHasExpectedItem =
true;
95 $watchedItemsForUserHasExpectedItem,
96 'getWatchedItemsForUser should not contain the page'
98 $this->assertEquals( $initialWatchers, $store->countWatchers(
$title ) );
101 $store->countWatchersMultiple( [
$title ] )[
$title->getNamespace()][
$title->getDBkey()]
105 $store->getNotificationTimestampsBatch(
$user, [
$title ] )
111 $otherUser = (
new TestUser(
'WatchedItemStoreIntegrationTestUser_otherUser' ) )->
getUser();
113 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
115 $this->assertNull( $store->loadWatchedItem(
$user,
$title )->getNotificationTimestamp() );
116 $initialVisitingWatchers = $store->countVisitingWatchers(
$title,
'20150202020202' );
117 $initialUnreadNotifications = $store->countUnreadNotifications(
$user );
119 $store->updateNotificationTimestamp( $otherUser,
$title,
'20150202010101' );
122 $store->loadWatchedItem(
$user,
$title )->getNotificationTimestamp()
125 [
$title->getNamespace() => [
$title->getDBkey() =>
'20150202010101' ] ],
126 $store->getNotificationTimestampsBatch(
$user, [
$title ] )
129 $initialVisitingWatchers - 1,
130 $store->countVisitingWatchers(
$title,
'20150202020202' )
133 $initialVisitingWatchers - 1,
134 $store->countVisitingWatchersMultiple(
135 [ [
$title,
'20150202020202' ] ]
139 $initialUnreadNotifications + 1,
140 $store->countUnreadNotifications(
$user )
144 $store->countUnreadNotifications(
$user, $initialUnreadNotifications + 1 )
147 $this->assertTrue( $store->resetNotificationTimestamp(
$user,
$title ) );
148 $this->assertNull( $store->getWatchedItem(
$user,
$title )->getNotificationTimestamp() );
150 [
$title->getNamespace() => [
$title->getDBkey() => null ] ],
151 $store->getNotificationTimestampsBatch(
$user, [
$title ] )
154 $initialVisitingWatchers,
155 $store->countVisitingWatchers(
$title,
'20150202020202' )
158 $initialVisitingWatchers,
159 $store->countVisitingWatchersMultiple(
160 [ [
$title,
'20150202020202' ] ]
164 [ 0 => [
'WatchedItemStoreIntegrationTestPage' => $initialVisitingWatchers ] ],
165 $store->countVisitingWatchersMultiple(
166 [ [
$title,
'20150202020202' ] ], $initialVisitingWatchers
170 [ 0 => [
'WatchedItemStoreIntegrationTestPage' => 0 ] ],
171 $store->countVisitingWatchersMultiple(
172 [ [
$title,
'20150202020202' ] ], $initialVisitingWatchers + 1
178 $store->setNotificationTimestampsForUser(
$user,
'20200202020202', [
$title ] )
182 $store->getWatchedItem(
$user,
$title )->getNotificationTimestamp()
187 $store->setNotificationTimestampsForUser(
$user,
'20210202020202' )
191 $store->getWatchedItem(
$user,
$title )->getNotificationTimestamp()
199 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
200 $store->addWatch(
$user, $titleOld->getSubjectPage() );
201 $store->addWatch(
$user, $titleOld->getTalkPage() );
203 $store->removeWatch(
$user, $titleNew->getSubjectPage() );
204 $store->removeWatch(
$user, $titleNew->getTalkPage() );
206 $store->duplicateAllAssociatedEntries( $titleOld, $titleNew );
208 $this->assertTrue( $store->isWatched(
$user, $titleOld->getSubjectPage() ) );
209 $this->assertTrue( $store->isWatched(
$user, $titleOld->getTalkPage() ) );
210 $this->assertTrue( $store->isWatched(
$user, $titleNew->getSubjectPage() ) );
211 $this->assertTrue( $store->isWatched(
$user, $titleNew->getTalkPage() ) );
processing should stop and the error should be shown to the user * false
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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 MediaWikiServices
testUpdateResetAndSetNotificationTimestamp()
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testWatchAndUnWatchItem()
namespace and then decline to actually register it file or subcat img or subcat $title
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
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
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
Wraps the user object, so we can also retain full access to properties like password if we log in via...
testDuplicateAllAssociatedEntries()