File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -980,6 +980,37 @@ public function seeAuthentication($remembered = false)
980980 $ this ->assertTrue ($ security ->isGranted ($ role ), 'There is no authenticated user ' );
981981 }
982982
983+ /**
984+ * Submit a form specifying the form name only once.
985+ *
986+ * Use this function instead of $I->submitForm() to avoid repeating the form name in the field selectors.
987+ * If you customized the names of the field selectors use $I->submitForm() for full control.
988+ *
989+ * ```php
990+ * <?php
991+ * $I->submitSymfonyForm('login_form', [
992+ * '[email]' => 'john_doe@gmail.com',
993+ * '[password]' => 'secretForest'
994+ * ]);
995+ * ```
996+ *
997+ * @param string $name
998+ * @param string[] $fields
999+ */
1000+ public function submitSymfonyForm ($ name , $ fields )
1001+ {
1002+ $ selector = sprintf ('form[name=%s] ' , $ name );
1003+
1004+ $ params = [];
1005+ foreach ($ fields as $ key => $ value ) {
1006+ $ fixedKey = sprintf ('%s%s ' , $ name , $ key );
1007+ $ params [$ fixedKey ] = $ value ;
1008+ }
1009+ $ button = sprintf ('%s_submit ' , $ name );
1010+
1011+ $ this ->submitForm ($ selector , $ params , $ button );
1012+ }
1013+
9831014 /**
9841015 * Check that the current user has a role
9851016 *
You can’t perform that action at this time.
0 commit comments