mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[Dev] Add unit test to PickPostalCodeType
This commit is contained in:
parent
9aae36556b
commit
dea217a670
@ -18,6 +18,7 @@ use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\PreloadedExtension;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
@ -31,19 +32,21 @@ final class PickPostalCodeTypeTest extends TypeTestCase
|
||||
|
||||
public function testSubmitValidData(): void
|
||||
{
|
||||
$form = $this->factory->create(PickPostalCodeType::class, null);
|
||||
$builder = $this->factory->createBuilder(FormType::class, ['postal_code' => null]);
|
||||
$builder->add('postal_code', PickPostalCodeType::class);
|
||||
$form = $builder->getForm();
|
||||
|
||||
$form->submit(['1']);
|
||||
$form->submit(['postal_code' => '1']);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
|
||||
$this->assertEquals(1, $form->getData()->getId());
|
||||
$this->assertEquals(1, $form['postal_code']->getData()->getId());
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
$postalCodeRepository = $this->prophesize(PostalCodeRepositoryInterface::class);
|
||||
$postalCodeRepository->find(Argument::type('string'))
|
||||
$postalCodeRepository->find(Argument::any())
|
||||
->will(static function ($args) {
|
||||
$postalCode = new PostalCode();
|
||||
$reflectionClass = new ReflectionClass($postalCode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user