* @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;
}
);
}
+ /**
+ * @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