wiki.techinc.nl/tests/phpunit/includes/api/ApiClearHasMsgTest.php
Reedy 75640200fb tests: Namespace api tests
Bug: T357823
Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
2024-02-18 15:47:04 +00:00

37 lines
919 B
PHP

<?php
namespace MediaWiki\Tests\Api;
use MediaWiki\Permissions\UltimateAuthority;
use MediaWiki\User\UserIdentityValue;
/**
* @group API
* @group medium
* @group Database
* @covers \ApiClearHasMsg
*/
class ApiClearHasMsgTest extends ApiTestCase {
/**
* Test clearing hasmsg flag for current user
*/
public function testClearFlag() {
$user = new UserIdentityValue( 42, __METHOD__ );
$talkPageNotificationManager = $this->getServiceContainer()
->getTalkPageNotificationManager();
$talkPageNotificationManager->setUserHasNewMessages( $user );
$this->assertTrue( $talkPageNotificationManager->userHasNewMessages( $user ) );
$data = $this->doApiRequest(
[ 'action' => 'clearhasmsg' ],
[],
false,
new UltimateAuthority( $user )
);
$this->assertEquals( 'success', $data[0]['clearhasmsg'] );
$this->assertFalse( $talkPageNotificationManager->userHasNewMessages( $user ) );
}
}