diff options
author | Dreamy Jazz <wpgbrown@wikimedia.org> | 2024-11-01 16:17:26 +0000 |
---|---|---|
committer | Dreamy Jazz <wpgbrown@wikimedia.org> | 2024-11-01 16:31:49 +0000 |
commit | 43baaac14945f8ceda49a9b641da778f69aae027 (patch) | |
tree | 58fed67c43791e3c34a8270f0726dd2665b6f13b /tests/phpunit/integration/includes | |
parent | 08045dd3fba6f82503eb43fd8211122e2a4c6838 (diff) | |
download | mediawikicore-43baaac14945f8ceda49a9b641da778f69aae027.tar.gz mediawikicore-43baaac14945f8ceda49a9b641da778f69aae027.zip |
NamespaceInputWidget: Correctly set default for 'include'
Why:
* In 5617115fe22337ba464bd6b253c1d2af941b2adc, the
NamespaceInputWidget class was modified to support filtering
out all namespaces but a specified few.
* The modifications to the ::__construct method incorrectly set
the default for this include list as an empty list, which meant
that by default all namespaces were excluded.
* This commit fixes that to instead make the default null, which
does not apply any filtering.
What:
* Fix NamespaceInputWidget::__construct to correctly set the
default for the 'include' configuration value.
* Add regression tests with this fix.
Bug: T378810
Change-Id: Ie00483641cf058b4522b60a72393a8f1ba4d15a1
Diffstat (limited to 'tests/phpunit/integration/includes')
-rw-r--r-- | tests/phpunit/integration/includes/widget/NamespaceInputWidgetTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/phpunit/integration/includes/widget/NamespaceInputWidgetTest.php b/tests/phpunit/integration/includes/widget/NamespaceInputWidgetTest.php new file mode 100644 index 000000000000..c72416c36d72 --- /dev/null +++ b/tests/phpunit/integration/includes/widget/NamespaceInputWidgetTest.php @@ -0,0 +1,34 @@ +<?php + +namespace MediaWiki\Tests\Integration\Widget; + +use MediaWiki\Widget\NamespaceInputWidget; +use MediaWikiIntegrationTestCase; +use Wikimedia\TestingAccessWrapper; + +/** + * @covers \MediaWiki\Widget\NamespaceInputWidget + */ +class NamespaceInputWidgetTest extends MediaWikiIntegrationTestCase { + /** @dataProvider provideConstruct */ + public function testConstruct( $config, $expectedPropertyValues ) { + $widget = new NamespaceInputWidget( $config ); + $widget = TestingAccessWrapper::newFromObject( $widget ); + foreach ( $expectedPropertyValues as $property => $expectedValue ) { + $this->assertSame( $expectedValue, $widget->$property ); + } + } + + public static function provideConstruct() { + return [ + 'Empty config provided gives defaults' => [ + [], + [ 'include' => null, 'exclude' => [], 'userLang' => false, 'includeAllValue' => null ], + ], + 'Custom values for config' => [ + [ 'include' => [ 0 ], 'exclude' => [ 1 ], 'userLang' => 'en', 'includeAllValue' => 'include' ], + [ 'include' => [ 0 ], 'exclude' => [ 1 ], 'userLang' => 'en', 'includeAllValue' => 'include' ], + ], + ]; + } +} |