wiki.techinc.nl/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
Cindy Cicalese b242d49a62 Use WatchlistManager in API classes
Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
2021-04-21 04:41:06 +00:00

57 lines
1.3 KiB
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* @author Addshore
* @covers ApiSetNotificationTimestamp
* @group API
* @group medium
* @group Database
*/
class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase {
protected function setUp(): void {
parent::setUp();
$this->tablesUsed = array_merge(
$this->tablesUsed,
[ 'watchlist', 'watchlist_expiry' ]
);
}
public function testStuff() {
$user = $this->getTestUser()->getUser();
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
$watchlistManager = $this->getServiceContainer()->getWatchlistManager();
$watchlistManager->addWatch( $user, $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' ] ]
);
}
}