MediaWiki REL1_31
ChangesListBooleanFilterTest.php
Go to the documentation of this file.
1<?php
2
7 public function testGetJsData() {
9 'name' => 'group',
10 'priority' => 2,
11 'filters' => [],
12 ] );
13
14 $definition = [
15 'group' => $group,
16 'label' => 'main-label',
17 'description' => 'main-description',
18 'default' => 1,
19 'priority' => 1,
20 ];
21
22 $fooFilter = new ChangesListBooleanFilter(
23 $definition + [ 'name' => 'hidefoo' ]
24 );
25
26 $barFilter = new ChangesListBooleanFilter(
27 $definition + [ 'name' => 'hidebar' ]
28 );
29
30 $bazFilter = new ChangesListBooleanFilter(
31 $definition + [ 'name' => 'hidebaz' ]
32 );
33
34 $fooFilter->conflictsWith(
35 $barFilter,
36 'foo-bar-global-conflict',
37 'foo-conflicts-bar',
38 'bar-conflicts-foo'
39 );
40
41 $fooFilter->setAsSupersetOf( $bazFilter, 'foo-superset-of-baz' );
42
43 $fooData = $fooFilter->getJsData();
44 $this->assertArrayEquals(
45 [
46 'name' => 'hidefoo',
47 'label' => 'main-label',
48 'description' => 'main-description',
49 'default' => 1,
50 'priority' => 1,
51 'cssClass' => null,
52 'defaultHighlightColor' => null,
53 'conflicts' => [
54 [
55 'group' => 'group',
56 'filter' => 'hidebar',
57 'globalDescription' => 'foo-bar-global-conflict',
58 'contextDescription' => 'foo-conflicts-bar',
59 ]
60 ],
61 'subset' => [
62 [
63 'group' => 'group',
64 'filter' => 'hidebaz',
65 ],
66
67 ],
68 'messageKeys' => [
69 'main-label',
70 'main-description',
71 'foo-bar-global-conflict',
72 'foo-conflicts-bar',
73 ],
74 ],
75 $fooData,
false, true
78 );
79
80 $barData = $barFilter->getJsData();
81 $this->assertArrayEquals(
82 [
83 'name' => 'hidebar',
84 'label' => 'main-label',
85 'description' => 'main-description',
86 'default' => 1,
87 'priority' => 1,
88 'cssClass' => null,
89 'defaultHighlightColor' => null,
90 'conflicts' => [
91 [
92 'group' => 'group',
93 'filter' => 'hidefoo',
94 'globalDescription' => 'foo-bar-global-conflict',
95 'contextDescription' => 'bar-conflicts-foo',
96 ]
97 ],
98 'subset' => [],
99 'messageKeys' => [
100 'main-label',
101 'main-description',
102 'foo-bar-global-conflict',
103 'bar-conflicts-foo',
104 ],
105 ],
106 $barData,
false, true
109 );
110 }
111
113 $groupA = new ChangesListBooleanFilterGroup( [
114 'name' => 'groupA',
115 'priority' => 1,
116 'filters' => [],
117 ] );
118
119 $foo = new ChangesListBooleanFilter( [
120 'name' => 'hidefoo',
121 'group' => $groupA,
122 'label' => 'foo-label',
123 'description' => 'foo-description',
124 'default' => true,
125 'showHide' => 'showhidefoo',
126 'priority' => 2,
127 ] );
128
129 $this->assertEquals(
130 true,
131 $foo->isFeatureAvailableOnStructuredUi(),
132 'Same filter appears on both'
133 );
134
135 // Should only be legacy ones that haven't been ported yet
136 $bar = new ChangesListBooleanFilter( [
137 'name' => 'hidebar',
138 'default' => true,
139 'group' => $groupA,
140 'showHide' => 'showhidebar',
141 'priority' => 2,
142 ] );
143
144 $this->assertEquals(
145 false,
146 $bar->isFeatureAvailableOnStructuredUi(),
147 'Only on unstructured UI'
148 );
149
150 $baz = new ChangesListBooleanFilter( [
151 'name' => 'hidebaz',
152 'default' => true,
153 'group' => $groupA,
154 'showHide' => 'showhidebaz',
155 'isReplacedInStructuredUi' => true,
156 'priority' => 2,
157 ] );
158
159 $this->assertEquals(
160 true,
161 $baz->isFeatureAvailableOnStructuredUi(),
162 'Legacy filter does not appear directly in new UI, but equivalent ' .
163 'does and is marked with isReplacedInStructuredUi'
164 );
165 }
166}
If the group is active, any unchecked filters will translate to hide parameters in the URL.
Represents a hide-based boolean filter (used on ChangesListSpecialPage and descendants)
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37