Add ApiSetNotificationTimestampIntegrationTest
authoraddshore <addshorewiki@gmail.com>
Wed, 18 May 2016 11:08:47 +0000 (12:08 +0100)
committeraddshore <addshorewiki@gmail.com>
Wed, 18 May 2016 11:08:47 +0000 (12:08 +0100)
Change-Id: If0bc1f56533102f54c0031eea548c20d8abe1818

tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php b/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
new file mode 100644 (file)
index 0000000..ef4f513
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+use MediaWiki\MediaWikiServices;
+
+/**
+ * @author Addshore
+ * @covers ApiSetNotificationTimestamp
+ * @group API
+ * @group medium
+ * @group Database
+ */
+class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase {
+
+       protected function setUp() {
+               parent::setUp();
+               self::$users[__CLASS__] = new TestUser( __CLASS__ );
+               $this->doLogin( __CLASS__ );
+       }
+
+       public function testStuff() {
+               $user = self::$users[__CLASS__]->getUser();
+               $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
+
+               $user->addWatch( $page->getTitle() );
+
+               $result = $this->doApiRequestWithToken(
+                       [
+                               'action' => 'setnotificationtimestamp',
+                               'timestamp' => '20160101020202',
+                               'pageids' => $page->getId(),
+                       ],
+                       null,
+                       $user
+               );
+
+               $this->assertEquals(
+                       [
+                               'batchcomplete' => true,
+                               'setnotificationtimestamp' => [
+                                       [ 'ns' => 0, 'title' => 'UTPage', 'notificationtimestamp' => '2016-01-01T02:02:02Z' ]
+                               ],
+                       ],
+                       $result[0]
+               );
+
+               $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
+               $this->assertEquals(
+                       $watchedItemStore->getNotificationTimestampsBatch( $user, [ $page->getTitle() ] ),
+                       [ [ 'UTPage' => '20160101020202' ] ]
+               );
+       }
+
+}