| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Api; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class ApiSetNotificationTimestampIntegrationTest extends ApiTestCase { |
| 13 |
|
| 14 |
public function testStuff() { |
| 15 |
$user = $this->getTestUser()->getUser(); |
| 16 |
$watchedPageTitle = 'PageWatched'; |
| 17 |
$pageWatched = $this->getExistingTestPage( $watchedPageTitle ); |
| 18 |
$notWatchedPageTitle = 'PageNotWatched'; |
| 19 |
$pageNotWatched = $this->getExistingTestPage( $notWatchedPageTitle ); |
| 20 |
|
| 21 |
$watchlistManager = $this->getServiceContainer()->getWatchlistManager(); |
| 22 |
$watchlistManager->addWatch( $user, $pageWatched ); |
| 23 |
|
| 24 |
$result = $this->doApiRequestWithToken( |
| 25 |
[ |
| 26 |
'action' => 'setnotificationtimestamp', |
| 27 |
'timestamp' => '20160101020202', |
| 28 |
'titles' => "$watchedPageTitle|$notWatchedPageTitle", |
| 29 |
], |
| 30 |
null, |
| 31 |
$user |
| 32 |
); |
| 33 |
|
| 34 |
$this->assertTrue( $result[0]['batchcomplete'] ); |
| 35 |
$this->assertArrayEquals( |
| 36 |
[ |
| 37 |
[ |
| 38 |
'ns' => NS_MAIN, |
| 39 |
'title' => $watchedPageTitle, |
| 40 |
'notificationtimestamp' => '2016-01-01T02:02:02Z' |
| 41 |
], |
| 42 |
[ |
| 43 |
'ns' => NS_MAIN, |
| 44 |
'title' => $notWatchedPageTitle, |
| 45 |
'notwatched' => true |
| 46 |
], |
| 47 |
], |
| 48 |
$result[0]['setnotificationtimestamp'] |
| 49 |
); |
| 50 |
|
| 51 |
$watchedItemStore = $this->getServiceContainer()->getWatchedItemStore(); |
| 52 |
$this->assertEquals( |
| 53 |
[ [ $watchedPageTitle => '20160101020202', $notWatchedPageTitle => false, ] ], |
| 54 |
$watchedItemStore->getNotificationTimestampsBatch( |
| 55 |
$user, [ $pageWatched->getTitle(), $pageNotWatched->getTitle() ] ) |
| 56 |
); |
| 57 |
} |
| 58 |
|
| 59 |
} |