X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FXmlTest.php;h=c5572b46c6c79a68fa255152bfc80d47ae39261f;hb=86f4025ceafaaa56231a94ac3878a4a665e6f825;hp=25b754d2bc1c012c9441dbd8d8e63c5f13a2b760;hpb=91be4ee4645e28866910f654c6eda730a692fc90;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index 25b754d2bc..c5572b46c6 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -477,4 +477,55 @@ class XmlTest extends MediaWikiTestCase { ] ) ); } + + /** + * @covers Xml::fieldset + */ + public function testFieldset() { + $this->assertEquals( + "
\n", + Xml::fieldset(), + 'Opening tag' + ); + $this->assertEquals( + "
\n", + Xml::fieldset( false ), + 'Opening tag (false means no legend)' + ); + $this->assertEquals( + "
\n", + Xml::fieldset( '' ), + 'Opening tag (empty string also means no legend)' + ); + $this->assertEquals( + "
\nFoo\n", + Xml::fieldset( 'Foo' ), + 'Opening tag with legend' + ); + $this->assertEquals( + "
\nFoo\nBar\n
\n", + Xml::fieldset( 'Foo', 'Bar' ), + 'Entire element with legend' + ); + $this->assertEquals( + "
\nFoo\n", + Xml::fieldset( 'Foo', false ), + 'Opening tag with legend (false means no content and no closing tag)' + ); + $this->assertEquals( + "
\nFoo\n\n
\n", + Xml::fieldset( 'Foo', '' ), + 'Entire element with legend but no content (empty string generates a closing tag)' + ); + $this->assertEquals( + "
\nFoo\nBar\n
\n", + Xml::fieldset( 'Foo', 'Bar', [ 'class' => 'bar' ] ), + 'Opening tag with legend and attributes' + ); + $this->assertEquals( + "
\nFoo\n", + Xml::fieldset( 'Foo', false, [ 'class' => 'bar' ] ), + 'Entire element with legend and attributes' + ); + } }