Skip to content

Commit 3006020

Browse files
committed
add tests for previous commit to avoid regressions
1 parent 0baa2e9 commit 3006020

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,39 @@ public function testSubmitCastsToInteger()
3232
$this->assertSame(1, $form->getData());
3333
$this->assertSame('1', $form->getViewData());
3434
}
35+
36+
public function testSubmitNull()
37+
{
38+
$form = $this->factory->create('integer');
39+
40+
$form->submit(null);
41+
42+
$this->assertNull($form->getData());
43+
$this->assertSame('', $form->getViewData());
44+
}
45+
46+
public function testSubmitNullWithEmptyData()
47+
{
48+
$form = $this->factory->create('integer', null, array(
49+
'empty_data' => 1,
50+
));
51+
52+
$form->submit(null);
53+
54+
$this->assertSame(1, $form->getData());
55+
$this->assertSame('1', $form->getViewData());
56+
}
57+
58+
public function testSubmitNullWithEmptyDataWhenNested()
59+
{
60+
$form = $this->factory->create('form')
61+
->add('age', 'integer', array(
62+
'empty_data' => 1,
63+
));
64+
65+
$form->submit(null);
66+
67+
$this->assertSame(1, $form->get('age')->getData());
68+
$this->assertSame('1', $form->get('age')->getViewData());
69+
}
3570
}

0 commit comments

Comments
 (0)