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 testResetNotificationTimestamp() {
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 EmailNotification
::updateWatchlistTimestamp( $otherUser, $title, '20150202010101' );
53 $this->assertNotNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
54 $this->assertTrue( $store->resetNotificationTimestamp( $user, $title ) );
55 $this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
58 public function testDuplicateAllAssociatedEntries() {
59 $user = $this->getUser();
60 $titleOld = Title
::newFromText( 'WatchedItemStoreIntegrationTestPageOld' );
61 $titleNew = Title
::newFromText( 'WatchedItemStoreIntegrationTestPageNew' );
62 $store = WatchedItemStore
::getDefaultInstance();
63 $store->addWatch( $user, $titleOld->getSubjectPage() );
64 $store->addWatch( $user, $titleOld->getTalkPage() );
65 // Cleanup after previous tests
66 $store->removeWatch( $user, $titleNew->getSubjectPage() );
67 $store->removeWatch( $user, $titleNew->getTalkPage() );
69 $store->duplicateAllAssociatedEntries( $titleOld, $titleNew );
71 $this->assertTrue( $store->isWatched( $user, $titleOld->getSubjectPage() ) );
72 $this->assertTrue( $store->isWatched( $user, $titleOld->getTalkPage() ) );
73 $this->assertTrue( $store->isWatched( $user, $titleNew->getSubjectPage() ) );
74 $this->assertTrue( $store->isWatched( $user, $titleNew->getTalkPage() ) );