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

Commit

Permalink
Merge pull request #5551. Fix #5549 in develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Feb 20, 2014
2 parents 70b6470 + 230b0a2 commit f85d27d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Form/Element/Number.php
Expand Up @@ -49,7 +49,7 @@ protected function getValidators()
));

$inclusive = true;
if (!empty($this->attributes['inclusive'])) {
if (isset($this->attributes['inclusive'])) {
$inclusive = $this->attributes['inclusive'];
}

Expand Down
33 changes: 33 additions & 0 deletions tests/ZendTest/Form/Element/NumberTest.php
Expand Up @@ -89,4 +89,37 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri
}
}
}

public function testFalseInclusiveValidatorBasedOnAttributes()
{
$element = new NumberElement();
$element->setAttributes(array(
'inclusive' => false,
'min' => 5,
));

$inputSpec = $element->getInputSpecification();
foreach($inputSpec['validators'] as $validator) {
if (get_class($validator) == 'Zend\Validator\GreaterThan') {
$this->assertFalse($validator->getInclusive());
break;
}
}
}

public function testDefaultInclusiveTrueatValidatorWhenInclusiveIsNotSetOnAttributes()
{
$element = new NumberElement();
$element->setAttributes(array(
'min' => 5,
));

$inputSpec = $element->getInputSpecification();
foreach($inputSpec['validators'] as $validator) {
if (get_class($validator) == 'Zend\Validator\GreaterThan') {
$this->assertTrue($validator->getInclusive());
break;
}
}
}
}

0 comments on commit f85d27d

Please sign in to comment.