Index: trunk/phase3/includes/specials/SpecialJavaScriptTest.php |
— | — | @@ -58,8 +58,10 @@ |
59 | 59 | $summary = $this->wrapSummaryHtml( '<p class="error">' |
60 | 60 | . wfMsg( 'javascripttest-pagetext-unknownframework', $par ) |
61 | 61 | . '</p>' |
62 | | - . $this->getFrameworkListHtml() ); |
63 | | - $out->addHtml( $summary, 'unknownframework' ); |
| 62 | + . $this->getFrameworkListHtml(), |
| 63 | + 'unknownframework' |
| 64 | + ); |
| 65 | + $out->addHtml( $summary ); |
64 | 66 | } |
65 | 67 | } |
66 | 68 | |
— | — | @@ -84,10 +86,19 @@ |
85 | 87 | |
86 | 88 | /** |
87 | 89 | * Function to wrap the summary. |
| 90 | + * It must be given a valid state as a second parameter or an exception will |
| 91 | + * be thrown. |
88 | 92 | * @param $html String: The raw HTML. |
89 | 93 | * @param $state String: State, one of 'noframework', 'unknownframework' or 'frameworkfound' |
90 | 94 | */ |
91 | | - private function wrapSummaryHtml( $html = '', $state ) { |
| 95 | + private function wrapSummaryHtml( $html, $state ) { |
| 96 | + $validStates = array( 'noframework', 'unknownframework', 'frameworkfound' ); |
| 97 | + if( !in_array( $state, $validStates ) ) { |
| 98 | + throw new MWException( __METHOD__ |
| 99 | + . ' given an invalid state. Must be one of "' |
| 100 | + . join( '", "', $validStates) . '".' |
| 101 | + ); |
| 102 | + } |
92 | 103 | return "<div id=\"mw-javascripttest-summary\" class=\"mw-javascripttest-$state\">$html</div>"; |
93 | 104 | } |
94 | 105 | |