2014-08-13 22:00:25 +00:00
|
|
|
<?php
|
|
|
|
|
2024-06-12 18:31:47 +00:00
|
|
|
use MediaWiki\Tests\Api\ApiTestCase;
|
|
|
|
|
2014-08-13 22:00:25 +00:00
|
|
|
/**
|
|
|
|
* @group medium
|
|
|
|
* @group API
|
2016-05-23 23:10:58 +00:00
|
|
|
* @group Database
|
2022-10-02 22:44:38 +00:00
|
|
|
* @covers \MediaWiki\Extension\Notifications\Api\ApiEchoMarkRead
|
2014-08-13 22:00:25 +00:00
|
|
|
*/
|
|
|
|
class ApiEchoMarkReadTest extends ApiTestCase {
|
|
|
|
|
|
|
|
public function testMarkReadWithList() {
|
|
|
|
// Grouping by section
|
2021-04-20 20:05:40 +00:00
|
|
|
$data = $this->doApiRequestWithToken( [
|
2014-08-13 22:00:25 +00:00
|
|
|
'action' => 'echomarkread',
|
|
|
|
'notlist' => '121|122|123',
|
2021-04-20 20:05:40 +00:00
|
|
|
] );
|
2014-08-13 22:00:25 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'query', $data[0] );
|
|
|
|
$this->assertArrayHasKey( 'echomarkread', $data[0]['query'] );
|
|
|
|
|
|
|
|
$result = $data[0]['query']['echomarkread'];
|
|
|
|
|
|
|
|
// General count
|
|
|
|
$this->assertArrayHasKey( 'count', $result );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $result );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
|
|
$alert = $result['alert'];
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
|
|
$message = $result['message'];
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMarkReadWithAll() {
|
|
|
|
// Grouping by section
|
2021-04-20 20:05:40 +00:00
|
|
|
$data = $this->doApiRequestWithToken( [
|
2014-08-13 22:00:25 +00:00
|
|
|
'action' => 'echomarkread',
|
|
|
|
'notall' => '1',
|
2021-04-20 20:05:40 +00:00
|
|
|
] );
|
2014-08-13 22:00:25 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'query', $data[0] );
|
|
|
|
$this->assertArrayHasKey( 'echomarkread', $data[0]['query'] );
|
|
|
|
|
|
|
|
$result = $data[0]['query']['echomarkread'];
|
|
|
|
|
|
|
|
// General count
|
|
|
|
$this->assertArrayHasKey( 'count', $result );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $result );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
|
|
$alert = $result['alert'];
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
|
|
$message = $result['message'];
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMarkReadWithSections() {
|
|
|
|
// Grouping by section
|
2021-04-20 20:05:40 +00:00
|
|
|
$data = $this->doApiRequestWithToken( [
|
2014-08-13 22:00:25 +00:00
|
|
|
'action' => 'echomarkread',
|
|
|
|
'sections' => 'alert|message',
|
2021-04-20 20:05:40 +00:00
|
|
|
] );
|
2014-08-13 22:00:25 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'query', $data[0] );
|
|
|
|
$this->assertArrayHasKey( 'echomarkread', $data[0]['query'] );
|
|
|
|
|
|
|
|
$result = $data[0]['query']['echomarkread'];
|
|
|
|
|
|
|
|
// General count
|
|
|
|
$this->assertArrayHasKey( 'count', $result );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $result );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
|
|
$alert = $result['alert'];
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
|
|
$message = $result['message'];
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|