]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.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                 $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 }