-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
FormactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.
Description
Currently, the section "Adding custom extensions" in http://symfony.com/doc/current/cookbook/form/unit_testing.html#adding-custom-extensions is overly complicated. The same result as in the code on that page can be achieved with:
use Symfony\Component\Form\PreloadedExtension;
class TestedTypeTest extends TypeTestCase
{
protected function getExtensions()
{
$validator = $this->getMock('\Symfony\Component\Validator\Validator\ValidatorInterface');
$validator->method('validate')->will($this->returnValue(new ConstraintViolationList()));
$typeGuesser = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser')
->disableOriginalConstructor()
->getMock();
return array(
new PreloadedExtension(
// Form types
array(),
// Form type extensions
array(new FormTypeValidatorExtension($validator)),
// Type guesser
$typeGuesser
),
);
}
// ... your tests
}
Metadata
Metadata
Assignees
Labels
FormactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.