r107999 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107998‎ | r107999 | r108000 >
Date:08:56, 4 January 2012
Author:santhosh
Status:ok
Tags:
Comment:
Address an edge case - input being null. Add test cases.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageMlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/languages/LanguageMlTest.php
@@ -30,5 +30,7 @@
3131 $this->assertEquals( '-98', $this->lang->formatNum( '-98' ) );
3232 $this->assertEquals( '-98', $this->lang->formatNum( -98 ) );
3333 $this->assertEquals( '-1,23,45,678', $this->lang->formatNum( -12345678 ) );
 34+ $this->assertEquals( '', $this->lang->formatNum( '' ) );
 35+ $this->assertEquals( '', $this->lang->formatNum( null ) );
3436 }
3537 }
Index: trunk/phase3/languages/Language.php
@@ -2729,6 +2729,9 @@
27302730 */
27312731 function commafy( $_ ) {
27322732 $digitGroupingPattern = $this->digitGroupingPattern();
 2733+ if ( $_ === null ) {
 2734+ return '';
 2735+ }
27332736
27342737 if ( !$digitGroupingPattern || $digitGroupingPattern === "###,###,###" ) {
27352738 // default grouping is at thousands, use the same for ###,###,### pattern too.

Status & tagging log