diff options
author | Marius Hoch <mail@mariushoch.de> | 2023-05-08 16:17:05 +0200 |
---|---|---|
committer | Marius Hoch <mail@mariushoch.de> | 2023-05-30 12:28:15 +0200 |
commit | dc87b69568ca90152491ade38888d9e24dd46c19 (patch) | |
tree | 9b00796de375b002c694775597c6e72ad05ad873 /tests/phpunit/includes/htmlform/HTMLFormFieldTest.php | |
parent | e20f87a117a4695add46da0ebfb813663c87ee43 (diff) | |
download | mediawikicore-dc87b69568ca90152491ade38888d9e24dd46c19.tar.gz mediawikicore-dc87b69568ca90152491ade38888d9e24dd46c19.zip |
Allow setting "notices" for OOUI form fields
We need this in Wikibase to nicely indicate why
a certain form field cannot be used.
Bug: T330193
Change-Id: Ic0a6f9561db41d4da218122477ce9318665929d5
Diffstat (limited to 'tests/phpunit/includes/htmlform/HTMLFormFieldTest.php')
-rw-r--r-- | tests/phpunit/includes/htmlform/HTMLFormFieldTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php b/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php index 2426affa2952..907e546be80b 100644 --- a/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php +++ b/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php @@ -426,4 +426,23 @@ class HTMLFormFieldTest extends PHPUnit\Framework\TestCase { [ '===', 'wpcloner[0][foo]', '1' ], ]; } + + public function testNoticeInfo() { + $form = $this->getNewForm( [ + 'withNotice' => [ 'type' => 'check', 'notices' => [ 'a notice' ] ], + 'withoutNotice' => [ 'type' => 'check' ], + ], [] ); + + $configWithNotice = $configWithoutNotice = []; + $form->getField( 'withNotice' )->getOOUI( '' )->getConfig( $configWithNotice ); + $form->getField( 'withoutNotice' )->getOOUI( '' )->getConfig( $configWithoutNotice ); + + $this->assertArrayHasKey( 'notices', $configWithNotice ); + $this->assertSame( + [ 'a notice' ], + $configWithNotice['notices'] + ); + $this->assertArrayNotHasKey( 'notices', $configWithoutNotice ); + } + } |