Debian Codegraph @

tests/phpunit/includes/api/ApiClearHasMsgTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Api;
4
5 use MediaWiki\Permissions\UltimateAuthority;
6 use MediaWiki\User\UserIdentityValue;
7
8 /**
9 * @group API
10 * @group medium
11 * @group Database
12 * @covers \MediaWiki\Api\ApiClearHasMsg
13 */
14 class ApiClearHasMsgTest extends ApiTestCase {
15
16 /**
17 * Test clearing hasmsg flag for current user
18 */
19 public function testClearFlag() {
20 $user = new UserIdentityValue( 42, __METHOD__ );
21 $talkPageNotificationManager = $this->getServiceContainer()
22 ->getTalkPageNotificationManager();
23 $talkPageNotificationManager->setUserHasNewMessages( $user );
24 $this->assertTrue( $talkPageNotificationManager->userHasNewMessages( $user ) );
25
26 $data = $this->doApiRequest(
27 [ 'action' => 'clearhasmsg' ],
28 [],
29 false,
30 new UltimateAuthority( $user )
31 );
32
33 $this->assertEquals( 'success', $data[0]['clearhasmsg'] );
34 $this->assertFalse( $talkPageNotificationManager->userHasNewMessages( $user ) );
35 }
36
37 }