2018-01-02 02:58:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
2024-02-16 19:35:21 +00:00
|
|
|
namespace MediaWiki\Tests\Api;
|
|
|
|
|
|
2023-07-16 23:53:31 +00:00
|
|
|
use MediaWiki\Permissions\UltimateAuthority;
|
|
|
|
|
use MediaWiki\User\UserIdentityValue;
|
|
|
|
|
|
2018-01-02 02:58:08 +00:00
|
|
|
/**
|
|
|
|
|
* @group API
|
|
|
|
|
* @group medium
|
2023-08-01 00:57:54 +00:00
|
|
|
* @group Database
|
2024-02-16 18:04:47 +00:00
|
|
|
* @covers \ApiClearHasMsg
|
2018-01-02 02:58:08 +00:00
|
|
|
*/
|
|
|
|
|
class ApiClearHasMsgTest extends ApiTestCase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test clearing hasmsg flag for current user
|
|
|
|
|
*/
|
|
|
|
|
public function testClearFlag() {
|
2023-07-16 23:53:31 +00:00
|
|
|
$user = new UserIdentityValue( 42, __METHOD__ );
|
2022-01-12 20:13:39 +00:00
|
|
|
$talkPageNotificationManager = $this->getServiceContainer()
|
2020-05-15 16:35:45 +00:00
|
|
|
->getTalkPageNotificationManager();
|
|
|
|
|
$talkPageNotificationManager->setUserHasNewMessages( $user );
|
2021-11-21 19:13:24 +00:00
|
|
|
$this->assertTrue( $talkPageNotificationManager->userHasNewMessages( $user ) );
|
2018-01-02 02:58:08 +00:00
|
|
|
|
2023-07-16 23:53:31 +00:00
|
|
|
$data = $this->doApiRequest(
|
|
|
|
|
[ 'action' => 'clearhasmsg' ],
|
|
|
|
|
[],
|
|
|
|
|
false,
|
|
|
|
|
new UltimateAuthority( $user )
|
|
|
|
|
);
|
2018-01-02 02:58:08 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals( 'success', $data[0]['clearhasmsg'] );
|
2020-05-15 16:35:45 +00:00
|
|
|
$this->assertFalse( $talkPageNotificationManager->userHasNewMessages( $user ) );
|
2018-01-02 02:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|