From 9b8c34a9be831df96289b5230d59e513a366f24e Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 18 May 2021 11:41:26 +0200 Subject: [PATCH 1/2] Symfony form: use FQDN instead of custom constant. --- src/Bundle/ChillPersonBundle/Controller/PersonController.php | 3 +-- src/Bundle/ChillPersonBundle/Form/CreationPersonType.php | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index bfb32654e..70c5a0634 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -299,7 +299,6 @@ final class PersonController extends AbstractController } $form = $this->createForm( - //CreationPersonType::NAME, CreationPersonType::class, new Person(), array( @@ -326,7 +325,7 @@ final class PersonController extends AbstractController } $form = $this->createForm( - CreationPersonType::NAME, + CreationPersonType::class, $person, array( 'action' => $this->generateUrl('chill_person_review'), diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index ec3ddbf82..e3583071f 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -33,9 +33,10 @@ use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Form\Type\PersonAltNameType; -class CreationPersonType extends AbstractType +final class CreationPersonType extends AbstractType { - + // TODO: This is only used in test. + // TODO: See if this is still valid and update accordingly. const NAME = 'chill_personbundle_person_creation'; const FORM_NOT_REVIEWED = 'not_reviewed'; From a7fad0ca1bf8ab37bcab4c5dff73d7951046682e Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 18 May 2021 11:55:32 +0200 Subject: [PATCH 2/2] tests: Update relevant tests but it seems that it is currently broken. --- .../Controller/PersonControllerCreateTest.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php index c49c0ea97..d1381c241 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php @@ -25,6 +25,7 @@ namespace Chill\PersonBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\DomCrawler\Form; use Chill\MainBundle\Test\PrepareClientTrait; +use \Symfony\Component\BrowserKit\Client; /** * Test creation and deletion for persons @@ -32,7 +33,9 @@ use Chill\MainBundle\Test\PrepareClientTrait; class PersonControllerCreateTest extends WebTestCase { use PrepareClientTrait; - + + private Client $client; + const FIRSTNAME_INPUT = 'chill_personbundle_person_creation[firstName]'; const LASTNAME_INPUT = "chill_personbundle_person_creation[lastName]"; const GENDER_INPUT = "chill_personbundle_person_creation[gender]"; @@ -42,18 +45,20 @@ class PersonControllerCreateTest extends WebTestCase const LONG_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq."; - public function setUp() + public function setUp(): void { - $this->client = $this::getClientAuthenticated(); + $this->client = $this->getClientAuthenticated(); } /** * * @param Form $creationForm */ - private function fillAValidCreationForm(Form &$creationForm, - $firstname = 'God', $lastname = 'Jesus') - { + private function fillAValidCreationForm( + Form &$creationForm, + string $firstname = 'God', + string $lastname = 'Jesus' + ) { $creationForm->get(self::FIRSTNAME_INPUT)->setValue($firstname); $creationForm->get(self::LASTNAME_INPUT)->setValue($lastname); $creationForm->get(self::GENDER_INPUT)->select("man");