X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FWatchedItemStoreIntegrationTest.php;h=61b62aa66bb0df516947986fcb12b5adfd2a2bb6;hb=3cb14f56bdf3271769a5866f9dcaad56bf873aea;hp=5b2873a4fcfc3317a8b86b47898e9b4dda30b091;hpb=a5b975edd132e52ee8ce1c725d8195da941c8b7b;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/WatchedItemStoreIntegrationTest.php b/tests/phpunit/includes/WatchedItemStoreIntegrationTest.php index 5b2873a4fc..61b62aa66b 100644 --- a/tests/phpunit/includes/WatchedItemStoreIntegrationTest.php +++ b/tests/phpunit/includes/WatchedItemStoreIntegrationTest.php @@ -1,5 +1,7 @@ getUser(); $title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' ); - $store = WatchedItemStore::getDefaultInstance(); + $store = MediaWikiServices::getInstance()->getWatchedItemStore(); // Cleanup after previous tests $store->removeWatch( $user, $title ); $initialWatchers = $store->countWatchers( $title ); @@ -104,11 +106,11 @@ class WatchedItemStoreIntegrationTest extends MediaWikiTestCase { ); } - public function testUpdateAndResetNotificationTimestamp() { + public function testUpdateResetAndSetNotificationTimestamp() { $user = $this->getUser(); $otherUser = ( new TestUser( 'WatchedItemStoreIntegrationTestUser_otherUser' ) )->getUser(); $title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' ); - $store = WatchedItemStore::getDefaultInstance(); + $store = MediaWikiServices::getInstance()->getWatchedItemStore(); $store->addWatch( $user, $title ); $this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() ); $initialVisitingWatchers = $store->countVisitingWatchers( $title, '20150202020202' ); @@ -170,13 +172,31 @@ class WatchedItemStoreIntegrationTest extends MediaWikiTestCase { [ [ $title, '20150202020202' ] ], $initialVisitingWatchers + 1 ) ); + + // setNotificationTimestampsForUser specifying a title + $this->assertTrue( + $store->setNotificationTimestampsForUser( $user, '20200202020202', [ $title ] ) + ); + $this->assertEquals( + '20200202020202', + $store->getWatchedItem( $user, $title )->getNotificationTimestamp() + ); + + // setNotificationTimestampsForUser not specifying a title + $this->assertTrue( + $store->setNotificationTimestampsForUser( $user, '20210202020202' ) + ); + $this->assertEquals( + '20210202020202', + $store->getWatchedItem( $user, $title )->getNotificationTimestamp() + ); } public function testDuplicateAllAssociatedEntries() { $user = $this->getUser(); $titleOld = Title::newFromText( 'WatchedItemStoreIntegrationTestPageOld' ); $titleNew = Title::newFromText( 'WatchedItemStoreIntegrationTestPageNew' ); - $store = WatchedItemStore::getDefaultInstance(); + $store = MediaWikiServices::getInstance()->getWatchedItemStore(); $store->addWatch( $user, $titleOld->getSubjectPage() ); $store->addWatch( $user, $titleOld->getTalkPage() ); // Cleanup after previous tests