From dea217a670a09ea50f45e63e04a3fd38a3ac5ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Oct 2022 22:06:45 +0200 Subject: [PATCH] [Dev] Add unit test to PickPostalCodeType --- .../Tests/Form/Type/PickPostalCodeTypeTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickPostalCodeTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickPostalCodeTypeTest.php index 9c0174754..126130275 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickPostalCodeTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickPostalCodeTypeTest.php @@ -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);