r108007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108006‎ | r108007 | r108008 >
Date:10:31, 4 January 2012
Author:hashar
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/specials/SpecialJavaScriptTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialJavaScriptTest.php
@@ -58,8 +58,10 @@
5959 $summary = $this->wrapSummaryHtml( '<p class="error">'
6060 . wfMsg( 'javascripttest-pagetext-unknownframework', $par )
6161 . '</p>'
62 - . $this->getFrameworkListHtml() );
63 - $out->addHtml( $summary, 'unknownframework' );
 62+ . $this->getFrameworkListHtml(),
 63+ 'unknownframework'
 64+ );
 65+ $out->addHtml( $summary );
6466 }
6567 }
6668
@@ -84,10 +86,19 @@
8587
8688 /**
8789 * Function to wrap the summary.
 90+ * It must be given a valid state as a second parameter or an exception will
 91+ * be thrown.
8892 * @param $html String: The raw HTML.
8993 * @param $state String: State, one of 'noframework', 'unknownframework' or 'frameworkfound'
9094 */
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+ }
92103 return "<div id=\"mw-javascripttest-summary\" class=\"mw-javascripttest-$state\">$html</div>";
93104 }
94105

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107919merge JSTesting branch into trunk...hashar18:33, 3 January 2012

Status & tagging log