RCFilters: Test abstract class func directly, not in subclass tests
[lhc/web/wiklou.git] / tests / phpunit / includes / changes / ChangesListFilterTest.php
1 <?php
2
3 /**
4 * @covers ChangesListFilter
5 */
6 class ChangesListFilterTest extends MediaWikiTestCase {
7 protected $group;
8
9 public function setUp() {
10 $this->group = $this->getGroup( [ 'name' => 'group' ] );
11
12 parent::setUp();
13 }
14
15 protected function getGroup( $groupDefinition ) {
16 return new MockChangesListFilterGroup(
17 $groupDefinition + [
18 'isFullCoverage' => true,
19 'type' => 'some_type',
20 'name' => 'group',
21 'filters' => [],
22 ]
23 );
24
25 }
26
27 /**
28 * @expectedException MWException
29 * @expectedExceptionMessage Supersets can only be defined for filters in the same group
30 */
31 public function testSetAsSupersetOf() {
32 $groupA = $this->getGroup(
33 [
34 'name' => 'groupA',
35 'filters' => [
36 [
37 'name' => 'foo',
38 ],
39 [
40 'name' => 'bar',
41 ]
42 ],
43 ]
44 );
45
46 $groupB = $this->getGroup(
47 [
48 'name' => 'groupB',
49 'filters' => [
50 [
51 'name' => 'baz',
52 ],
53 ],
54 ]
55 );
56
57 $foo = TestingAccessWrapper::newFromObject( $groupA->getFilter( 'foo' ) );
58
59 $bar = $groupA->getFilter( 'bar' );
60
61 $baz = $groupB->getFilter( 'baz' );
62
63 $foo->setAsSupersetOf( $bar );
64 $this->assertArrayEquals( [
65 [
66 'group' => 'groupA',
67 'filter' => 'bar',
68 ],
69 ],
70 $foo->subsetFilters,
71 /** ordered= */ false,
72 /** named= */ true
73 );
74
75 $foo->setAsSupersetOf( $baz );
76 }
77 }