Merge "maintenance: Document secondary purpose of --server"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiSetNotificationTimestampIntegrationTest.php
1 <?php
2 use MediaWiki\MediaWikiServices;
3
4 /**
5 * @author Addshore
6 * @covers ApiSetNotificationTimestamp
7 * @group API
8 * @group medium
9 * @group Database
10 */
11 class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase {
12
13 protected function setUp() {
14 parent::setUp();
15 self::$users[__CLASS__] = new TestUser( __CLASS__ );
16 }
17
18 public function testStuff() {
19 $user = self::$users[__CLASS__]->getUser();
20 $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
21
22 $user->addWatch( $page->getTitle() );
23
24 $result = $this->doApiRequestWithToken(
25 [
26 'action' => 'setnotificationtimestamp',
27 'timestamp' => '20160101020202',
28 'pageids' => $page->getId(),
29 ],
30 null,
31 $user
32 );
33
34 $this->assertEquals(
35 [
36 'batchcomplete' => true,
37 'setnotificationtimestamp' => [
38 [ 'ns' => 0, 'title' => 'UTPage', 'notificationtimestamp' => '2016-01-01T02:02:02Z' ]
39 ],
40 ],
41 $result[0]
42 );
43
44 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
45 $this->assertEquals(
46 $watchedItemStore->getNotificationTimestampsBatch( $user, [ $page->getTitle() ] ),
47 [ [ 'UTPage' => '20160101020202' ] ]
48 );
49 }
50
51 }