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,
110 public function testIsFeatureAvailableOnStructuredUi() {
111 $groupA = new ChangesListBooleanFilterGroup( [
117 $foo = new ChangesListBooleanFilter( [
120 'label' => 'foo-label',
121 'description' => 'foo-description',
123 'showHide' => 'showhidefoo',
129 $foo->isFeatureAvailableOnStructuredUi(),
130 'Same filter appears on both'
133 // Should only be legacy ones that haven't been ported yet
134 $bar = new ChangesListBooleanFilter( [
138 'showHide' => 'showhidebar',
144 $bar->isFeatureAvailableOnStructuredUi(),
145 'Only on unstructured UI'
148 $baz = new ChangesListBooleanFilter( [
152 'showHide' => 'showhidebaz',
153 'isReplacedInStructuredUi' => true,
159 $baz->isFeatureAvailableOnStructuredUi(),
160 'Legacy filter does not appear directly in new UI, but equivalent ' .
161 'does and is marked with isReplacedInStructuredUi'