From a906d0ac898b1fabc08f9a4ef363186274edfa04 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Thu, 9 Jan 2025 15:08:11 +0100 Subject: [PATCH] [ORM] use xml mapping, resolves #501 (#503) * [ORM] use xml mapping, resolves #501 * [TEST] fix intl icu formatting --- .../doctrine/model/DoubleOptInSession.orm.xml | 28 +++++++++ .../doctrine/model/DoubleOptInSession.orm.yml | 46 --------------- config/doctrine/model/FormDefinition.orm.xml | 25 ++++++++ config/doctrine/model/FormDefinition.orm.yml | 53 ----------------- config/doctrine/model/OutputWorkflow.orm.xml | 31 ++++++++++ config/doctrine/model/OutputWorkflow.orm.yml | 43 -------------- .../model/OutputWorkflowChannel.orm.xml | 23 ++++++++ .../model/OutputWorkflowChannel.orm.yml | 36 ----------- src/FormBuilderBundle.php | 2 +- tests/Functional/Fields/AbstractFieldCest.php | 2 +- tests/Functional/Fields/DateTimeFieldCest.php | 58 ++++++------------ tests/Functional/Fields/TimeFieldCest.php | 59 ++++++------------- 12 files changed, 145 insertions(+), 261 deletions(-) create mode 100644 config/doctrine/model/DoubleOptInSession.orm.xml delete mode 100644 config/doctrine/model/DoubleOptInSession.orm.yml create mode 100644 config/doctrine/model/FormDefinition.orm.xml delete mode 100644 config/doctrine/model/FormDefinition.orm.yml create mode 100644 config/doctrine/model/OutputWorkflow.orm.xml delete mode 100644 config/doctrine/model/OutputWorkflow.orm.yml create mode 100644 config/doctrine/model/OutputWorkflowChannel.orm.xml delete mode 100644 config/doctrine/model/OutputWorkflowChannel.orm.yml diff --git a/config/doctrine/model/DoubleOptInSession.orm.xml b/config/doctrine/model/DoubleOptInSession.orm.xml new file mode 100644 index 00000000..102e535e --- /dev/null +++ b/config/doctrine/model/DoubleOptInSession.orm.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/doctrine/model/DoubleOptInSession.orm.yml b/config/doctrine/model/DoubleOptInSession.orm.yml deleted file mode 100644 index ab5aff9c..00000000 --- a/config/doctrine/model/DoubleOptInSession.orm.yml +++ /dev/null @@ -1,46 +0,0 @@ -FormBuilderBundle\Model\DoubleOptInSession: - type: entity - table: formbuilder_double_opt_in_session - indexes: - token_form: - columns: [ token, form_definition, applied ] - id: - token: - unique: true - column: token - type: uuid - generator: - strategy: CUSTOM - customIdGenerator: - class: Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator - fields: - email: - column: email - type: string - nullable: false - length: 190 - additionalData: - column: additional_data - type: array - nullable: true - dispatchLocation: - column: dispatch_location - type: text - nullable: true - applied: - column: applied - type: boolean - options: - default: 0 - creationDate: - column: creationDate - type: datetime - nullable: false - manyToOne: - formDefinition: - targetEntity: FormBuilderBundle\Model\FormDefinition - orphanRemoval: true - joinColumn: - name: form_definition - referencedColumnName: id - onDelete: CASCADE \ No newline at end of file diff --git a/config/doctrine/model/FormDefinition.orm.xml b/config/doctrine/model/FormDefinition.orm.xml new file mode 100644 index 00000000..387884d3 --- /dev/null +++ b/config/doctrine/model/FormDefinition.orm.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/doctrine/model/FormDefinition.orm.yml b/config/doctrine/model/FormDefinition.orm.yml deleted file mode 100644 index 9812401d..00000000 --- a/config/doctrine/model/FormDefinition.orm.yml +++ /dev/null @@ -1,53 +0,0 @@ -FormBuilderBundle\Model\FormDefinition: - type: entity - table: formbuilder_forms - fields: - id: - type: integer - column: id - id: true - generator: - strategy: AUTO - name: - column: '`name`' - nullable: true - type: string - unique: true - length: 190 - group: - column: '`group`' - nullable: true - type: string - length: 190 - creationDate: - column: creationDate - type: datetime - nullable: false - modificationDate: - column: modificationDate - type: datetime - nullable: false - createdBy: - column: createdBy - type: integer - modifiedBy: - column: modifiedBy - type: integer - configuration: - column: configuration - type: object - nullable: true - conditionalLogic: - column: conditionalLogic - type: object - nullable: true - fields: - column: fields - type: form_builder_fields - nullable: true - oneToMany: - outputWorkflows: - targetEntity: FormBuilderBundle\Model\OutputWorkflow - mappedBy: formDefinition - cascade: - - all \ No newline at end of file diff --git a/config/doctrine/model/OutputWorkflow.orm.xml b/config/doctrine/model/OutputWorkflow.orm.xml new file mode 100644 index 00000000..fb1cc614 --- /dev/null +++ b/config/doctrine/model/OutputWorkflow.orm.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/doctrine/model/OutputWorkflow.orm.yml b/config/doctrine/model/OutputWorkflow.orm.yml deleted file mode 100644 index 3cedb92a..00000000 --- a/config/doctrine/model/OutputWorkflow.orm.yml +++ /dev/null @@ -1,43 +0,0 @@ -FormBuilderBundle\Model\OutputWorkflow: - type: entity - table: formbuilder_output_workflow - fields: - id: - type: integer - column: id - id: true - generator: - strategy: AUTO - name: - column: '`name`' - nullable: true - type: string - length: 190 - funnelWorkflow: - column: funnel_workflow - nullable: false - type: boolean - successManagement: - column: success_management - nullable: true - type: object - manyToOne: - formDefinition: - targetEntity: FormBuilderBundle\Model\FormDefinition - orphanRemoval: true - inversedBy: outputWorkflows - joinColumn: - name: form_definition - referencedColumnName: id - oneToMany: - channels: - targetEntity: FormBuilderBundle\Model\OutputWorkflowChannel - orphanRemoval: true - mappedBy: outputWorkflow - orderBy: - id: ASC - cascade: - - all - uniqueConstraints: - name_form: - columns: [name, form_definition] \ No newline at end of file diff --git a/config/doctrine/model/OutputWorkflowChannel.orm.xml b/config/doctrine/model/OutputWorkflowChannel.orm.xml new file mode 100644 index 00000000..0df61746 --- /dev/null +++ b/config/doctrine/model/OutputWorkflowChannel.orm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/config/doctrine/model/OutputWorkflowChannel.orm.yml b/config/doctrine/model/OutputWorkflowChannel.orm.yml deleted file mode 100644 index b8845085..00000000 --- a/config/doctrine/model/OutputWorkflowChannel.orm.yml +++ /dev/null @@ -1,36 +0,0 @@ -FormBuilderBundle\Model\OutputWorkflowChannel: - type: entity - table: formbuilder_output_workflow_channel - fields: - id: - type: integer - column: id - id: true - generator: - strategy: AUTO - type: - column: type - type: string - length: 190 - name: - column: name - type: string - length: 190 - configuration: - column: configuration - nullable: true - type: object - funnelActions: - column: funnel_actions - nullable: true - type: object - manyToOne: - outputWorkflow: - targetEntity: FormBuilderBundle\Model\OutputWorkflow - inversedBy: channels - joinColumn: - name: output_workflow - referencedColumnName: id - uniqueConstraints: - ow_name: - columns: [ output_workflow, name ] \ No newline at end of file diff --git a/src/FormBuilderBundle.php b/src/FormBuilderBundle.php index d9c1f4e2..47daa27a 100644 --- a/src/FormBuilderBundle.php +++ b/src/FormBuilderBundle.php @@ -91,7 +91,7 @@ protected function getComposerPackageName(): string protected function configureDoctrineExtension(ContainerBuilder $container): void { $container->addCompilerPass( - DoctrineOrmMappingsPass::createYamlMappingDriver( + DoctrineOrmMappingsPass::createXmlMappingDriver( [$this->getNameSpacePath() => $this->getNamespaceName()], ['form_builder.persistence.doctrine.manager'], 'form_builder.persistence.doctrine.enabled' diff --git a/tests/Functional/Fields/AbstractFieldCest.php b/tests/Functional/Fields/AbstractFieldCest.php index 67f8ed95..d5a21173 100644 --- a/tests/Functional/Fields/AbstractFieldCest.php +++ b/tests/Functional/Fields/AbstractFieldCest.php @@ -31,7 +31,7 @@ protected function setupField(FunctionalTester $I, $options = [], $optional = [] $testFormBuilder = (new TestFormBuilder('dachcom_test'))->setUseAjax(false); if ($this->type === 'container') { - $subFields = isset($optional['subFields']) ? $optional['subFields'] : []; + $subFields = $optional['subFields'] ?? []; $testFormBuilder->addFormFieldContainer( $this->subType, $this->name, diff --git a/tests/Functional/Fields/DateTimeFieldCest.php b/tests/Functional/Fields/DateTimeFieldCest.php index 72c10dc5..8eff0822 100644 --- a/tests/Functional/Fields/DateTimeFieldCest.php +++ b/tests/Functional/Fields/DateTimeFieldCest.php @@ -7,31 +7,24 @@ class DateTimeFieldCest extends AbstractFieldCest { protected $type = 'date_time'; - protected $name = 'simple_date_time'; - protected $displayName = 'simple_date_time'; - /** - * @param FunctionalTester $I - */ - public function testDateTimeFieldOptionsWithLabel(FunctionalTester $I) + public function testDateTimeFieldOptionsWithLabel(FunctionalTester $I): void { $options = [ 'label' => 'Date Time Selection' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->see('Date Time Selection', 'label'); } /** * Help Text is not implemented! - * - * @param FunctionalTester $I */ - private function testDateTimeFieldOptionsWithHelpText(FunctionalTester $I) + private function testDateTimeFieldOptionsWithHelpText(FunctionalTester $I): void { $options = [ 'date_widget' => 'single_text', @@ -39,16 +32,13 @@ private function testDateTimeFieldOptionsWithHelpText(FunctionalTester $I) 'help_text' => 'This is a Helptext' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options, []); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options, []); $I->see('This is a Helptext', 'span'); } - /** - * @param FunctionalTester $I - */ - public function testDateTimeFieldOptionalsWithEmailLabel(FunctionalTester $I) + public function testDateTimeFieldOptionalsWithEmailLabel(FunctionalTester $I): void { $options = [ 'date_widget' => 'single_text', @@ -59,7 +49,7 @@ public function testDateTimeFieldOptionalsWithEmailLabel(FunctionalTester $I) 'email_label' => 'Date Time Email Selection' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options, $optionals); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options, $optionals); $I->fillField('input#formbuilder_1_simple_date_time_date', '1983-06-21'); $I->fillField('input#formbuilder_1_simple_date_time_time', '21:45'); @@ -69,17 +59,14 @@ public function testDateTimeFieldOptionalsWithEmailLabel(FunctionalTester $I) $I->seeInRenderedEmailBody($adminEmail, 'Date Time Email Selection'); } - /** - * @param FunctionalTester $I - */ - public function testDateTimeFieldWithSingleTextWidget(FunctionalTester $I) + public function testDateTimeFieldWithSingleTextWidget(FunctionalTester $I): void { $options = [ 'date_widget' => 'single_text', 'time_widget' => 'single_text', ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('input#formbuilder_1_simple_date_time_date', ['type' => 'date']); $I->seeElement('input#formbuilder_1_simple_date_time_time', ['type' => 'time']); @@ -88,20 +75,17 @@ public function testDateTimeFieldWithSingleTextWidget(FunctionalTester $I) $I->fillField('input#formbuilder_1_simple_date_time_time', '21:45'); $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => 'Jun 21, 1983, 9:45:00 PM']); + $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, 1983, 9:45:00%sPM', "\u{202F}")]); } - /** - * @param FunctionalTester $I - */ - public function testDateTimeFieldWithChoiceWidget(FunctionalTester $I) + public function testDateTimeFieldWithChoiceWidget(FunctionalTester $I): void { $options = [ 'date_widget' => 'choice', 'time_widget' => 'choice', ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('select#formbuilder_1_simple_date_time_date_month'); $I->seeElement('select#formbuilder_1_simple_date_time_date_day'); @@ -119,13 +103,10 @@ public function testDateTimeFieldWithChoiceWidget(FunctionalTester $I) $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, %s, 9:45:00 PM', date('Y'))]); + $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, %s, 9:45:00%sPM', date('Y'), "\u{202F}")]); } - /** - * @param FunctionalTester $I - */ - public function testDateTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I) + public function testDateTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I): void { $options = [ 'date_widget' => 'choice', @@ -133,7 +114,7 @@ public function testDateTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I) 'with_seconds' => true ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('select#formbuilder_1_simple_date_time_date_month'); $I->seeElement('select#formbuilder_1_simple_date_time_date_day'); @@ -153,20 +134,17 @@ public function testDateTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I) $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, %s, 9:45:12 PM', date('Y'))]); + $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, %s, 9:45:12%sPM', date('Y'), "\u{202F}")]); } - /** - * @param FunctionalTester $I - */ - public function testDateTimeFieldWithTextWidget(FunctionalTester $I) + public function testDateTimeFieldWithTextWidget(FunctionalTester $I): void { $options = [ 'date_widget' => 'text', 'time_widget' => 'text', ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('input#formbuilder_1_simple_date_time_date_month'); $I->seeElement('input#formbuilder_1_simple_date_time_date_day'); @@ -184,6 +162,6 @@ public function testDateTimeFieldWithTextWidget(FunctionalTester $I) $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, %s, 9:45:00 PM', date('Y'))]); + $I->seePropertiesInEmail($adminEmail, ['simple_date_time' => sprintf('Jun 21, %s, 9:45:00%sPM', date('Y'), "\u{202F}")]); } } diff --git a/tests/Functional/Fields/TimeFieldCest.php b/tests/Functional/Fields/TimeFieldCest.php index a84fad66..673e245f 100644 --- a/tests/Functional/Fields/TimeFieldCest.php +++ b/tests/Functional/Fields/TimeFieldCest.php @@ -7,46 +7,35 @@ class TimeFieldCest extends AbstractFieldCest { protected $type = 'time'; - protected $name = 'simple_time'; - protected $displayName = 'simple_time'; - /** - * @param FunctionalTester $I - */ - public function testTimeFieldOptionsWithLabel(FunctionalTester $I) + public function testTimeFieldOptionsWithLabel(FunctionalTester $I): void { $options = [ 'widget' => 'single_text', 'label' => 'Time Selection' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->see('Time Selection', 'label'); } - /** - * @param FunctionalTester $I - */ - public function testTimeFieldOptionsWithHelpText(FunctionalTester $I) + public function testTimeFieldOptionsWithHelpText(FunctionalTester $I): void { $options = [ 'widget' => 'single_text', 'help_text' => 'This is a Helptext' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options, []); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options, []); $I->see('This is a Helptext', 'span'); } - /** - * @param FunctionalTester $I - */ - public function testTimeFieldOptionalsWithEmailLabel(FunctionalTester $I) + public function testTimeFieldOptionalsWithEmailLabel(FunctionalTester $I): void { $options = [ 'widget' => 'single_text' @@ -56,7 +45,7 @@ public function testTimeFieldOptionalsWithEmailLabel(FunctionalTester $I) 'email_label' => 'Time Email Selection' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options, $optionals); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options, $optionals); $I->fillField($testFormBuilder->getFormFieldSelector(1, 'simple_time'), '21:45'); $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); @@ -64,35 +53,29 @@ public function testTimeFieldOptionalsWithEmailLabel(FunctionalTester $I) $I->seeInRenderedEmailBody($adminEmail, 'Time Email Selection'); } - /** - * @param FunctionalTester $I - */ - public function testTimeFieldWithSingleTextWidget(FunctionalTester $I) + public function testTimeFieldWithSingleTextWidget(FunctionalTester $I): void { $options = [ 'widget' => 'single_text' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('input#formbuilder_1_simple_time', ['type' => 'time']); $I->fillField($testFormBuilder->getFormFieldSelector(1, 'simple_time'), '21:45'); $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_time' => '9:45:00 PM']); + $I->seePropertiesInEmail($adminEmail, ['simple_time' => sprintf('9:45:00%sPM', "\u{202F}")]); } - /** - * @param FunctionalTester $I - */ - public function testTimeFieldWithChoiceWidget(FunctionalTester $I) + public function testTimeFieldWithChoiceWidget(FunctionalTester $I): void { $options = [ 'widget' => 'choice' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('select#formbuilder_1_simple_time_hour'); $I->seeElement('select#formbuilder_1_simple_time_minute'); @@ -101,20 +84,17 @@ public function testTimeFieldWithChoiceWidget(FunctionalTester $I) $I->selectOption('select#formbuilder_1_simple_time_minute', '45'); $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_time' => '9:45:00 PM']); + $I->seePropertiesInEmail($adminEmail, ['simple_time' => sprintf('9:45:00%sPM', "\u{202F}")]); } - /** - * @param FunctionalTester $I - */ - public function testTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I) + public function testTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I): void { $options = [ 'widget' => 'choice', 'with_seconds' => true ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('select#formbuilder_1_simple_time_hour'); $I->seeElement('select#formbuilder_1_simple_time_minute'); @@ -125,19 +105,16 @@ public function testTimeFieldWithSecondsAndChoiceWidget(FunctionalTester $I) $I->selectOption('select#formbuilder_1_simple_time_second', '12'); $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_time' => '9:45:12 PM']); + $I->seePropertiesInEmail($adminEmail, ['simple_time' => sprintf('9:45:12%sPM', "\u{202F}")]); } - /** - * @param FunctionalTester $I - */ - public function testTimeFieldWithTextWidget(FunctionalTester $I) + public function testTimeFieldWithTextWidget(FunctionalTester $I): void { $options = [ 'widget' => 'text' ]; - list($adminEmail, $testFormBuilder, $form) = $this->setupField($I, $options); + [$adminEmail, $testFormBuilder, $form] = $this->setupField($I, $options); $I->seeElement('input#formbuilder_1_simple_time_hour'); $I->seeElement('input#formbuilder_1_simple_time_minute'); @@ -146,6 +123,6 @@ public function testTimeFieldWithTextWidget(FunctionalTester $I) $I->fillField('input#formbuilder_1_simple_time_minute', '45'); $I->click($testFormBuilder->getFormFieldSelector(1, 'submit')); - $I->seePropertiesInEmail($adminEmail, ['simple_time' => '9:45:00 PM']); + $I->seePropertiesInEmail($adminEmail, ['simple_time' => sprintf('9:45:00%sPM', "\u{202F}")]); } }