Skip to content

Fix adding custom extensions for unit testing #6463

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

Conversation

jacek-foremski
Copy link

Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets -

The previous version was generating the following error when running tests:

Error: Call to a member function addConstraint() on null

/vagrant/blog/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php:39
/vagrant/blog/tests/AppBundle/Form/Type/UserCreateTypeTest.php:87
/vagrant/blog/vendor/symfony/symfony/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php:30
/vagrant/blog/vendor/symfony/symfony/src/Symfony/Component/Form/Test/TypeTestCase.php:31
/vagrant/blog/tests/AppBundle/Form/Type/UserCreateTypeTest.php:93

The changes for vesion 2.8+ should be a little different due to the refactoring that took place, but I would be happy to fix it once this gets merged.

@xabbuh
Copy link
Member

xabbuh commented Apr 19, 2016

I am not sure if it wasn't better to properly set up the validator extension here instead of mocking things away.

@xabbuh
Copy link
Member

xabbuh commented May 21, 2016

What do others think about this?

->getMock();
$validator
->method('getMetadataFor')
->will($this->returnValue($metadata));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could actually be ->willReturn($metadata);

@xabbuh
Copy link
Member

xabbuh commented Jun 5, 2017

Sorry @natanael89 for not merging your PR earlier. Unfortunately, we merged #7941 in the meantime so there's no need for this PR anymore. I hope to see you soon again with some other changes though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants