Skip to content

Commit 0bccb16

Browse files
committed
[Form] Hardened test suite for empty data (following for 3.4)
1 parent 5901e57 commit 0bccb16

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,17 @@ public function testSubmitNull($expected = null, $norm = null, $view = null)
410410
'days' => '',
411411
));
412412
}
413+
414+
public function testSubmitNullUsesDefaultEmptyData($emptyData = array(), $expectedData = null)
415+
{
416+
$form = $this->factory->create(static::TESTED_TYPE, null, array(
417+
'empty_data' => $emptyData,
418+
));
419+
$form->submit(null);
420+
421+
// view transformer writes back empty strings in the view data
422+
$this->assertSame(array('years' => '', 'months' => '', 'days' => ''), $form->getViewData());
423+
$this->assertSame($expectedData, $form->getNormData());
424+
$this->assertSame($expectedData, $form->getData());
425+
}
413426
}

0 commit comments

Comments
 (0)