mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
ad691fb838
When two array have the same keys, we want to merge them into one array rather than one overwriting another one This was preventing count and rawcount from appearing inside the messages and alerts object returned by the API. Change-Id: I989b9b0994a33925faf52c6d99d8c46920e62cd6
72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group medium
|
|
* @group API
|
|
* @covers ApiQuery
|
|
*/
|
|
class ApiEchoNotificationsTest extends ApiTestCase {
|
|
|
|
public function testWithSectionGrouping() {
|
|
// Grouping by section
|
|
$data = $this->doApiRequest( array(
|
|
'action' => 'query',
|
|
'meta' => 'notifications',
|
|
'notsections' => 'alert|message',
|
|
'notgroupbysection' => 1,
|
|
'notlimit' => 10,
|
|
'notprop' => 'index|list|count' ) );
|
|
|
|
$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 );
|
|
|
|
// Alert
|
|
$this->assertArrayHasKey( 'alert', $result );
|
|
$alert = $result['alert'];
|
|
$this->assertArrayHasKey( 'list', $alert );
|
|
$this->assertArrayHasKey( 'continue', $alert );
|
|
$this->assertArrayHasKey( 'index', $alert );
|
|
$this->assertArrayHasKey( 'rawcount', $alert );
|
|
$this->assertArrayHasKey( 'count', $alert );
|
|
|
|
// Message
|
|
$this->assertArrayHasKey( 'message', $result );
|
|
$message = $result['message'];
|
|
$this->assertArrayHasKey( 'list', $message );
|
|
$this->assertArrayHasKey( 'continue', $message );
|
|
$this->assertArrayHasKey( 'index', $message );
|
|
$this->assertArrayHasKey( 'rawcount', $message );
|
|
$this->assertArrayHasKey( 'count', $message );
|
|
}
|
|
|
|
public function testWithoutSectionGrouping() {
|
|
$data = $this->doApiRequest( array(
|
|
'action' => 'query',
|
|
'meta' => 'notifications',
|
|
'notsections' => 'alert|message',
|
|
'notlimit' => 10,
|
|
'notprop' => 'index|list|count' ) );
|
|
|
|
$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->assertArrayHasKey( 'index', $result );
|
|
|
|
$this->assertTrue( !isset( $result['alert'] ) );
|
|
$this->assertTrue( !isset( $result['message'] ) );
|
|
}
|
|
|
|
}
|