From 507fb24620d3f240d54e030fe3cbd016af64b5f6 Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 21:10:48 +0200 Subject: [PATCH 01/11] Test D11 --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7906c0..d528533 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,15 +6,17 @@ jobs: strategy: fail-fast: false matrix: - php_version: ["7.4", "8.0", "8.1", "8.2"] - drupal_version: ["9", "10"] - exclude: + include: - php_version: "7.4" - drupal_version: "10" - - php_version: "8.0" + drupal_version: "9" + - php_version: "8.1" drupal_version: "10" - php_version: "8.2" - drupal_version: "9" + drupal_version: "10" + - php_version: "8.3" + drupal_version: "10" + - php_version: "8.3" + drupal_version: "11" env: PHP_VERSION: ${{ matrix.php_version }} DRUPAL_VERSION: ${{ matrix.drupal_version }} From 1d2bf22588ff1137470776e24ca862fb2a255b0d Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 21:11:47 +0200 Subject: [PATCH 02/11] Fix call to user_role_names() --- src/Drupal/Driver/Cores/Drupal8.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Drupal/Driver/Cores/Drupal8.php b/src/Drupal/Driver/Cores/Drupal8.php index ddbdf18..4b14898 100644 --- a/src/Drupal/Driver/Cores/Drupal8.php +++ b/src/Drupal/Driver/Cores/Drupal8.php @@ -262,18 +262,19 @@ public function userDelete(\stdClass $user) { */ public function userAddRole(\stdClass $user, $role_name) { // Allow both machine and human role names. - $roles = user_role_names(); - $id = array_search($role_name, $roles); - if (FALSE !== $id) { - $role_name = $id; - } - - if (!$role = Role::load($role_name)) { + $query = \Drupal::entityQuery('user_role'); + $conditions = $query->orConditionGroup() + ->condition('id', $role_name) + ->condition('label', $role_name); + $rids = $query + ->condition($conditions) + ->execute(); + if (!$rids) { throw new \RuntimeException(sprintf('No role "%s" exists.', $role_name)); } $account = User::load($user->uid); - $account->addRole($role->id()); + $account->addRole(reset($rids)); $account->save(); } From dcb028bfafa47bb49a4ea6e6103ee8696672126a Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 21:24:46 +0200 Subject: [PATCH 03/11] debugging CI --- .github/workflows/ci.yml | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d528533..032cb2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: - php_version: "7.4" drupal_version: "9" - php_version: "8.1" - drupal_version: "10" + drupal_version: "10.3" - php_version: "8.2" drupal_version: "10" - php_version: "8.3" diff --git a/composer.json b/composer.json index ed01b28..7162bc5 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,8 @@ "phpspec/phpspec": "~2.0 || ~4.0 || ~6.1 || dev-main", "phpunit/phpunit": "~6.0 || ~7.0 || ^9", "mockery/mockery": "^1.5", - "drupal/core-composer-scaffold": "^8.4 || ^9 || ^10@beta", - "drupal/core-recommended": "^8.4 || ^9 || ^10@beta", + "drupal/core-composer-scaffold": "^8.4 || ^9 || ^10 || ^11", + "drupal/core-recommended": "^8.4 || ^9 || ^10 || ^11", "drupal/mailsystem": "^4.4", "drush-ops/behat-drush-endpoint": "*", "php-parallel-lint/php-parallel-lint": "^1.0", From b9cbe7468e4572db3e2fd5f0990ee0da63f006f9 Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 21:30:33 +0200 Subject: [PATCH 04/11] No matching phpspec version for PHP 8.1? --- .github/workflows/ci.yml | 2 -- composer.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 032cb2f..f7cd8de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,6 @@ jobs: include: - php_version: "7.4" drupal_version: "9" - - php_version: "8.1" - drupal_version: "10.3" - php_version: "8.2" drupal_version: "10" - php_version: "8.3" diff --git a/composer.json b/composer.json index 7162bc5..f79808b 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "mockery/mockery": "^1.5", "drupal/core-composer-scaffold": "^8.4 || ^9 || ^10 || ^11", "drupal/core-recommended": "^8.4 || ^9 || ^10 || ^11", - "drupal/mailsystem": "^4.4", + "drupal/mailsystem": "^4.4 || 4.x-dev", "drush-ops/behat-drush-endpoint": "*", "php-parallel-lint/php-parallel-lint": "^1.0", "dms/phpunit-arraysubset-asserts": "^0.4.0", From a5926ea6aa91b5c54f524e8c1684f45e5d85d833 Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 21:32:56 +0200 Subject: [PATCH 05/11] more CI debugging --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7cd8de..8476e77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: composer self-update run: docker-compose exec -T php composer self-update - name: composer require - run: docker-compose exec -u ${DOCKER_USER_ID} -T php composer require --no-interaction --dev --no-update drupal/core:^${DRUPAL_VERSION} + run: docker-compose exec -u ${DOCKER_USER_ID} -T php composer require --no-interaction --dev --no-update drupal/core:^${DRUPAL_VERSION} drupal/core-recommended:^${DRUPAL_VERSION} - name: composer install run: docker-compose exec -T php composer install - name: composer test From c788a759cbe42dd20a5dc4e5fff94c48e9f5e570 Mon Sep 17 00:00:00 2001 From: DDEV User Date: Mon, 29 Jul 2024 19:38:22 +0000 Subject: [PATCH 06/11] Remove drupal-check --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index f79808b..22b88e3 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "drush-ops/behat-drush-endpoint": "*", "php-parallel-lint/php-parallel-lint": "^1.0", "dms/phpunit-arraysubset-asserts": "^0.4.0", - "mglaman/drupal-check": "^1", "palantirnet/drupal-rector": "^0.13", "symfony/phpunit-bridge": "^6.1" }, @@ -41,7 +40,6 @@ "phpunit": "XDEBUG_MODE=coverage phpunit --coverage-text", "phpspec": "XDEBUG_MODE=off phpspec run -f pretty --no-interaction", "phpcs": "XDEBUG_MODE=off phpcs --standard=./phpcs-ruleset.xml .", - "drupal-check": "XDEBUG_MODE=off drupal-check --drupal-root=drupal ./src/Drupal/Driver/Cores/Drupal8.php ./src/Drupal/Driver/Fields/Drupal8", "rector": [ "cp ./vendor/palantirnet/drupal-rector/rector.php drupal/.", "XDEBUG_MODE=off cd drupal && ../vendor/bin/rector process ../src/Drupal/Driver/Cores/Drupal8.php --dry-run", @@ -53,7 +51,6 @@ "@phpunit", "@phpspec", "@phpcs", - "@drupal-check", "@rector" ] }, From 34598388389e41a339491ee4c92acf5e59fd2a5c Mon Sep 17 00:00:00 2001 From: DDEV User Date: Mon, 29 Jul 2024 19:45:08 +0000 Subject: [PATCH 07/11] phpunit updates --- composer.json | 4 ++-- tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php | 2 +- ...ndlerAbstractTest.php => FieldHandlerAbstractTestBase.php} | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename tests/Drupal/Tests/Driver/{FieldHandlerAbstractTest.php => FieldHandlerAbstractTestBase.php} (96%) diff --git a/composer.json b/composer.json index 22b88e3..cd7ae77 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,14 @@ "composer/installers": "^2.1", "drupal/coder": "~8.3.0", "phpspec/phpspec": "~2.0 || ~4.0 || ~6.1 || dev-main", - "phpunit/phpunit": "~6.0 || ~7.0 || ^9", + "phpunit/phpunit": "~6.0 || ~7.0 || ^9 || ^10", "mockery/mockery": "^1.5", "drupal/core-composer-scaffold": "^8.4 || ^9 || ^10 || ^11", "drupal/core-recommended": "^8.4 || ^9 || ^10 || ^11", "drupal/mailsystem": "^4.4 || 4.x-dev", "drush-ops/behat-drush-endpoint": "*", "php-parallel-lint/php-parallel-lint": "^1.0", - "dms/phpunit-arraysubset-asserts": "^0.4.0", + "dms/phpunit-arraysubset-asserts": "^0.4.0 || ^0.5.0", "palantirnet/drupal-rector": "^0.13", "symfony/phpunit-bridge": "^6.1" }, diff --git a/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php b/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php index 7878567..c627d90 100644 --- a/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php +++ b/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php @@ -43,7 +43,7 @@ public function testFieldHandlers($class_name, $entity, $entity_type, array $fie * @return array * An array of test data. */ - public function dataProvider() { + public static function dataProvider() { return [ // Test default text field provided as simple text. [ diff --git a/tests/Drupal/Tests/Driver/FieldHandlerAbstractTest.php b/tests/Drupal/Tests/Driver/FieldHandlerAbstractTestBase.php similarity index 96% rename from tests/Drupal/Tests/Driver/FieldHandlerAbstractTest.php rename to tests/Drupal/Tests/Driver/FieldHandlerAbstractTestBase.php index 165e6f7..e8c9187 100644 --- a/tests/Drupal/Tests/Driver/FieldHandlerAbstractTest.php +++ b/tests/Drupal/Tests/Driver/FieldHandlerAbstractTestBase.php @@ -7,7 +7,7 @@ /** * Base class for field handler tests. */ -abstract class FieldHandlerAbstractTest extends TestCase { +abstract class FieldHandlerAbstractTestBase extends TestCase { /** * {@inheritdoc} From 25b5e65a7207f18514cd308934b66dbccd3e1cbb Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 21:48:33 +0200 Subject: [PATCH 08/11] fix extends from test base class --- tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php b/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php index c627d90..4bf2cd8 100644 --- a/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php +++ b/tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php @@ -7,7 +7,7 @@ /** * Tests the Drupal 7 field handlers. */ -class Drupal7FieldHandlerTest extends FieldHandlerAbstractTest { +class Drupal7FieldHandlerTest extends FieldHandlerAbstractTestBase { /** * Tests the field handlers. From 778827b6f410bf86e464405ffb9a4db05f79c977 Mon Sep 17 00:00:00 2001 From: DDEV User Date: Mon, 29 Jul 2024 19:55:25 +0000 Subject: [PATCH 09/11] trying to migrate configuration on the fly --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd7ae77..44ad2a0 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ }, "scripts": { "lint": "XDEBUG_MODE=off parallel-lint src spec tests", - "phpunit": "XDEBUG_MODE=coverage phpunit --coverage-text", + "phpunit-configuration": "hpunit --migrate-configuration", + "phpunit": "XDEBUG_MODE=coverage phpunit", "phpspec": "XDEBUG_MODE=off phpspec run -f pretty --no-interaction", "phpcs": "XDEBUG_MODE=off phpcs --standard=./phpcs-ruleset.xml .", "rector": [ @@ -48,6 +49,7 @@ "test": [ "XDEBUG_MODE=off composer validate --no-interaction", "@lint", + "@phpunit-configuration", "@phpunit", "@phpspec", "@phpcs", From fed07a96e0bbe853922dc4cd648bb44795d4772b Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 22:00:35 +0200 Subject: [PATCH 10/11] fix phpunit migraate --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 44ad2a0..7d436a5 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ }, "scripts": { "lint": "XDEBUG_MODE=off parallel-lint src spec tests", - "phpunit-configuration": "hpunit --migrate-configuration", + "phpunit-configuration": "phpunit --migrate-configuration", "phpunit": "XDEBUG_MODE=coverage phpunit", "phpspec": "XDEBUG_MODE=off phpspec run -f pretty --no-interaction", "phpcs": "XDEBUG_MODE=off phpcs --standard=./phpcs-ruleset.xml .", From 1d3efa9674bcbaee4a713ec4d8859a55bc7e6d38 Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher Date: Mon, 29 Jul 2024 22:05:59 +0200 Subject: [PATCH 11/11] move migrate to a separate d11 only step --- .github/workflows/ci.yml | 3 +++ composer.json | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8476e77..f7712fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,5 +30,8 @@ jobs: run: docker-compose exec -u ${DOCKER_USER_ID} -T php composer require --no-interaction --dev --no-update drupal/core:^${DRUPAL_VERSION} drupal/core-recommended:^${DRUPAL_VERSION} - name: composer install run: docker-compose exec -T php composer install + - name: composer phpunit-configuration + run: docker-compose exec -T php phpunit --migrate-configuration + if: "${{ matrix.drupal_version == '11'}}" - name: composer test run: docker-compose exec -T php composer test diff --git a/composer.json b/composer.json index 7d436a5..d91d4f6 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,6 @@ }, "scripts": { "lint": "XDEBUG_MODE=off parallel-lint src spec tests", - "phpunit-configuration": "phpunit --migrate-configuration", "phpunit": "XDEBUG_MODE=coverage phpunit", "phpspec": "XDEBUG_MODE=off phpspec run -f pretty --no-interaction", "phpcs": "XDEBUG_MODE=off phpcs --standard=./phpcs-ruleset.xml .", @@ -49,7 +48,6 @@ "test": [ "XDEBUG_MODE=off composer validate --no-interaction", "@lint", - "@phpunit-configuration", "@phpunit", "@phpspec", "@phpcs",