Skip to content

Instantly share code, notes, and snippets.

@shmaltorhbooks
Created March 21, 2017 11:00
Show Gist options
  • Save shmaltorhbooks/de88f4aa43f636409ba862e2389cefbe to your computer and use it in GitHub Desktop.
Save shmaltorhbooks/de88f4aa43f636409ba862e2389cefbe to your computer and use it in GitHub Desktop.
<?php
declare(strict_types = 1);
namespace Tests\AppBundle\Form;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Test\TypeTestCase as TestCase;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* @description Add 'constraints' option to FormsTests
*/
class FormTypeTypeTest extends TestCase
{
protected function getExtensions()
{
/** @var ValidatorInterface|\PHPUnit_Framework_MockObject_MockObject $validator */
$validator = $this->createMock(ValidatorInterface::class);
$validator
->method('validate')
->will($this->returnValue(new ConstraintViolationList()));
$validator
->method('getMetadataFor')
->will($this->returnValue(new ClassMetadata('Symfony\Component\Form\Form')));
return [
new ValidatorExtension($validator),
new CoreExtension()
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment