Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Oct 18, 2014
1 parent 3e6936d commit dfd48e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/Zend/I18n/Validator/Float.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public function isValid($value)

//We have seperators, and they are flipped. i.e. 2.000,000 for en-US
if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) {
$this->error(self::NOT_FLOAT);
return false;
}

Expand Down Expand Up @@ -237,6 +238,7 @@ public function isValid($value)
return true;
}

$this->error(self::NOT_FLOAT);
return false;
}
}
22 changes: 22 additions & 0 deletions tests/ZendTest/I18n/Validator/FloatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,26 @@ public function testEqualsMessageTemplates()
$validator = $this->validator;
$this->assertAttributeEquals($validator->getOption('messageTemplates'), 'messageTemplates', $validator);
}

/**
* @group ZF2-6647
* @dataProvider notFloatProvider
*/
public function testNotFloat($value)
{
$this->assertFalse($this->validator->isValid($value));

$message = $this->validator->getMessages();
$this->assertContains('does not appear to be a float', $message['notFloat']);
}

public function notFloatProvider()
{
return array(
array(
'hello',
2.000,000
),
);
}
}

0 comments on commit dfd48e1

Please sign in to comment.