Support a heading of '0' in Html::messageBox()
authorKunal Mehta <legoktm@member.fsf.org>
Mon, 20 Aug 2018 04:46:21 +0000 (21:46 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Mon, 20 Aug 2018 04:46:21 +0000 (21:46 -0700)
Change-Id: I181cb6f92ab1b10d87b1213a043a5f291149d094

includes/Html.php
tests/phpunit/includes/HtmlTest.php

index 32375c1..dba4c67 100644 (file)
@@ -704,7 +704,7 @@ class Html {
         * @return string of HTML representing a box.
         */
        private static function messageBox( $html, $className, $heading = '' ) {
-               if ( $heading ) {
+               if ( $heading !== '' ) {
                        $html = self::element( 'h2', [], $heading ) . $html;
                }
                return self::rawElement( 'div', [ 'class' => $className ], $html );
index dc32a6f..070a029 100644 (file)
@@ -476,6 +476,10 @@ class HtmlTest extends MediaWikiTestCase {
                        Html::errorBox( 'err', 'heading' ),
                        '<div class="errorbox"><h2>heading</h2>err</div>'
                );
+               $this->assertEquals(
+                       Html::errorBox( 'err', '0' ),
+                       '<div class="errorbox"><h2>0</h2>err</div>'
+               );
        }
 
        /**