Skip to content

[Form] Added test to show that delete_empty don't work for embedded forms without data_class #22014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,30 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
$this->assertEquals(array(new Author('s_first', 's_last')), $form->getData());
}

public function testResizedDownIfSubmittedWithCompoundEmptyDataDeleteEmptyAndNoDataClass()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'entry_type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType',
// If the field is not required, no new Author will be created if the
// form is completely empty
'entry_options' => array('data_class' => null),
'allow_add' => true,
'allow_delete' => true,
'delete_empty' => true,
));

$form->setData(array(array('firstName' => 'first', 'lastName' => 'last')));
$form->submit(array(
array('firstName' => 's_first', 'lastName' => 's_last'),
array('firstName' => '', 'lastName' => ''),
));

$this->assertTrue($form->has('0'));
$this->assertFalse($form->has('1'));
$this->assertEquals(array('s_first', 's_last'), $form[0]->getData());
$this->assertEquals(array(array('s_first', 's_last')), $form->getData());
}

public function testNotResizedIfSubmittedWithExtraData()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
Expand Down