jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391626 )

Change subject: Add unit tests for Html helper methods and change messageBox 
visibility
......................................................................


Add unit tests for Html helper methods and change messageBox visibility

* Messagebox is now private to Html class to discourage unconventional
  usages
* Tests are added for all three helper methods added in
  4e7021a2318

Bug: T166915
Change-Id: I1c3e4131b2439c0f4fb94ad4e616a909b52d6b78
---
M includes/Html.php
M tests/phpunit/includes/HtmlTest.php
2 files changed, 42 insertions(+), 1 deletion(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Html.php b/includes/Html.php
index 524fdcd..dfd80a8 100644
--- a/includes/Html.php
+++ b/includes/Html.php
@@ -683,7 +683,7 @@
         * @param string $heading (optional)
         * @return string of HTML representing a box.
         */
-       public static function messageBox( $html, $className, $heading = '' ) {
+       private static function messageBox( $html, $className, $heading = '' ) {
                if ( $heading ) {
                        $html = self::element( 'h2', [], $heading ) . $html;
                }
diff --git a/tests/phpunit/includes/HtmlTest.php 
b/tests/phpunit/includes/HtmlTest.php
index f3d4916..e867f5e 100644
--- a/tests/phpunit/includes/HtmlTest.php
+++ b/tests/phpunit/includes/HtmlTest.php
@@ -448,6 +448,47 @@
        }
 
        /**
+        * @covers Html::warningBox
+        * @covers Html::messageBox
+        */
+       public function testWarningBox() {
+               $this->assertEquals(
+                       Html::warningBox( 'warn' ),
+                       '<div class="warningbox">warn</div>'
+               );
+       }
+
+       /**
+        * @covers Html::errorBox
+        * @covers Html::messageBox
+        */
+       public function testErrorBox() {
+               $this->assertEquals(
+                       Html::errorBox( 'err' ),
+                       '<div class="errorbox">err</div>'
+               );
+               $this->assertEquals(
+                       Html::errorBox( 'err', 'heading' ),
+                       '<div class="errorbox"><h2>heading</h2>err</div>'
+               );
+       }
+
+       /**
+        * @covers Html::successBox
+        * @covers Html::messageBox
+        */
+       public function testSuccessBox() {
+               $this->assertEquals(
+                       Html::successBox( 'great' ),
+                       '<div class="successbox">great</div>'
+               );
+               $this->assertEquals(
+                       Html::successBox( '<script>beware no 
escaping!</script>' ),
+                       '<div class="successbox"><script>beware no 
escaping!</script></div>'
+               );
+       }
+
+       /**
         * List of input element types values introduced by HTML5
         * Full list at https://www.w3.org/TR/html-markup/input.html
         */

-- 
To view, visit https://gerrit.wikimedia.org/r/391626
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1c3e4131b2439c0f4fb94ad4e616a909b52d6b78
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to