Skip to content

Commit 5a92b22

Browse files
authored
Merge pull request jhedstrom#276 from Berdir/d11
D11 testing and fixes
2 parents 531f3e4 + 1d3efa9 commit 5a92b22

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
php_version: ["7.4", "8.0", "8.1", "8.2"]
10-
drupal_version: ["9", "10"]
11-
exclude:
9+
include:
1210
- php_version: "7.4"
11+
drupal_version: "9"
12+
- php_version: "8.2"
1313
drupal_version: "10"
14-
- php_version: "8.0"
14+
- php_version: "8.3"
1515
drupal_version: "10"
16-
- php_version: "8.2"
17-
drupal_version: "9"
16+
- php_version: "8.3"
17+
drupal_version: "11"
1818
env:
1919
PHP_VERSION: ${{ matrix.php_version }}
2020
DRUPAL_VERSION: ${{ matrix.drupal_version }}
@@ -27,8 +27,11 @@ jobs:
2727
- name: composer self-update
2828
run: docker-compose exec -T php composer self-update
2929
- name: composer require
30-
run: docker-compose exec -u ${DOCKER_USER_ID} -T php composer require --no-interaction --dev --no-update drupal/core:^${DRUPAL_VERSION}
30+
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}
3131
- name: composer install
3232
run: docker-compose exec -T php composer install
33+
- name: composer phpunit-configuration
34+
run: docker-compose exec -T php phpunit --migrate-configuration
35+
if: "${{ matrix.drupal_version == '11'}}"
3336
- name: composer test
3437
run: docker-compose exec -T php composer test

composer.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
"composer/installers": "^2.1",
2222
"drupal/coder": "~8.3.0",
2323
"phpspec/phpspec": "~2.0 || ~4.0 || ~6.1 || dev-main",
24-
"phpunit/phpunit": "~6.0 || ~7.0 || ^9",
24+
"phpunit/phpunit": "~6.0 || ~7.0 || ^9 || ^10",
2525
"mockery/mockery": "^1.5",
26-
"drupal/core-composer-scaffold": "^8.4 || ^9 || ^10@beta",
27-
"drupal/core-recommended": "^8.4 || ^9 || ^10@beta",
28-
"drupal/mailsystem": "^4.4",
26+
"drupal/core-composer-scaffold": "^8.4 || ^9 || ^10 || ^11",
27+
"drupal/core-recommended": "^8.4 || ^9 || ^10 || ^11",
28+
"drupal/mailsystem": "^4.4 || 4.x-dev",
2929
"drush-ops/behat-drush-endpoint": "*",
3030
"php-parallel-lint/php-parallel-lint": "^1.0",
31-
"dms/phpunit-arraysubset-asserts": "^0.4.0",
32-
"mglaman/drupal-check": "^1",
31+
"dms/phpunit-arraysubset-asserts": "^0.4.0 || ^0.5.0",
3332
"palantirnet/drupal-rector": "^0.13",
3433
"symfony/phpunit-bridge": "^6.1"
3534
},
@@ -38,10 +37,9 @@
3837
},
3938
"scripts": {
4039
"lint": "XDEBUG_MODE=off parallel-lint src spec tests",
41-
"phpunit": "XDEBUG_MODE=coverage phpunit --coverage-text",
40+
"phpunit": "XDEBUG_MODE=coverage phpunit",
4241
"phpspec": "XDEBUG_MODE=off phpspec run -f pretty --no-interaction",
4342
"phpcs": "XDEBUG_MODE=off phpcs --standard=./phpcs-ruleset.xml .",
44-
"drupal-check": "XDEBUG_MODE=off drupal-check --drupal-root=drupal ./src/Drupal/Driver/Cores/Drupal8.php ./src/Drupal/Driver/Fields/Drupal8",
4543
"rector": [
4644
"cp ./vendor/palantirnet/drupal-rector/rector.php drupal/.",
4745
"XDEBUG_MODE=off cd drupal && ../vendor/bin/rector process ../src/Drupal/Driver/Cores/Drupal8.php --dry-run",
@@ -53,7 +51,6 @@
5351
"@phpunit",
5452
"@phpspec",
5553
"@phpcs",
56-
"@drupal-check",
5754
"@rector"
5855
]
5956
},

src/Drupal/Driver/Cores/Drupal8.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,19 @@ public function userDelete(\stdClass $user) {
262262
*/
263263
public function userAddRole(\stdClass $user, $role_name) {
264264
// Allow both machine and human role names.
265-
$roles = user_role_names();
266-
$id = array_search($role_name, $roles);
267-
if (FALSE !== $id) {
268-
$role_name = $id;
269-
}
270-
271-
if (!$role = Role::load($role_name)) {
265+
$query = \Drupal::entityQuery('user_role');
266+
$conditions = $query->orConditionGroup()
267+
->condition('id', $role_name)
268+
->condition('label', $role_name);
269+
$rids = $query
270+
->condition($conditions)
271+
->execute();
272+
if (!$rids) {
272273
throw new \RuntimeException(sprintf('No role "%s" exists.', $role_name));
273274
}
274275

275276
$account = User::load($user->uid);
276-
$account->addRole($role->id());
277+
$account->addRole(reset($rids));
277278
$account->save();
278279
}
279280

tests/Drupal/Tests/Driver/Drupal7FieldHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Tests the Drupal 7 field handlers.
99
*/
10-
class Drupal7FieldHandlerTest extends FieldHandlerAbstractTest {
10+
class Drupal7FieldHandlerTest extends FieldHandlerAbstractTestBase {
1111

1212
/**
1313
* Tests the field handlers.
@@ -43,7 +43,7 @@ public function testFieldHandlers($class_name, $entity, $entity_type, array $fie
4343
* @return array
4444
* An array of test data.
4545
*/
46-
public function dataProvider() {
46+
public static function dataProvider() {
4747
return [
4848
// Test default text field provided as simple text.
4949
[

tests/Drupal/Tests/Driver/FieldHandlerAbstractTest.php renamed to tests/Drupal/Tests/Driver/FieldHandlerAbstractTestBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Base class for field handler tests.
99
*/
10-
abstract class FieldHandlerAbstractTest extends TestCase {
10+
abstract class FieldHandlerAbstractTestBase extends TestCase {
1111

1212
/**
1313
* {@inheritdoc}

0 commit comments

Comments
 (0)