Merge "Hard deprecrate Language::viewPrevNext()"
[lhc/web/wiklou.git] / tests / phpunit / includes / changes / ChangesListFilterGroupTest.php
1 <?php
2
3 /**
4 * @covers ChangesListFilterGroup
5 */
6 class ChangesListFilterGroupTest extends MediaWikiTestCase {
7 /**
8 * phpcs:disable Generic.Files.LineLength
9 * @expectedException MWException
10 * @expectedExceptionMessage Group names may not contain '_'. Use the naming convention: 'camelCase'
11 * phpcs:enable
12 */
13 public function testReservedCharacter() {
14 new MockChangesListFilterGroup(
15 [
16 'type' => 'some_type',
17 'name' => 'group_name',
18 'priority' => 1,
19 'filters' => [],
20 ]
21 );
22 }
23
24 public function testAutoPriorities() {
25 $group = new MockChangesListFilterGroup(
26 [
27 'type' => 'some_type',
28 'name' => 'groupName',
29 'isFullCoverage' => true,
30 'priority' => 1,
31 'filters' => [
32 [ 'name' => 'hidefoo' ],
33 [ 'name' => 'hidebar' ],
34 [ 'name' => 'hidebaz' ],
35 ],
36 ]
37 );
38
39 $filters = $group->getFilters();
40 $this->assertEquals(
41 [
42 -2,
43 -3,
44 -4,
45 ],
46 array_map(
47 function ( $f ) {
48 return $f->getPriority();
49 },
50 array_values( $filters )
51 )
52 );
53 }
54
55 // Get without warnings
56 public function testGetFilter() {
57 $group = new MockChangesListFilterGroup(
58 [
59 'type' => 'some_type',
60 'name' => 'groupName',
61 'isFullCoverage' => true,
62 'priority' => 1,
63 'filters' => [
64 [ 'name' => 'foo' ],
65 ],
66 ]
67 );
68
69 $this->assertEquals(
70 'foo',
71 $group->getFilter( 'foo' )->getName()
72 );
73
74 $this->assertEquals(
75 null,
76 $group->getFilter( 'bar' )
77 );
78 }
79 }