Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#4562 from pauloelr/zen…
Browse files Browse the repository at this point in the history
…d_validator_greater_than_messgage_tests

Validator Messages Tests
  • Loading branch information
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/GreaterThanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,32 @@ public function testEqualsMessageVariables()
$this->assertAttributeEquals($validator->getOption('messageVariables'),
'messageVariables', $validator);
}

public function testCorrectInclusiveMessageReturn()
{
$valuesToValidate = array(0, 0.5, 5, 10);

foreach ($valuesToValidate as $value) {
$validator = new GreaterThan(10);
$validator->isValid($value);
$message = $validator->getMessages();

$this->assertArrayHaskey('notGreaterThan', $message);
$this->assertEquals($message['notGreaterThan'], "The input is not greater than '10'");
}
}

public function testCorrectNotInclusiveMessageReturn()
{
$valuesToValidate = array(0, 0.5, 5, 9);

foreach ($valuesToValidate as $value) {
$validator = new GreaterThan(array('min' => 10, 'inclusive' => true));
$validator->isValid($value);
$message = $validator->getMessages();

$this->assertArrayHaskey('notGreaterThanInclusive', $message);
$this->assertEquals($message['notGreaterThanInclusive'], "The input is not greater or equal than '10'");
}
}
}

0 comments on commit 5d4d576

Please sign in to comment.