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',
52 'defaultHighlightColor' => null,
56 'filter' => 'hidebar',
57 'globalDescription' => 'foo-bar-global-conflict',
58 'contextDescription' => 'foo-conflicts-bar',
64 'filter' => 'hidebaz',
71 'foo-bar-global-conflict',
76 /** ordered= */ false,
80 $barData = $barFilter->getJsData();
81 $this->assertArrayEquals(
84 'label' => 'main-label',
85 'description' => 'main-description',
89 'defaultHighlightColor' => null,
93 'filter' => 'hidefoo',
94 'globalDescription' => 'foo-bar-global-conflict',
95 'contextDescription' => 'bar-conflicts-foo',
102 'foo-bar-global-conflict',
107 /** ordered= */ false,
112 public function testIsFeatureAvailableOnStructuredUi() {
113 $groupA = new ChangesListBooleanFilterGroup( [
119 $foo = new ChangesListBooleanFilter( [
122 'label' => 'foo-label',
123 'description' => 'foo-description',
125 'showHide' => 'showhidefoo',
131 $foo->isFeatureAvailableOnStructuredUi(),
132 'Same filter appears on both'
135 // Should only be legacy ones that haven't been ported yet
136 $bar = new ChangesListBooleanFilter( [
140 'showHide' => 'showhidebar',
146 $bar->isFeatureAvailableOnStructuredUi(),
147 'Only on unstructured UI'
150 $baz = new ChangesListBooleanFilter( [
154 'showHide' => 'showhidebaz',
155 'isReplacedInStructuredUi' => true,
161 $baz->isFeatureAvailableOnStructuredUi(),
162 'Legacy filter does not appear directly in new UI, but equivalent ' .
163 'does and is marked with isReplacedInStructuredUi'