mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 09:40:41 +00:00
86b4ed5c56
I805520e5 is removing all callers from core. Change-Id: I56025a9c64406f44cb157a17e308da358de0da47
106 lines
2.9 KiB
PHP
106 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group medium
|
|
* @group API
|
|
* @group Database
|
|
* @covers ApiEchoMarkRead
|
|
*/
|
|
class ApiEchoMarkReadTest extends ApiTestCase {
|
|
|
|
function getTokens() {
|
|
return $this->getTokenList( self::$users['sysop'] );
|
|
}
|
|
|
|
public function testMarkReadWithList() {
|
|
$tokens = $this->getTokens();
|
|
// Grouping by section
|
|
$data = $this->doApiRequest( [
|
|
'action' => 'echomarkread',
|
|
'notlist' => '121|122|123',
|
|
'token' => $tokens['edittoken'] ] );
|
|
|
|
$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 );
|
|
|
|
// Alert
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
$alert = $result['alert'];
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
// Message
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
$message = $result['message'];
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
}
|
|
|
|
public function testMarkReadWithAll() {
|
|
$tokens = $this->getTokens();
|
|
// Grouping by section
|
|
$data = $this->doApiRequest( [
|
|
'action' => 'echomarkread',
|
|
'notall' => '1',
|
|
'token' => $tokens['edittoken'] ] );
|
|
|
|
$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 );
|
|
|
|
// Alert
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
$alert = $result['alert'];
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
// Message
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
$message = $result['message'];
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
}
|
|
|
|
public function testMarkReadWithSections() {
|
|
$tokens = $this->getTokens();
|
|
// Grouping by section
|
|
$data = $this->doApiRequest( [
|
|
'action' => 'echomarkread',
|
|
'sections' => 'alert|message',
|
|
'token' => $tokens['edittoken'] ] );
|
|
|
|
$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 );
|
|
|
|
// Alert
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
$alert = $result['alert'];
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
// Message
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
$message = $result['message'];
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
}
|
|
|
|
}
|