Mock the needed dependencies to avoid database access when possible, and add the test to the Database group otherwise. Bug: T155147 Change-Id: Ic5c39ab35ab4d993721713285180f072497a5a40
35 lines
886 B
PHP
35 lines
886 B
PHP
<?php
|
|
|
|
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 ) );
|
|
}
|
|
|
|
}
|