3 namespace MediaWiki\Tests\Api
;
7 * @covers \MediaWiki\Api\ApiSetNotificationTimestamp
12 class ApiSetNotificationTimestampIntegrationTest
extends ApiTestCase
{
14 public function testStuff() {
15 $user = $this->getTestUser()->getUser();
16 $watchedPageTitle = 'PageWatched';
17 $pageWatched = $this->getExistingTestPage( $watchedPageTitle );
18 $notWatchedPageTitle = 'PageNotWatched';
19 $pageNotWatched = $this->getExistingTestPage( $notWatchedPageTitle );
21 $watchlistManager = $this->getServiceContainer()->getWatchlistManager();
22 $watchlistManager->addWatch( $user, $pageWatched );
24 $result = $this->doApiRequestWithToken(
26 'action' => 'setnotificationtimestamp',
27 'timestamp' => '20160101020202',
28 'titles' => "$watchedPageTitle|$notWatchedPageTitle",
34 $this->assertTrue( $result[0]['batchcomplete'] );
35 $this->assertArrayEquals(
39 'title' => $watchedPageTitle,
40 'notificationtimestamp' => '2016-01-01T02:02:02Z'
44 'title' => $notWatchedPageTitle,
48 $result[0]['setnotificationtimestamp']
51 $watchedItemStore = $this->getServiceContainer()->getWatchedItemStore();
53 [ [ $watchedPageTitle => '20160101020202', $notWatchedPageTitle => false, ] ],
54 $watchedItemStore->getNotificationTimestampsBatch(
55 $user, [ $pageWatched->getTitle(), $pageNotWatched->getTitle() ] )