From 77e0eb5895c2fecbbc45a4120d5e0a614716b10c Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 4 Jan 2019 08:45:22 +0100 Subject: [PATCH 01/11] OPENEUROPA-1500: Implement configuration form for webtools analytics. --- .../oe_webtools_analytics.links.menu.yml | 5 ++ .../oe_webtools_analytics.routing.yml | 7 ++ .../Form/WebtoolsAnalyticsSettingsForm.php | 71 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml create mode 100644 modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml create mode 100644 modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml new file mode 100644 index 00000000..be7267e7 --- /dev/null +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml @@ -0,0 +1,5 @@ +oe_webtools_analytics.settings: + title: Webtools Analytics + description: 'Configure Webtools Analytics.' + route_name: oe_webtools_analytics.settings + parent: system.admin_config_regional \ No newline at end of file diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml new file mode 100644 index 00000000..bb4e11e9 --- /dev/null +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml @@ -0,0 +1,7 @@ +oe_webtools_analytics.settings: + path: '/admin/config/regional/oe_webtools_analytics' + defaults: + _form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm' + _title: 'Webtools Analytics settings' + requirements: + _permission: 'administer site configuration' \ No newline at end of file diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php new file mode 100644 index 00000000..0652dd77 --- /dev/null +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -0,0 +1,71 @@ + 'textfield', + '#title' => $this->t('Site ID'), + '#default_value' => $this->config(static::CONFIGNAME)->get('siteID'), + '#description' => $this->t('The site unique identifier.'), + ]; + $form['sitePath'] = [ + '#type' => 'textfield', + '#title' => $this->t('Site path'), + '#default_value' => $this->config(static::CONFIGNAME)->get('sitePath'), + '#description' => $this->t('The domain + root path without protocol.'), + ]; + $form['instance'] = [ + '#type' => 'textfield', + '#title' => $this->t('Instance'), + '#default_value' => $this->config(static::CONFIGNAME)->get('instance'), + '#description' => $this->t('The test server instance. e.g. testing, ec.europa.eu or europa.eu.'), + ]; + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $this->config(static::CONFIGNAME) + ->set('siteID', $form_state->getValues()['siteID']) + ->set('sitePath', $form_state->getValues()['sitePath']) + ->set('instance', $form_state->getValues()['instance']) + ->save(); + parent::submitForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'oe_webtools_analytics_settings'; + } + + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return ['oe_webtools_analytics.settings']; + } + +} \ No newline at end of file From c19f244481dd238f6c4b4b8f14877064d6f8d02c Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 4 Jan 2019 09:16:37 +0100 Subject: [PATCH 02/11] OPENEUROPA-1500: Add BEHAT. --- .../oe_webtools_analytics.links.menu.yml | 2 +- .../oe_webtools_analytics.routing.yml | 2 +- .../Form/WebtoolsAnalyticsSettingsForm.php | 2 +- tests/features/analytics.feature | 21 +++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/features/analytics.feature diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml index be7267e7..d1c5ef8f 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml @@ -2,4 +2,4 @@ oe_webtools_analytics.settings: title: Webtools Analytics description: 'Configure Webtools Analytics.' route_name: oe_webtools_analytics.settings - parent: system.admin_config_regional \ No newline at end of file + parent: system.admin_config_regional diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml index bb4e11e9..a5a88db6 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml @@ -4,4 +4,4 @@ oe_webtools_analytics.settings: _form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm' _title: 'Webtools Analytics settings' requirements: - _permission: 'administer site configuration' \ No newline at end of file + _permission: 'administer site configuration' diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index 0652dd77..87d8406c 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -68,4 +68,4 @@ protected function getEditableConfigNames() { return ['oe_webtools_analytics.settings']; } -} \ No newline at end of file +} diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature new file mode 100644 index 00000000..eb5aa06c --- /dev/null +++ b/tests/features/analytics.feature @@ -0,0 +1,21 @@ +@api +Feature: Webtools Analytics + In order to provide analytics + As the site manager + I need to be able to configure the settings + And Webtools Analytics works as expected + + Background: + Given I am logged in as a user with the "administer site configuration" permission + + Scenario: Create Webtools Analytics settings + Given I am on "admin/config/regional/oe_webtools_analytics" + Then I should see "Webtools Analytics settings" + When I fill in "Site ID" with "INFO" + And I fill in "Site path" with "ec.europa.eu/info" + And I fill in "Instance" with "ec.europa.eu" + And I press "Save configuration" + Then I should see the message "The configuration options have been saved." + And the "Site ID" field should contain "INFO" + And the "Site path" field should contain "ec.europa.eu/info" + And the "Instance" field should contain "ec.europa.eu" From 480a33c6a3e19d12b84f4a3a92f19b6ee08e62b4 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 4 Jan 2019 10:59:30 +0100 Subject: [PATCH 03/11] OPENEUROPA-1500: Some improvements. --- .../schema/oe_webtools_analytics.schema.yml | 2 +- .../oe_webtools_analytics.links.menu.yml | 2 +- .../oe_webtools_analytics.routing.yml | 2 +- .../Form/WebtoolsAnalyticsSettingsForm.php | 30 +++++++++---------- tests/features/analytics.feature | 1 - 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/modules/oe_webtools_analytics/config/schema/oe_webtools_analytics.schema.yml b/modules/oe_webtools_analytics/config/schema/oe_webtools_analytics.schema.yml index 3f12ab52..ae976b12 100644 --- a/modules/oe_webtools_analytics/config/schema/oe_webtools_analytics.schema.yml +++ b/modules/oe_webtools_analytics/config/schema/oe_webtools_analytics.schema.yml @@ -13,4 +13,4 @@ oe_webtools_analytics.settings: instance: type: string label: 'Instance' - description: 'The test server instance. e.g. testing, ec.europa.eu or europa.eu.' + description: 'The server instance. e.g. testing, ec.europa.eu or europa.eu.' diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml index d1c5ef8f..7e08be02 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.links.menu.yml @@ -2,4 +2,4 @@ oe_webtools_analytics.settings: title: Webtools Analytics description: 'Configure Webtools Analytics.' route_name: oe_webtools_analytics.settings - parent: system.admin_config_regional + parent: system.admin_config_system diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml index a5a88db6..681925e3 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml @@ -1,5 +1,5 @@ oe_webtools_analytics.settings: - path: '/admin/config/regional/oe_webtools_analytics' + path: '/admin/config/system/oe_webtools_analytics' defaults: _form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm' _title: 'Webtools Analytics settings' diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index 87d8406c..f25ad58a 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -17,6 +17,20 @@ class WebtoolsAnalyticsSettingsForm extends ConfigFormBase { */ const CONFIGNAME = 'oe_webtools_analytics.settings'; + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'oe_webtools_analytics_settings'; + } + + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return ['oe_webtools_analytics.settings']; + } + /** * {@inheritdoc} */ @@ -37,7 +51,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'textfield', '#title' => $this->t('Instance'), '#default_value' => $this->config(static::CONFIGNAME)->get('instance'), - '#description' => $this->t('The test server instance. e.g. testing, ec.europa.eu or europa.eu.'), + '#description' => $this->t('The server instance. e.g. testing, ec.europa.eu or europa.eu.'), ]; return parent::buildForm($form, $form_state); } @@ -54,18 +68,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'oe_webtools_analytics_settings'; - } - - /** - * {@inheritdoc} - */ - protected function getEditableConfigNames() { - return ['oe_webtools_analytics.settings']; - } - } diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index eb5aa06c..a2f9847c 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -3,7 +3,6 @@ Feature: Webtools Analytics In order to provide analytics As the site manager I need to be able to configure the settings - And Webtools Analytics works as expected Background: Given I am logged in as a user with the "administer site configuration" permission From f7a70dac75e98169a47cb83f99a9c93f25865292 Mon Sep 17 00:00:00 2001 From: nagyad Date: Mon, 7 Jan 2019 09:43:50 +0100 Subject: [PATCH 04/11] OPENEUROPA-1500: Add validation for Site ID input field. --- .../oe_webtools_analytics.info.yml | 1 + .../src/Form/WebtoolsAnalyticsSettingsForm.php | 14 +++++++++++++- tests/features/analytics.feature | 9 +++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.info.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.info.yml index 75132819..1356d357 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.info.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.info.yml @@ -4,5 +4,6 @@ package: OpenEuropa Webtools type: module version: 1.0 core: 8.x +configure: oe_webtools_analytics.settings dependencies: - oe_webtools diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index f25ad58a..6bd6ac06 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'textfield', '#title' => $this->t('Site ID'), '#default_value' => $this->config(static::CONFIGNAME)->get('siteID'), - '#description' => $this->t('The site unique identifier.'), + '#description' => $this->t('The site unique numeric identifier.'), ]; $form['sitePath'] = [ '#type' => 'textfield', @@ -56,6 +56,18 @@ public function buildForm(array $form, FormStateInterface $form_state) { return parent::buildForm($form, $form_state); } + /** + * {@inheritdoc} + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + parent::validateForm($form, $form_state); + + $site_id = $form_state->getValue('siteID'); + if (!is_numeric($site_id)) { + $form_state->setErrorByName('siteID', $this->t('The value must be numeric.')); + } + } + /** * {@inheritdoc} */ diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index a2f9847c..783300ba 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -8,13 +8,18 @@ Feature: Webtools Analytics Given I am logged in as a user with the "administer site configuration" permission Scenario: Create Webtools Analytics settings - Given I am on "admin/config/regional/oe_webtools_analytics" + Given I am on "admin/config/system/oe_webtools_analytics" Then I should see "Webtools Analytics settings" When I fill in "Site ID" with "INFO" And I fill in "Site path" with "ec.europa.eu/info" And I fill in "Instance" with "ec.europa.eu" And I press "Save configuration" + Then I should see the message "The value must be numeric." + When I fill in "Site ID" with "123456" + And I fill in "Site path" with "ec.europa.eu/info" + And I fill in "Instance" with "ec.europa.eu" + And I press "Save configuration" Then I should see the message "The configuration options have been saved." - And the "Site ID" field should contain "INFO" + And the "Site ID" field should contain "123456" And the "Site path" field should contain "ec.europa.eu/info" And the "Instance" field should contain "ec.europa.eu" From 7fbf610c94aaf29ff9bbb94ebed6927101216fe2 Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 14:28:31 +0100 Subject: [PATCH 05/11] OPENEUROPA-1500: Add custom permission for webtools analytics config. --- .../oe_webtools_analytics.permissions.yml | 3 +++ .../oe_webtools_analytics/oe_webtools_analytics.routing.yml | 2 +- tests/features/analytics.feature | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml new file mode 100644 index 00000000..3be57b9f --- /dev/null +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml @@ -0,0 +1,3 @@ +administer webtools analytics: + title: 'Administer Webtools Analytics' + restrict access: false \ No newline at end of file diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml index 681925e3..8381e090 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml @@ -4,4 +4,4 @@ oe_webtools_analytics.settings: _form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm' _title: 'Webtools Analytics settings' requirements: - _permission: 'administer site configuration' + _permission: 'administer webtools analytics' diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index 783300ba..42d5f47c 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -10,11 +10,6 @@ Feature: Webtools Analytics Scenario: Create Webtools Analytics settings Given I am on "admin/config/system/oe_webtools_analytics" Then I should see "Webtools Analytics settings" - When I fill in "Site ID" with "INFO" - And I fill in "Site path" with "ec.europa.eu/info" - And I fill in "Instance" with "ec.europa.eu" - And I press "Save configuration" - Then I should see the message "The value must be numeric." When I fill in "Site ID" with "123456" And I fill in "Site path" with "ec.europa.eu/info" And I fill in "Instance" with "ec.europa.eu" From e5efea09002d5e4e6967046fdb27ba12c5b70f06 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 8 Jan 2019 14:30:32 +0100 Subject: [PATCH 06/11] OPENEUROPA-1500: Update field type from textfield to number and remove the custom validation hook. --- .../src/Form/WebtoolsAnalyticsSettingsForm.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index 6bd6ac06..02214d9e 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -36,7 +36,7 @@ protected function getEditableConfigNames() { */ public function buildForm(array $form, FormStateInterface $form_state) { $form['siteID'] = [ - '#type' => 'textfield', + '#type' => 'number', '#title' => $this->t('Site ID'), '#default_value' => $this->config(static::CONFIGNAME)->get('siteID'), '#description' => $this->t('The site unique numeric identifier.'), @@ -56,18 +56,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { return parent::buildForm($form, $form_state); } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - parent::validateForm($form, $form_state); - - $site_id = $form_state->getValue('siteID'); - if (!is_numeric($site_id)) { - $form_state->setErrorByName('siteID', $this->t('The value must be numeric.')); - } - } - /** * {@inheritdoc} */ From 64565e7c979db188c51c9aa842b4fbd033e15511 Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 15:24:56 +0100 Subject: [PATCH 07/11] OPENEUROPA-1500: Add review improvements. --- .../oe_webtools_analytics.permissions.yml | 2 +- .../src/Form/WebtoolsAnalyticsSettingsForm.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml index 3be57b9f..18eb4719 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml @@ -1,3 +1,3 @@ administer webtools analytics: title: 'Administer Webtools Analytics' - restrict access: false \ No newline at end of file + restrict access: false diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index 02214d9e..bd164bc0 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -24,13 +24,6 @@ public function getFormId() { return 'oe_webtools_analytics_settings'; } - /** - * {@inheritdoc} - */ - protected function getEditableConfigNames() { - return ['oe_webtools_analytics.settings']; - } - /** * {@inheritdoc} */ @@ -53,6 +46,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $this->config(static::CONFIGNAME)->get('instance'), '#description' => $this->t('The server instance. e.g. testing, ec.europa.eu or europa.eu.'), ]; + return parent::buildForm($form, $form_state); } @@ -68,4 +62,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return ['oe_webtools_analytics.settings']; + } + } From e615e06544e4f62bbc9642b4358befa691a42e91 Mon Sep 17 00:00:00 2001 From: nagyad Date: Wed, 9 Jan 2019 14:52:26 +0100 Subject: [PATCH 08/11] OPENEUROPA-1500: Backup analytics configs for behat and fix test. --- tests/Behat/WebtoolsConfigContext.php | 13 +++++++++++++ tests/features/analytics.feature | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/Behat/WebtoolsConfigContext.php b/tests/Behat/WebtoolsConfigContext.php index 46100283..1608a3a5 100644 --- a/tests/Behat/WebtoolsConfigContext.php +++ b/tests/Behat/WebtoolsConfigContext.php @@ -64,4 +64,17 @@ public function backupLacoConfigs() { } } + /** + * Backup configs that need to be reverted in AfterScenario by ConfigContext. + * + * @BeforeScenario @BackupAnalyticsConfigs + */ + public function backupAnalyticsConfigs() { + $name = 'oe_webtools_analytics.settings'; + $configs = $this->getDriver()->getCore()->configGet($name); + foreach ($configs as $key => $value) { + $this->configContext->setConfig($name, $key, $value); + } + } + } diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index 42d5f47c..16d62f1e 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -5,8 +5,9 @@ Feature: Webtools Analytics I need to be able to configure the settings Background: - Given I am logged in as a user with the "administer site configuration" permission + Given I am logged in as a user with the "administer webtools analytics" permission + @BackupAnalyticsConfigs Scenario: Create Webtools Analytics settings Given I am on "admin/config/system/oe_webtools_analytics" Then I should see "Webtools Analytics settings" From 114f7d9edaad021d785d9da6401abe03ab76057e Mon Sep 17 00:00:00 2001 From: nagyad Date: Thu, 10 Jan 2019 15:28:27 +0100 Subject: [PATCH 09/11] OPENEUROPA-1500: Simplify test. --- tests/features/analytics.feature | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index 16d62f1e..72fd63f5 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -4,12 +4,10 @@ Feature: Webtools Analytics As the site manager I need to be able to configure the settings - Background: - Given I am logged in as a user with the "administer webtools analytics" permission - @BackupAnalyticsConfigs Scenario: Create Webtools Analytics settings - Given I am on "admin/config/system/oe_webtools_analytics" + Given I am logged in as a user with the "administer webtools analytics" permission + And I am on "admin/config/system/oe_webtools_analytics" Then I should see "Webtools Analytics settings" When I fill in "Site ID" with "123456" And I fill in "Site path" with "ec.europa.eu/info" From 8a0d4699917226c662b1c05b7ceb1951d47e0b94 Mon Sep 17 00:00:00 2001 From: nagyad Date: Thu, 10 Jan 2019 15:36:43 +0100 Subject: [PATCH 10/11] OPENEUROPA-1500: Small improvement on submitForm. --- .../src/Form/WebtoolsAnalyticsSettingsForm.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index bd164bc0..719ad1ad 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -55,9 +55,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config(static::CONFIGNAME) - ->set('siteID', $form_state->getValues()['siteID']) - ->set('sitePath', $form_state->getValues()['sitePath']) - ->set('instance', $form_state->getValues()['instance']) + ->set('siteID', $form_state->getValue('siteID')) + ->set('sitePath', $form_state->getValue('sitePath')) + ->set('instance', $form_state->getValue('instance')) ->save(); parent::submitForm($form, $form_state); } From 04f742dcedc723dc5ca076db93044d6dd18c08de Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 11 Jan 2019 09:37:25 +0100 Subject: [PATCH 11/11] OPENEUROPA-1500: Name path for behat. --- behat.yml.dist | 3 +++ .../src/Form/WebtoolsAnalyticsSettingsForm.php | 10 +++++----- tests/features/analytics.feature | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 5616e184..1f45b73f 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -10,6 +10,9 @@ default: - Drupal\DrupalExtension\Context\MessageContext - Drupal\Tests\oe_webtools\Behat\WebtoolsAnalyticsMinkContext - Drupal\Tests\oe_webtools\Behat\WebtoolsConfigContext + - OpenEuropa\Behat\TransformationContext: + pages: + Webtools Analytics configuration: '/admin/config/system/oe_webtools_analytics' extensions: Behat\MinkExtension: goutte: ~ diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index 719ad1ad..b3737081 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -15,7 +15,7 @@ class WebtoolsAnalyticsSettingsForm extends ConfigFormBase { /** * Name of the config being edited. */ - const CONFIGNAME = 'oe_webtools_analytics.settings'; + const CONFIG_NAME = 'oe_webtools_analytics.settings'; /** * {@inheritdoc} @@ -31,19 +31,19 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['siteID'] = [ '#type' => 'number', '#title' => $this->t('Site ID'), - '#default_value' => $this->config(static::CONFIGNAME)->get('siteID'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('siteID'), '#description' => $this->t('The site unique numeric identifier.'), ]; $form['sitePath'] = [ '#type' => 'textfield', '#title' => $this->t('Site path'), - '#default_value' => $this->config(static::CONFIGNAME)->get('sitePath'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('sitePath'), '#description' => $this->t('The domain + root path without protocol.'), ]; $form['instance'] = [ '#type' => 'textfield', '#title' => $this->t('Instance'), - '#default_value' => $this->config(static::CONFIGNAME)->get('instance'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('instance'), '#description' => $this->t('The server instance. e.g. testing, ec.europa.eu or europa.eu.'), ]; @@ -54,7 +54,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $this->config(static::CONFIGNAME) + $this->config(static::CONFIG_NAME) ->set('siteID', $form_state->getValue('siteID')) ->set('sitePath', $form_state->getValue('sitePath')) ->set('instance', $form_state->getValue('instance')) diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index 72fd63f5..a2a32cc8 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -7,7 +7,7 @@ Feature: Webtools Analytics @BackupAnalyticsConfigs Scenario: Create Webtools Analytics settings Given I am logged in as a user with the "administer webtools analytics" permission - And I am on "admin/config/system/oe_webtools_analytics" + And I am on "the Webtools Analytics configuration page" Then I should see "Webtools Analytics settings" When I fill in "Site ID" with "123456" And I fill in "Site path" with "ec.europa.eu/info"