wiki.techinc.nl/tests/phpunit/includes/api/ApiSetNotificationTimestampIntegrationTest.php
Max Semenik 48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00

52 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() : void {
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' ] ]
);
}
}