8 * @covers WatchedItemStore
10 class WatchedItemStoreIntegrationTest
extends MediaWikiTestCase
{
12 public function setUp() {
14 self
::$users['WatchedItemStoreIntegrationTestUser']
15 = new TestUser( 'WatchedItemStoreIntegrationTestUser' );
18 private function getUser() {
19 return self
::$users['WatchedItemStoreIntegrationTestUser']->getUser();
22 public function testWatchAndUnWatchItem() {
23 $user = $this->getUser();
24 $title = Title
::newFromText( 'WatchedItemStoreIntegrationTestPage' );
25 $store = WatchedItemStore
::getDefaultInstance();
26 // Cleanup after previous tests
27 $store->removeWatch( $user, $title );
30 $store->isWatched( $user, $title ),
31 'Page should not initially be watched'
33 $store->addWatch( $user, $title );
35 $store->isWatched( $user, $title ),
36 'Page should be watched'
38 $store->removeWatch( $user, $title );
40 $store->isWatched( $user, $title ),
41 'Page should be unwatched'
45 public function testUpdateAndResetNotificationTimestamp() {
46 $user = $this->getUser();
47 $otherUser = ( new TestUser( 'WatchedItemStoreIntegrationTestUser_otherUser' ) )->getUser();
48 $title = Title
::newFromText( 'WatchedItemStoreIntegrationTestPage' );
49 $store = WatchedItemStore
::getDefaultInstance();
50 $store->addWatch( $user, $title );
51 $this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
53 $store->updateNotificationTimestamp( $otherUser, $title, '20150202010101' );
56 $store->loadWatchedItem( $user, $title )->getNotificationTimestamp()
59 $this->assertTrue( $store->resetNotificationTimestamp( $user, $title ) );
60 $this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
63 public function testDuplicateAllAssociatedEntries() {
64 $user = $this->getUser();
65 $titleOld = Title
::newFromText( 'WatchedItemStoreIntegrationTestPageOld' );
66 $titleNew = Title
::newFromText( 'WatchedItemStoreIntegrationTestPageNew' );
67 $store = WatchedItemStore
::getDefaultInstance();
68 $store->addWatch( $user, $titleOld->getSubjectPage() );
69 $store->addWatch( $user, $titleOld->getTalkPage() );
70 // Cleanup after previous tests
71 $store->removeWatch( $user, $titleNew->getSubjectPage() );
72 $store->removeWatch( $user, $titleNew->getTalkPage() );
74 $store->duplicateAllAssociatedEntries( $titleOld, $titleNew );
76 $this->assertTrue( $store->isWatched( $user, $titleOld->getSubjectPage() ) );
77 $this->assertTrue( $store->isWatched( $user, $titleOld->getTalkPage() ) );
78 $this->assertTrue( $store->isWatched( $user, $titleNew->getSubjectPage() ) );
79 $this->assertTrue( $store->isWatched( $user, $titleNew->getTalkPage() ) );