From a4b92d6db0251d6c9d50c4aaed4840f6ea7925b0 Mon Sep 17 00:00:00 2001 From: Nikolay Shapovalov <46209-zniki.ru@users.noreply.drupalcode.org> Date: Sun, 7 Jan 2024 21:29:40 +0000 Subject: [PATCH] Issue #3410055 by Nikolay Shapovalov, dcam, Anjali Mehta, dww: Adopt GitlabCi --- .gitlab-ci.yml | 50 +++++++++++++++++++ phpstan.neon | 11 ++++ ...node.ief_test_nested1.test_ref_nested1.yml | 8 +-- ...node.ief_test_nested2.test_ref_nested2.yml | 8 +-- .../field.storage.node.test_ref_nested1.yml | 5 +- .../field.storage.node.test_ref_nested2.yml | 5 +- .../FunctionalJavascript/ElementWebTest.php | 4 +- .../FunctionalJavascript/SimpleWidgetTest.php | 16 +++--- 8 files changed, 79 insertions(+), 28 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 phpstan.neon diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..e1a8c112 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,50 @@ +################ +# DrupalCI GitLabCI template +# +# Gitlab-ci.yml to replicate DrupalCI testing for Contrib +# +# With thanks to: +# * The GitLab Acceleration Initiative participants +# * DrupalSpoons +################ + +################ +# Guidelines +# +# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained. +# +# However, you can modify this template if you have additional needs for your project. +################ + +################ +# Includes +# +# Additional configuration can be provided through includes. +# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include. +# +# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml +# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values +################ + +include: + ################ + # DrupalCI includes: + # As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically. + # View these include files at https://git.drupalcode.org/project/gitlab_templates/ + ################ + - project: $_GITLAB_TEMPLATES_REPO + ref: $_GITLAB_TEMPLATES_REF + file: + - '/includes/include.drupalci.main.yml' + - '/includes/include.drupalci.variables.yml' + - '/includes/include.drupalci.workflows.yml' + +################ +# Pipeline configuration variables +# +# These are the variables provided to the Run Pipeline form that a user may want to override. +# +# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml +################ +variables: + SKIP_PHPSTAN: 1 diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000..51f2077c --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,11 @@ +# Configuration file for PHPStan static code checking, see https://phpstan.org. +includes: + - phar://phpstan.phar/conf/bleedingEdge.neon + +parameters: + level: 1 + paths: + - . + ignoreErrors: + # new static() is a best practice in Drupal, so we cannot fix that. + - "#^Unsafe usage of new static#" diff --git a/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested1.test_ref_nested1.yml b/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested1.test_ref_nested1.yml index 167d9177..de303e65 100644 --- a/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested1.test_ref_nested1.yml +++ b/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested1.test_ref_nested1.yml @@ -4,9 +4,6 @@ dependencies: config: - field.storage.node.test_ref_nested1 - node.type.ief_test_nested1 - module: - - inline_entity_form_test - - entity_reference enforced: module: - inline_entity_form_test @@ -14,18 +11,17 @@ id: node.ief_test_nested1.test_ref_nested1 field_name: test_ref_nested1 entity_type: node bundle: ief_test_nested1 -label: Multiple nodes +label: 'Multiple nodes' description: 'Reference multiple nodes.' required: true translatable: false default_value: { } default_value_callback: '' settings: - handler: default:node + handler: 'default:node' handler_settings: target_bundles: ief_reference_type: ief_test_nested2 sort: field: _none -third_party_settings: { } field_type: entity_reference diff --git a/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested2.test_ref_nested2.yml b/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested2.test_ref_nested2.yml index 0b18216e..bce2f364 100644 --- a/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested2.test_ref_nested2.yml +++ b/tests/modules/inline_entity_form_test/config/install/field.field.node.ief_test_nested2.test_ref_nested2.yml @@ -4,9 +4,6 @@ dependencies: config: - field.storage.node.test_ref_nested2 - node.type.ief_test_nested2 - module: - - inline_entity_form_test - - entity_reference enforced: module: - inline_entity_form_test @@ -14,18 +11,17 @@ id: node.ief_test_nested2.test_ref_nested2 field_name: test_ref_nested2 entity_type: node bundle: ief_test_nested2 -label: Multiple nodes +label: 'Multiple nodes' description: 'Reference multiple nodes.' required: true translatable: false default_value: { } default_value_callback: '' settings: - handler: default:node + handler: 'default:node' handler_settings: target_bundles: ief_reference_type: ief_test_nested3 sort: field: _none -third_party_settings: { } field_type: entity_reference diff --git a/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested1.yml b/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested1.yml index 323cecc4..aee1d405 100644 --- a/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested1.yml +++ b/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested1.yml @@ -2,8 +2,6 @@ langcode: und status: true dependencies: module: - - inline_entity_form_test - - entity_reference - node enforced: module: @@ -14,9 +12,10 @@ entity_type: node type: entity_reference settings: target_type: node -module: entity_reference +module: core locked: false cardinality: -1 translatable: false indexes: { } persist_with_no_fields: false +custom_storage: false diff --git a/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested2.yml b/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested2.yml index 4aaf0aaf..8edc2522 100644 --- a/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested2.yml +++ b/tests/modules/inline_entity_form_test/config/install/field.storage.node.test_ref_nested2.yml @@ -2,8 +2,6 @@ langcode: und status: true dependencies: module: - - inline_entity_form_test - - entity_reference - node enforced: module: @@ -14,9 +12,10 @@ entity_type: node type: entity_reference settings: target_type: node -module: entity_reference +module: core locked: false cardinality: -1 translatable: false indexes: { } persist_with_no_fields: false +custom_storage: false diff --git a/tests/src/FunctionalJavascript/ElementWebTest.php b/tests/src/FunctionalJavascript/ElementWebTest.php index d1778462..b974118b 100644 --- a/tests/src/FunctionalJavascript/ElementWebTest.php +++ b/tests/src/FunctionalJavascript/ElementWebTest.php @@ -62,13 +62,13 @@ class ElementWebTest extends InlineEntityFormTestBase { $this->assertNoNodeByTitle($title); $assert_session->elementExists('xpath', $title_field_xpath)->setValue($title); - $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue(-1); + $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue('-1'); $page->pressButton('Save'); $assert_session->pageTextNotContains("Created Content $title"); $this->assertNoNodeByTitle($title); - $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue(11); + $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue('11'); $page->pressButton('Save'); $assert_session->pageTextContains("Created Content $title"); $this->assertNodeByTitle($title, 'ief_test_custom'); diff --git a/tests/src/FunctionalJavascript/SimpleWidgetTest.php b/tests/src/FunctionalJavascript/SimpleWidgetTest.php index 69d83975..9f61d723 100644 --- a/tests/src/FunctionalJavascript/SimpleWidgetTest.php +++ b/tests/src/FunctionalJavascript/SimpleWidgetTest.php @@ -76,7 +76,7 @@ class SimpleWidgetTest extends InlineEntityFormTestBase { $assert_session->buttonNotExists('Add another item'); $assert_session->elementExists('xpath', $title_field_xpath)->setValue('Host node'); $assert_session->elementExists('xpath', $first_nested_title_field_xpath)->setValue('Nested single node'); - $assert_session->elementExists('xpath', $first_positive_int_field_xpath)->setValue(42); + $assert_session->elementExists('xpath', $first_positive_int_field_xpath)->setValue('42'); $page->pressButton('Save'); $assert_session->pageTextContains('IEF simple single Host node has been created.'); $host_node = $this->getNodeByTitle('Host node'); @@ -86,9 +86,9 @@ class SimpleWidgetTest extends InlineEntityFormTestBase { $assert_session->buttonNotExists('Add another item'); $assert_session->elementExists('xpath', $title_field_xpath)->setValue('Host node 2'); $assert_session->elementExists('xpath', $first_nested_title_field_xpath)->setValue('Nested single node 2'); - $assert_session->elementExists('xpath', $first_positive_int_field_xpath)->setValue(42); + $assert_session->elementExists('xpath', $first_positive_int_field_xpath)->setValue('42'); $assert_session->elementExists('xpath', $second_nested_title_field_xpath)->setValue('Nested single node 3'); - $assert_session->elementExists('xpath', $second_positive_int_field_xpath)->setValue(42); + $assert_session->elementExists('xpath', $second_positive_int_field_xpath)->setValue('42'); $page->pressButton('Save'); $assert_session->pageTextContains('IEF simple single Host node 2 has been created.'); $host_node = $this->getNodeByTitle('Host node 2'); @@ -98,7 +98,7 @@ class SimpleWidgetTest extends InlineEntityFormTestBase { // and an 'Add another item' button should appear. $assert_session->elementExists('xpath', $title_field_xpath)->setValue('Host node 3'); $assert_session->elementExists('xpath', $first_nested_title_field_xpath)->setValue('Nested single node 4'); - $assert_session->elementExists('xpath', $first_positive_int_field_xpath)->setValue(42); + $assert_session->elementExists('xpath', $first_positive_int_field_xpath)->setValue('42'); $assert_session->elementNotExists('xpath', $second_positive_int_field_xpath); // Press the 'add another item' button and add a second item. @@ -107,7 +107,7 @@ class SimpleWidgetTest extends InlineEntityFormTestBase { // Assert an extra item isn't added at the same time. $assert_session->elementNotExists('xpath', $third_nested_title_field_xpath); $assert_session->elementExists('xpath', $second_nested_title_field_xpath)->setValue('Nested single node 5'); - $assert_session->elementExists('xpath', $second_positive_int_field_xpath)->setValue(42); + $assert_session->elementExists('xpath', $second_positive_int_field_xpath)->setValue('42'); // Press the 'add another item' button and add a third item. $assert_session->buttonExists('Add another item')->press(); @@ -115,7 +115,7 @@ class SimpleWidgetTest extends InlineEntityFormTestBase { // Assert an extra item isn't added at the same time. $assert_session->elementNotExists('xpath', $fourth_nested_title_field_xpath); $assert_session->elementExists('xpath', $third_nested_title_field_xpath)->setValue('Nested single node 6'); - $assert_session->elementExists('xpath', $third_positive_int_field_xpath)->setValue(42); + $assert_session->elementExists('xpath', $third_positive_int_field_xpath)->setValue('42'); $page->pressButton('Save'); $assert_session->pageTextContains('IEF simple single Host node 3 has been created.'); $host_node = $this->getNodeByTitle('Host node 3'); @@ -156,14 +156,14 @@ class SimpleWidgetTest extends InlineEntityFormTestBase { $child_title = 'Child node ' . $this->randomString(); $assert_session->elementExists('xpath', $nested_title_field_xpath)->setValue($child_title); - $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue(-1); + $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue('-1'); $page->pressButton('Save'); // Assert field validation fires on Inline Entity Form widget. $assert_session->pageTextNotContains('IEF simple single Host Validation Node has been created.'); // Assert that we're still on form due to to validation error. $this->assertSession()->addressEquals('node/add/ief_simple_single'); - $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue(1); + $assert_session->elementExists('xpath', $positive_int_field_xpath)->setValue('1'); $page->pressButton('Save'); // Assert title validation passes on Inline Entity Form widget. $assert_session->pageTextNotContains('Title field is required.'); -- GitLab