Permalink
Browse files

Created unit test for the change

  • Loading branch information...
1 parent 5555193 commit df521d315748696ef48471396b1e1d51e53f40dc igor committed Sep 20, 2012
Showing with 23 additions and 1 deletion.
  1. +1 −1 library/Zend/Form/Element/Select.php
  2. +22 −0 tests/ZendTest/Form/Element/SelectTest.php
@@ -86,7 +86,7 @@ public function setValueOptions(array $options)
$validator = $this->validator instanceof InArrayValidator ? $this->validator : $this->validator->getValidator();
$validator->setHaystack($this->getValueOptionsValues());
}
-
+
return $this;
}
@@ -151,6 +151,28 @@ public function testInArrayValidationOfOptions($valueTests, $options)
$this->assertTrue($inArrayValidator->isValid($valueToTest));
}
}
+
+ /**
+ * Testing that InArray Validator Haystack is Updated if the Options
+ * are added after the validator is attached
+ *
+ * @dataProvider selectOptionsDataProvider
+ */
+ public function testInArrayValidatorHaystakIsUpdated($valueTests, $options)
+ {
+ $element = new SelectElement('my-select');
+ $inputSpec = $element->getInputSpecification();
+
+ $explodeValidator = $inputSpec['validators'][0];
+ $this->assertInstanceOf('Zend\Validator\InArray', $explodeValidator);
+
+ $element->setAttributes(array(
+ 'options' => $options,
+ ));
+ $haystack=$explodeValidator->getHaystack();
+ $this->assertCount(count($options), $haystack);
+ }
+
public function testOptionsHasArrayOnConstruct()
{

0 comments on commit df521d3

Please sign in to comment.