wiki.techinc.nl/tests/phpunit/includes/api/ApiClearHasMsgTest.php
Clara Andrew-Wani b3a5c7c0d5 Use new TalkPageNotificationManager
Bug: T239640
Change-Id: I7c06d145854ab39faaef528e169f6b51de1c8d99
2020-05-15 12:35:45 -04:00

28 lines
777 B
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* @group API
* @group medium
* @covers ApiClearHasMsg
*/
class ApiClearHasMsgTest extends ApiTestCase {
/**
* Test clearing hasmsg flag for current user
*/
public function testClearFlag() {
$user = self::$users['sysop']->getUser();
$talkPageNotificationManager = MediaWikiServices::getInstance()
->getTalkPageNotificationManager();
$talkPageNotificationManager->setUserHasNewMessages( $user );
$this->assertTrue( $talkPageNotificationManager->userHasNewMessages( $user ), 'sanity check' );
$data = $this->doApiRequest( [ 'action' => 'clearhasmsg' ], [] );
$this->assertEquals( 'success', $data[0]['clearhasmsg'] );
$this->assertFalse( $talkPageNotificationManager->userHasNewMessages( $user ) );
}
}