File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ class UserFormType extends AbstractType
1111 public function buildForm (FormBuilderInterface $ builder , array $ options )
1212 {
1313 $ builder
14- ->add ('name ' , TextType::class)
14+ ->add ('name ' , TextType::class, [
15+ 'required ' => true ,
16+ ])
1517 ->add ('email ' , EmailType::class, [
1618 'rules ' => 'email ' ,
1719 ])
Original file line number Diff line number Diff line change @@ -32,7 +32,26 @@ public function testValidForm()
3232 $ this ->assertTrue ($ form ->isValid ());
3333 }
3434
35- public function testInvalidForm ()
35+ public function testMissingNameForm ()
36+ {
37+ /** @var UserFormType $form */
38+ $ form = FormFactory::create (UserFormType::class, [])
39+ ->add ('save ' , SubmitType::class, ['label ' => 'Save user ' ]);
40+
41+ $ request = $ this ->createPostRequest ([
42+ 'user_form ' => [
43+ 'email ' => 'barry@example.com ' ,
44+ 'save ' => true ,
45+ ]
46+ ]);
47+
48+ $ form ->handleRequest ($ request );
49+
50+ $ this ->assertTrue ($ form ->isSubmitted ());
51+ $ this ->assertFalse ($ form ->isValid ());
52+ }
53+
54+ public function testInvalidEmailForm ()
3655 {
3756 /** @var UserFormType $form */
3857 $ form = FormFactory::create (UserFormType::class, [])
You can’t perform that action at this time.
0 commit comments