2014-08-14 18:46:26 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-22 15:31:00 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\Test\API;
|
|
|
|
|
2024-06-12 18:31:47 +00:00
|
|
|
use MediaWiki\Tests\Api\ApiTestCase;
|
|
|
|
|
2014-08-14 18:46:26 +00:00
|
|
|
/**
|
|
|
|
* @group medium
|
|
|
|
* @group API
|
2023-08-04 00:31:24 +00:00
|
|
|
* @group Database
|
2022-10-02 22:44:38 +00:00
|
|
|
* @covers \MediaWiki\Extension\Notifications\Api\ApiEchoNotifications
|
2014-08-14 18:46:26 +00:00
|
|
|
*/
|
|
|
|
class ApiEchoNotificationsTest extends ApiTestCase {
|
|
|
|
|
|
|
|
public function testWithSectionGrouping() {
|
|
|
|
// Grouping by section
|
2016-12-05 18:51:07 +00:00
|
|
|
$data = $this->doApiRequest( [
|
2014-08-14 18:46:26 +00:00
|
|
|
'action' => 'query',
|
|
|
|
'meta' => 'notifications',
|
|
|
|
'notsections' => 'alert|message',
|
|
|
|
'notgroupbysection' => 1,
|
|
|
|
'notlimit' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
'notprop' => 'list|count' ] );
|
2014-08-14 18:46:26 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'query', $data[0] );
|
|
|
|
$this->assertArrayHasKey( 'notifications', $data[0]['query'] );
|
|
|
|
|
|
|
|
$result = $data[0]['query']['notifications'];
|
|
|
|
|
|
|
|
// General count
|
|
|
|
$this->assertArrayHasKey( 'count', $result );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $result );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
|
|
$alert = $result['alert'];
|
|
|
|
$this->assertArrayHasKey( 'list', $alert );
|
|
|
|
$this->assertArrayHasKey( 'continue', $alert );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
|
|
$message = $result['message'];
|
|
|
|
$this->assertArrayHasKey( 'list', $message );
|
|
|
|
$this->assertArrayHasKey( 'continue', $message );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWithoutSectionGrouping() {
|
2016-12-05 18:51:07 +00:00
|
|
|
$data = $this->doApiRequest( [
|
2014-08-14 18:46:26 +00:00
|
|
|
'action' => 'query',
|
|
|
|
'meta' => 'notifications',
|
|
|
|
'notsections' => 'alert|message',
|
|
|
|
'notlimit' => 10,
|
2016-12-05 18:51:07 +00:00
|
|
|
'notprop' => 'list|count' ] );
|
2014-08-14 18:46:26 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'query', $data[0] );
|
|
|
|
$this->assertArrayHasKey( 'notifications', $data[0]['query'] );
|
|
|
|
|
|
|
|
$result = $data[0]['query']['notifications'];
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'count', $result );
|
|
|
|
$this->assertArrayHasKey( 'rawcount', $result );
|
|
|
|
$this->assertArrayHasKey( 'list', $result );
|
|
|
|
$this->assertArrayHasKey( 'continue', $result );
|
|
|
|
|
|
|
|
$this->assertTrue( !isset( $result['alert'] ) );
|
|
|
|
$this->assertTrue( !isset( $result['message'] ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|