wiki.techinc.nl/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
Aryeh Gregor ed40e8ec53 Get rid of ApiTestCase::doLogin
The function is entirely unnecessary.

Change-Id: I805520e5355119e872e602d0bfc93be26f227128
2018-04-11 20:17:52 +03:00

51 lines
1.1 KiB
PHP

<?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__ );
}
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' ] ]
);
}
}