Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiSetNotificationTimestampIntegrationTest.php
1 <?php
2
3 use MediaWiki\MediaWikiServices;
4
5 /**
6 * @author Addshore
7 * @covers ApiSetNotificationTimestamp
8 * @group API
9 * @group medium
10 * @group Database
11 */
12 class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase {
13
14 protected function setUp() {
15 parent::setUp();
16 self::$users[__CLASS__] = new TestUser( __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 }