MediaWiki REL1_31
ApiSetNotificationTimestampIntegrationTest.php
Go to the documentation of this file.
1<?php
3
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}
doApiRequestWithToken(array $params, array $session=null, User $user=null, $tokenType='auto')
Convenience function to access the token parameter of doApiRequest() more succinctly.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Wraps the user object, so we can also retain full access to properties like password if we log in via...
Definition TestUser.php:7