2014-08-13 22:00:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group medium
|
|
|
|
* @group API
|
2016-05-23 23:10:58 +00:00
|
|
|
* @group Database
|
2019-10-23 10:23:09 +00:00
|
|
|
* @covers \ApiEchoMarkRead
|
2014-08-13 22:00:25 +00:00
|
|
|
*/
|
|
|
|
class ApiEchoMarkReadTest extends ApiTestCase {
|
|
|
|
|
2018-11-02 17:47:39 +00:00
|
|
|
public function getTokens() {
|
2014-08-13 22:00:25 +00:00
|
|
|
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 );
|
|
|
|
|
|
|
|
$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() {
|
|
|
|
$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 );
|
|
|
|
|
|
|
|
$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() {
|
|
|
|
$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 );
|
|
|
|
|
|
|
|
$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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|