2016-05-18 11:08:47 +00:00
|
|
|
<?php
|
2019-05-28 14:04:23 +00:00
|
|
|
|
2024-02-16 19:35:21 +00:00
|
|
|
namespace MediaWiki\Tests\Api;
|
|
|
|
|
|
2016-05-18 11:08:47 +00:00
|
|
|
/**
|
|
|
|
|
* @author Addshore
|
2024-02-16 18:04:47 +00:00
|
|
|
* @covers \ApiSetNotificationTimestamp
|
2016-05-18 11:08:47 +00:00
|
|
|
* @group API
|
|
|
|
|
* @group medium
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
|
|
|
|
class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase {
|
|
|
|
|
|
|
|
|
|
public function testStuff() {
|
2021-01-21 02:47:22 +00:00
|
|
|
$user = $this->getTestUser()->getUser();
|
2023-08-09 01:01:19 +00:00
|
|
|
$watchedPageTitle = 'PageWatched';
|
|
|
|
|
$pageWatched = $this->getExistingTestPage( $watchedPageTitle );
|
|
|
|
|
$notWatchedPageTitle = 'PageNotWatched';
|
|
|
|
|
$pageNotWatched = $this->getExistingTestPage( $notWatchedPageTitle );
|
2016-05-18 11:08:47 +00:00
|
|
|
|
2021-04-13 03:28:23 +00:00
|
|
|
$watchlistManager = $this->getServiceContainer()->getWatchlistManager();
|
2021-08-19 21:57:23 +00:00
|
|
|
$watchlistManager->addWatch( $user, $pageWatched );
|
2016-05-18 11:08:47 +00:00
|
|
|
|
|
|
|
|
$result = $this->doApiRequestWithToken(
|
|
|
|
|
[
|
|
|
|
|
'action' => 'setnotificationtimestamp',
|
|
|
|
|
'timestamp' => '20160101020202',
|
2023-08-09 01:01:19 +00:00
|
|
|
'titles' => "$watchedPageTitle|$notWatchedPageTitle",
|
2016-05-18 11:08:47 +00:00
|
|
|
],
|
|
|
|
|
null,
|
|
|
|
|
$user
|
|
|
|
|
);
|
|
|
|
|
|
2023-08-09 01:01:19 +00:00
|
|
|
$this->assertTrue( $result[0]['batchcomplete'] );
|
|
|
|
|
$this->assertArrayEquals(
|
2016-05-18 11:08:47 +00:00
|
|
|
[
|
2023-08-09 01:01:19 +00:00
|
|
|
[
|
|
|
|
|
'ns' => NS_MAIN,
|
|
|
|
|
'title' => $watchedPageTitle,
|
|
|
|
|
'notificationtimestamp' => '2016-01-01T02:02:02Z'
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'ns' => NS_MAIN,
|
|
|
|
|
'title' => $notWatchedPageTitle,
|
|
|
|
|
'notwatched' => true
|
2016-05-18 11:08:47 +00:00
|
|
|
],
|
|
|
|
|
],
|
2023-08-09 01:01:19 +00:00
|
|
|
$result[0]['setnotificationtimestamp']
|
2016-05-18 11:08:47 +00:00
|
|
|
);
|
|
|
|
|
|
2022-01-12 20:13:39 +00:00
|
|
|
$watchedItemStore = $this->getServiceContainer()->getWatchedItemStore();
|
2016-05-18 11:08:47 +00:00
|
|
|
$this->assertEquals(
|
2023-08-09 01:01:19 +00:00
|
|
|
[ [ $watchedPageTitle => '20160101020202', $notWatchedPageTitle => false, ] ],
|
2021-08-19 21:57:23 +00:00
|
|
|
$watchedItemStore->getNotificationTimestampsBatch(
|
2023-03-11 19:04:01 +00:00
|
|
|
$user, [ $pageWatched->getTitle(), $pageNotWatched->getTitle() ] )
|
2016-05-18 11:08:47 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|