From 35b2dbcc43b0a7fe02a5d240db3e57f82ca0a461 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Wed, 4 Jan 2012 10:31:02 +0000 Subject: [PATCH] JSTesting: make sure wrapSummaryHtml is given a valid state * wrapSummaryHTML() now really need one of three states or an exception is thrown. * Moved a parameter incorrectly passed to addHtml() up to the previous wrapSummaryHtml() code. Per CR on r107919 --- includes/specials/SpecialJavaScriptTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/specials/SpecialJavaScriptTest.php b/includes/specials/SpecialJavaScriptTest.php index d19eb8e698..c9719497e2 100644 --- a/includes/specials/SpecialJavaScriptTest.php +++ b/includes/specials/SpecialJavaScriptTest.php @@ -58,8 +58,10 @@ class SpecialJavaScriptTest extends SpecialPage { $summary = $this->wrapSummaryHtml( '

' . wfMsg( 'javascripttest-pagetext-unknownframework', $par ) . '

' - . $this->getFrameworkListHtml() ); - $out->addHtml( $summary, 'unknownframework' ); + . $this->getFrameworkListHtml(), + 'unknownframework' + ); + $out->addHtml( $summary ); } } @@ -84,10 +86,19 @@ class SpecialJavaScriptTest extends SpecialPage { /** * Function to wrap the summary. + * It must be given a valid state as a second parameter or an exception will + * be thrown. * @param $html String: The raw HTML. * @param $state String: State, one of 'noframework', 'unknownframework' or 'frameworkfound' */ - private function wrapSummaryHtml( $html = '', $state ) { + private function wrapSummaryHtml( $html, $state ) { + $validStates = array( 'noframework', 'unknownframework', 'frameworkfound' ); + if( !in_array( $state, $validStates ) ) { + throw new MWException( __METHOD__ + . ' given an invalid state. Must be one of "' + . join( '", "', $validStates) . '".' + ); + } return "
$html
"; } -- 2.20.1