MediaWiki REL1_30
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 $this->doLogin( __CLASS__ );
17 }
18
19 public function testStuff() {
20 $user = self::$users[__CLASS__]->getUser();
21 $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
22
23 $user->addWatch( $page->getTitle() );
24
25 $result = $this->doApiRequestWithToken(
26 [
27 'action' => 'setnotificationtimestamp',
28 'timestamp' => '20160101020202',
29 'pageids' => $page->getId(),
30 ],
31 null,
32 $user
33 );
34
35 $this->assertEquals(
36 [
37 'batchcomplete' => true,
38 'setnotificationtimestamp' => [
39 [ 'ns' => 0, 'title' => 'UTPage', 'notificationtimestamp' => '2016-01-01T02:02:02Z' ]
40 ],
41 ],
42 $result[0]
43 );
44
45 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
46 $this->assertEquals(
47 $watchedItemStore->getNotificationTimestampsBatch( $user, [ $page->getTitle() ] ),
48 [ [ 'UTPage' => '20160101020202' ] ]
49 );
50 }
51
52}
doApiRequestWithToken(array $params, array $session=null, User $user=null)
Add an edit token to the API request This is cheating a bit – we grab a token in the correct format a...
doLogin( $testUser='sysop')
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
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:121