Skip to content

How to update form integration tests in 2.8 #17088

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

Closed
pschultz opened this issue Dec 21, 2015 · 2 comments
Closed

How to update form integration tests in 2.8 #17088

pschultz opened this issue Dec 21, 2015 · 2 comments

Comments

@pschultz
Copy link
Contributor

During our update to 2.8 we noticed that the cookbook article on form tests is outdated.

It still says

$type = new TestedType();
$form = $this->factory->create($type);

however, passing type instances to FormFactoryInterface::create is deprecated in favor of FQCNs.

The simple example in the article is trivial to update, but we can't figure out how to do it for form types that have dependencies. Following the article back in the days, we have written tests that look something like this:

// setup collaborators

$type = new MyFormType($mock1, $mock2, $moreMocksHere);
$form = $this->factory->create($type);

// submit, assert, etc.

Is there any documentation available on how to update these tests for Symfony 2.8?

@Tobion
Copy link
Contributor

Tobion commented Dec 21, 2015

Create a form extension (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php#L34) that returns your form type with the mocked dependencies.

@wouterj
Copy link
Member

wouterj commented Dec 21, 2015

See symfony/symfony-docs#6053

The documentation will be updated very soon: symfony/symfony-docs#6058

@Tobion Tobion closed this as completed Dec 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants