summaryrefslogtreecommitdiff
blob: 9f86a6efb3aa1ab47da712eeb7da2809e95fbf7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

/**
 * @group medium
 * @group API
 * @covers ApiQuery
 */
class ApiEchoNotificationsTest extends ApiTestCase {

	public function testWithSectionGrouping() {
		// Grouping by section
		$data = $this->doApiRequest( [
			'action' => 'query',
			'meta' => 'notifications',
			'notsections' => 'alert|message',
			'notgroupbysection' => 1,
			'notlimit' => 10,
			'notprop' => '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( 'rawcount', $alert );
		$this->assertArrayHasKey( 'count', $alert );

		// Message
		$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() {
		$data = $this->doApiRequest( [
			'action' => 'query',
			'meta' => 'notifications',
			'notsections' => 'alert|message',
			'notlimit' => 10,
			'notprop' => '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->assertTrue( !isset( $result['alert'] ) );
		$this->assertTrue( !isset( $result['message'] ) );
	}

}