X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FWatchedItemStoreIntegrationTest.php;h=61b62aa66bb0df516947986fcb12b5adfd2a2bb6;hb=b86ef89dd17f51841a220e8ef9b3b8b2402e2547;hp=5b2873a4fcfc3317a8b86b47898e9b4dda30b091;hpb=54277fb7d5609c26b83d4fc7543b2c826fcae0bf;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