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

Commit

Permalink
Validator Messages Tests
Browse files Browse the repository at this point in the history
Add tests to validate if messages are correctly concatenating min value
  • Loading branch information
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/GreaterThanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,30 @@ 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 bef7015

Please sign in to comment.