r92188 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92187‎ | r92188 | r92189 >
Date:20:24, 14 July 2011
Author:jeroendedauw
Status:deferred
Tags:lamecommitsummary 
Comment:
Modified paths:
  • /trunk/extensions/Validator/includes/criteria/CriterionInRange.php (modified) (history)
  • /trunk/extensions/Validator/test/ValidatorCriteriaTests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/test/ValidatorCriteriaTests.php
@@ -80,11 +80,13 @@
8181 array( false, '4.2', Parameter::TYPE_FLOAT, 42, 42 ),
8282 array( true, '4.2', Parameter::TYPE_FLOAT, 4.2, 4.2 ),
8383 array( true, '4.2', Parameter::TYPE_FLOAT, 0, 9 ),
 84+ array( true, '42', Parameter::TYPE_FLOAT, 0, 99 ),
 85+ array( false, '42', Parameter::TYPE_FLOAT, 0, 9 ),
8486 );
8587
8688 foreach ( $tests as $test ) {
8789 $c = new CriterionInRange( $test[3], $test[4] );
88 - $p = new Parameter( 'test' );
 90+ $p = new Parameter( 'test', $test[2] );
8991 $p->setUserValue( 'test', $test[1] );
9092 $this->assertEquals(
9193 $test[0],
@@ -93,5 +95,5 @@
9496 );
9597 }
9698 }
97 -
 99+
98100 }
Index: trunk/extensions/Validator/includes/criteria/CriterionInRange.php
@@ -54,7 +54,16 @@
5555 return false;
5656 }
5757
58 - $value = (float)$value;
 58+ switch( $parameter->getType() ) {
 59+ case Parameter::TYPE_INTEGER:
 60+ $value = (int)$value;
 61+ break;
 62+ case Parameter::TYPE_FLOAT:
 63+ $value = (float)$value;
 64+ break;
 65+ default:
 66+ return false;
 67+ }
5968
6069 return ( $this->upperBound === false || $value <= $this->upperBound )
6170 && ( $this->lowerBound === false || $value >= $this->lowerBound );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92184added testjeroendedauw19:59, 14 July 2011

Status & tagging log