Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / api / ApiSetNotificationTimestampIntegrationTest.php
blobb7f2ebbe2dff211dd242898461bcd783ed2bc00a
1 <?php
3 namespace MediaWiki\Tests\Api;
5 /**
6 * @author Addshore
7 * @covers \MediaWiki\Api\ApiSetNotificationTimestamp
8 * @group API
9 * @group medium
10 * @group Database
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",
30 null,
31 $user
34 $this->assertTrue( $result[0]['batchcomplete'] );
35 $this->assertArrayEquals(
38 'ns' => NS_MAIN,
39 'title' => $watchedPageTitle,
40 'notificationtimestamp' => '2016-01-01T02:02:02Z'
43 'ns' => NS_MAIN,
44 'title' => $notWatchedPageTitle,
45 'notwatched' => true
48 $result[0]['setnotificationtimestamp']
51 $watchedItemStore = $this->getServiceContainer()->getWatchedItemStore();
52 $this->assertEquals(
53 [ [ $watchedPageTitle => '20160101020202', $notWatchedPageTitle => false, ] ],
54 $watchedItemStore->getNotificationTimestampsBatch(
55 $user, [ $pageWatched->getTitle(), $pageNotWatched->getTitle() ] )