Skip to content

Added submitSymfonyForm function #32

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

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions src/Codeception/Module/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,35 @@ public function seeAuthentication($remembered = false)
$this->assertTrue($security->isGranted($role), 'There is no authenticated user');
}

/**
* Submits the given Symfony Form on the page, with the given form values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from this description it is not clear when should I use submitSimfonyForm and submitForm
so a small description why you would need to use this method over submitForm is required

* If you customized the CSS selectors or field names use ->submitForm() instead.
*
* ```php
* <?php
* $I->submitSymfonyForm('login_form', [
* '[email]' => 'john_doe@gmail.com',
* '[password]' => 'secretForest'
* ]);
* ```
*
* @param string $name
* @param string[] $fields
*/
public function submitSymfonyForm($name, $fields)
{
$selector = sprintf('form[name=%s]', $name);

$params = [];
foreach ($fields as $key => $value) {
$fixedKey = sprintf('%s%s', $name, $key);
$params[$fixedKey] = $value;
}
$button = sprintf('%s_submit', $name);

$this->submitForm($selector, $params, $button);
}

/**
* Check that the current user has a role
*
Expand Down