2014-08-13 22:00:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group medium
|
|
|
|
* @group API
|
2016-05-23 23:10:58 +00:00
|
|
|
* @group Database
|
2014-08-13 22:00:25 +00:00
|
|
|
* @covers ApiQuery
|
|
|
|
*/
|
|
|
|
class ApiEchoMarkReadTest extends ApiTestCase {
|
|
|
|
|
|
|
|
protected function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->doLogin();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTokens() {
|
|
|
|
return $this->getTokenList( self::$users['sysop'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMarkReadWithList() {
|
|
|
|
$tokens = $this->getTokens();
|
|
|
|
// Grouping by section
|
2016-12-05 18:51:07 +00:00
|
|
|
$data = $this->doApiRequest( [
|
2014-08-13 22:00:25 +00:00
|
|
|
'action' => 'echomarkread',
|
|
|
|
'notlist' => '121|122|123',
|
2016-12-05 18:51:07 +00:00
|
|
|
'token' => $tokens['edittoken'] ] );
|
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 );
|
|
|
|
|
|
|
|
// 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
|
2016-12-05 18:51:07 +00:00
|
|
|
$data = $this->doApiRequest( [
|
2014-08-13 22:00:25 +00:00
|
|
|
'action' => 'echomarkread',
|
|
|
|
'notall' => '1',
|
2016-12-05 18:51:07 +00:00
|
|
|
'token' => $tokens['edittoken'] ] );
|
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 );
|
|
|
|
|
|
|
|
// 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
|
2016-12-05 18:51:07 +00:00
|
|
|
$data = $this->doApiRequest( [
|
2014-08-13 22:00:25 +00:00
|
|
|
'action' => 'echomarkread',
|
|
|
|
'sections' => 'alert|message',
|
2016-12-05 18:51:07 +00:00
|
|
|
'token' => $tokens['edittoken'] ] );
|
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 );
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|