Skip to content

Commit

Permalink
Merge pull request #276 from Berdir/d11
Browse files Browse the repository at this point in the history
D11 testing and fixes
  • Loading branch information
jhedstrom authored Jul 31, 2024
2 parents 531f3e4 + 1d3efa9 commit 5a92b22
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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: "9"
- php_version: "8.2"
drupal_version: "10"
- php_version: "8.0"
- php_version: "8.3"
drupal_version: "10"
- php_version: "8.2"
drupal_version: "9"
- php_version: "8.3"
drupal_version: "11"
env:
PHP_VERSION: ${{ matrix.php_version }}
DRUPAL_VERSION: ${{ matrix.drupal_version }}
Expand All @@ -27,8 +27,11 @@ 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 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
15 changes: 6 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +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@beta",
"drupal/core-recommended": "^8.4 || ^9 || ^10@beta",
"drupal/mailsystem": "^4.4",
"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",
"mglaman/drupal-check": "^1",
"dms/phpunit-arraysubset-asserts": "^0.4.0 || ^0.5.0",
"palantirnet/drupal-rector": "^0.13",
"symfony/phpunit-bridge": "^6.1"
},
Expand All @@ -38,10 +37,9 @@
},
"scripts": {
"lint": "XDEBUG_MODE=off parallel-lint src spec tests",
"phpunit": "XDEBUG_MODE=coverage phpunit --coverage-text",
"phpunit": "XDEBUG_MODE=coverage phpunit",
"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",
Expand All @@ -53,7 +51,6 @@
"@phpunit",
"@phpspec",
"@phpcs",
"@drupal-check",
"@rector"
]
},
Expand Down
17 changes: 9 additions & 8 deletions src/Drupal/Driver/Cores/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Tests the Drupal 7 field handlers.
*/
class Drupal7FieldHandlerTest extends FieldHandlerAbstractTest {
class Drupal7FieldHandlerTest extends FieldHandlerAbstractTestBase {

/**
* Tests the field handlers.
Expand Down Expand Up @@ -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.
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Base class for field handler tests.
*/
abstract class FieldHandlerAbstractTest extends TestCase {
abstract class FieldHandlerAbstractTestBase extends TestCase {

/**
* {@inheritdoc}
Expand Down

0 comments on commit 5a92b22

Please sign in to comment.