Permalink
Browse files

Added test

  • Loading branch information...
1 parent 45c1728 commit 69a76f5aa4e5b7fe367e5b4c532353144f55baad @davidwindell committed Aug 1, 2012
Showing with 36 additions and 0 deletions.
  1. +36 −0 tests/Zend/Form/FormTest.php
View
36 tests/Zend/Form/FormTest.php
@@ -892,6 +892,7 @@ public function testUnsetValuesNotBound()
$this->assertObjectNotHasAttribute('foo', $data);
$this->assertObjectHasAttribute('bar', $data);
}
+
public function testRemoveCollectionFromValidationGroupWhenZeroCountAndNoData()
{
$dataWithoutCollection = array(
@@ -917,4 +918,39 @@ public function testRemoveCollectionFromValidationGroupWhenZeroCountAndNoData()
$this->form->setData($dataWithoutCollection);
$this->assertTrue($this->form->isValid());
}
+
+ public function testApplyObjectInputFilterToBaseFieldsetAndApplyValidationGroup()
+ {
+ $fieldset = new Fieldset('foobar');
+ $fieldset->add(new Element('foo'));
+ $fieldset->setUseAsBaseFieldset(true);
+ $this->form->add($fieldset);
+ $this->form->setValidationGroup(array(
+ 'foobar'=> array(
+ 'foo',
+ )
+ ));
+
+ $inputFilterFactory = new InputFilterFactory();
+ $inputFilter = $inputFilterFactory->createInputFilter(array(
+ 'foo' => array(
+ 'name' => 'foo',
+ 'required' => true,
+ ),
+ ));
+ $model = new TestAsset\ValidatingModel();
+ $model->setInputFilter($inputFilter);
+ $this->form->bind($model);
+
+ $this->form->setData(array());
+ $this->assertFalse($this->form->isValid());
+
+ $validSet = array(
+ 'foobar' => array(
+ 'foo' => 'abcde',
+ )
+ );
+ $this->form->setData($validSet);
+ $this->assertTrue($this->form->isValid());
+ }
}

0 comments on commit 69a76f5

Please sign in to comment.