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

Commit

Permalink
Add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Jul 8, 2016
1 parent 79a7461 commit e3956c3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,35 @@ public function testSettingValidationGroupBindsOnlyThoseValuesToModel()
$this->assertObjectNotHasAttribute('foobar', $model);
}

public function testSettingValidationGroupWithoutCollectionBindsOnlyThoseValuesToModel()
{
$model = new stdClass;
$dataWithoutCollection = [
'foo' => 'abcde'
];
$this->populateForm();
$this->form->add([
'type' => 'Zend\Form\Element\Collection',
'name' => 'categories',
'options' => [
'count' => 0,
'target_element' => [
'type' => 'ZendTest\Form\TestAsset\CategoryFieldset'
]
]
]);
$this->form->setHydrator(new Hydrator\ObjectProperty());
$this->form->bind($model);
$this->form->setData($dataWithoutCollection);
$this->form->setValidationGroup(array('foo'));
$this->form->isValid();

$this->assertObjectHasAttribute('foo', $model);
$this->assertEquals('abcde', $model->foo);
$this->assertObjectNotHasAttribute('categories', $model);
$this->assertObjectNotHasAttribute('foobar', $model);
}

public function testCanBindModelsToArraySerializableObjects()
{
$model = new TestAsset\Model();
Expand Down

0 comments on commit e3956c3

Please sign in to comment.