4 * @covers ChangesListBooleanFilter
6 class ChangesListBooleanFilterTest
extends MediaWikiTestCase
{
7 public function testGetJsData() {
8 $group = new ChangesListBooleanFilterGroup( [
16 'label' => 'main-label',
17 'description' => 'main-description',
22 $fooFilter = new ChangesListBooleanFilter(
23 $definition +
[ 'name' => 'hidefoo' ]
26 $barFilter = new ChangesListBooleanFilter(
27 $definition +
[ 'name' => 'hidebar' ]
30 $bazFilter = new ChangesListBooleanFilter(
31 $definition +
[ 'name' => 'hidebaz' ]
34 $fooFilter->conflictsWith(
36 'foo-bar-global-conflict',
41 $fooFilter->setAsSupersetOf( $bazFilter, 'foo-superset-of-baz' );
43 $fooData = $fooFilter->getJsData();
44 $this->assertArrayEquals(
47 'label' => 'main-label',
48 'description' => 'main-description',
55 'filter' => 'hidebar',
56 'globalDescription' => 'foo-bar-global-conflict',
57 'contextDescription' => 'foo-conflicts-bar',
63 'filter' => 'hidebaz',
70 'foo-bar-global-conflict',
75 /** ordered= */ false,
79 $barData = $barFilter->getJsData();
80 $this->assertArrayEquals(
83 'label' => 'main-label',
84 'description' => 'main-description',
91 'filter' => 'hidefoo',
92 'globalDescription' => 'foo-bar-global-conflict',
93 'contextDescription' => 'bar-conflicts-foo',
100 'foo-bar-global-conflict',
105 /** ordered= */ false,
111 * @expectedException MWException
112 * @expectedExceptionMessage Supersets can only be defined for filters in the same group
114 public function testSetAsSupersetOf() {
115 $groupA = new ChangesListBooleanFilterGroup( [
130 $groupB = new ChangesListBooleanFilterGroup( [
141 $foo = TestingAccessWrapper
::newFromObject( $groupA->getFilter( 'foo' ) );
143 $bar = $groupA->getFilter( 'bar' );
145 $baz = $groupB->getFilter( 'baz' );
147 $foo->setAsSupersetOf( $bar );
148 $this->assertArrayEquals( [
155 /** ordered= */ false,
159 $foo->setAsSupersetOf( $baz, 'some-message' );
162 public function testIsFeatureAvailableOnStructuredUi() {
163 $specialPage = $this->getMockBuilder( 'ChangesListSpecialPage' )
164 ->setConstructorArgs( [
165 'ChangesListSpecialPage',
168 ->getMockForAbstractClass();
170 $groupA = new ChangesListBooleanFilterGroup( [
176 $foo = new ChangesListBooleanFilter( [
179 'label' => 'foo-label',
180 'description' => 'foo-description',
182 'showHide' => 'showhidefoo',
188 $foo->isFeatureAvailableOnStructuredUi( $specialPage ),
189 'Same filter appears on both'
192 // Should only be legacy ones that haven't been ported yet
193 $bar = new ChangesListBooleanFilter( [
197 'showHide' => 'showhidebar',
203 $bar->isFeatureAvailableOnStructuredUi( $specialPage ),
204 'Only on unstructured UI'
207 $baz = new ChangesListBooleanFilter( [
211 'showHide' => 'showhidebaz',
212 'isReplacedInStructuredUi' => true,
218 $baz->isFeatureAvailableOnStructuredUi( $specialPage ),
219 'Legacy filter does not appear directly in new UI, but equivalent ' .
220 'does and is marked with isReplacedInStructuredUi'