mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
291ea47dd3
This might make dependencies easier to find. Change-Id: I158fd9f63f18a2b8da0368ac95d5fb5aa9bca3ff
97 lines
2.7 KiB
PHP
97 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Test\API;
|
|
|
|
use MediaWiki\Tests\Api\ApiTestCase;
|
|
|
|
/**
|
|
* @group medium
|
|
* @group API
|
|
* @group Database
|
|
* @covers \MediaWiki\Extension\Notifications\Api\ApiEchoMarkRead
|
|
*/
|
|
class ApiEchoMarkReadTest extends ApiTestCase {
|
|
|
|
public function testMarkReadWithList() {
|
|
// Grouping by section
|
|
$data = $this->doApiRequestWithToken( [
|
|
'action' => 'echomarkread',
|
|
'notlist' => '121|122|123',
|
|
] );
|
|
|
|
$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
|
|
$data = $this->doApiRequestWithToken( [
|
|
'action' => 'echomarkread',
|
|
'notall' => '1',
|
|
] );
|
|
|
|
$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
|
|
$data = $this->doApiRequestWithToken( [
|
|
'action' => 'echomarkread',
|
|
'sections' => 'alert|message',
|
|
] );
|
|
|
|
$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 );
|
|
}
|
|
|
|
}
|