Skip to content
Snippets Groups Projects
Commit 1e52823f authored by Peter Wolanin's avatar Peter Wolanin Committed by Claudiu Cristea
Browse files

Issue #3521582 by pwolanin, claudiu.cristea: alpha12 has a fatal error on Drupal 9

parent 5330dd80
Branches
Tags 8.x-1.0-alpha13
2 merge requests!38Resolve #3525064 "Add views relationship",!35Issue #3521582 alpha12 fix for D9
Pipeline #484547 failed
......@@ -17,6 +17,18 @@ variables:
OPT_IN_TEST_PREVIOUS_MAJOR: 1
OPT_IN_TEST_MAX_PHP: 1
composer (D9):
extends: .composer-base
variables:
PHP_VERSION: "8.2"
PHP_IMAGE_VARIANT: "apache"
IGNORE_PROJECT_DRUPAL_CORE_VERSION: 1
DRUPAL_CORE: "9.5.11"
phpunit (D9):
extends: phpunit
needs: [composer (D9)]
phpstan:
allow_failure: false
phpcs:
......
......
......@@ -25,7 +25,7 @@
],
"require-dev": {
"drupal/coder": "^8.3.16",
"drush/drush": "^12.5 || ^13.3",
"drush/drush": "^11 || ^12.5 || ^13.3",
"phpunit/phpunit": "^7 || ^8 || ^9 || ^10.5"
},
"minimum-stability": "dev",
......
......
......@@ -33,12 +33,18 @@ function og_views_data_alter(array &$data) {
* field type check.
*/
function og_field_views_data(FieldStorageConfigInterface $field_storage) {
if (class_exists('\Drupal\Component\Utility\DeprecationHelper')) {
$data = DeprecationHelper::backwardsCompatibleCall(
currentVersion: \Drupal::VERSION,
deprecatedVersion: '11.2.0',
currentCallable: fn() => \Drupal::service('views.field_data_provider')->defaultFieldImplementation($field_storage),
deprecatedCallable: fn() => views_field_default_views_data($field_storage),
);
}
else {
// @phpstan-ignore-next-line
$data = views_field_default_views_data($field_storage);
}
// This is the same as entity reference integration as the OG standard
// reference item is no different really.
......
......
......@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\Tests\og_ui\Functional;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -45,10 +46,12 @@ class BundleEntityFormAlterTest extends BrowserTestBase {
parent::setUp();
$this->entityTypeManager = \Drupal::entityTypeManager();
$available_perms = \Drupal::service('user.permissions')->getPermissions();
// Permission 'administer block types' was added in Drupal 10.
$block_perm = isset($available_perms['administer block types']) ? 'administer block types' : 'administer blocks';
// Log in as an administrator that can manage blocks and content types.
$this->adminUser = $this->drupalCreateUser([
'administer block types',
$block_perm,
'administer content types',
'bypass node access',
]);
......@@ -67,7 +70,7 @@ class BundleEntityFormAlterTest extends BrowserTestBase {
'id' => 'school',
'og_is_group' => 1,
];
$this->drupalGet('/admin/structure/block-content/add');
$this->drupalGet(Url::fromRoute('block_content.type_add'));
$this->submitForm($edit, 'Save');
$edit = [
......
......
......@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\og\Unit;
use Drupal\TestTools\Random;
use Drupal\Component\Utility\Random;
use Drupal\Tests\UnitTestCase;
use Drupal\og\Event\PermissionEvent;
use Drupal\og\GroupContentOperationPermission;
......@@ -20,6 +20,34 @@ use Drupal\og\OgRoleInterface;
*/
class PermissionEventTest extends UnitTestCase {
/**
* An instance of the Random class.
*
* @var \Drupal\Component\Utility\Random
*/
protected static Random $myRandomGenerator;
/**
* Generates a unique random string containing letters and numbers.
*
* We can't use the method and object from \Drupal\Tests\UnitTestCase
* because we need it for static data provider methods.
*
* @param int $length
* Length of random string to generate.
*
* @return string
* Randomly generated unique string.
*
* @see \Drupal\Component\Utility\Random::name()
*/
protected static function myRandomMachineName($length = 8): string {
if (!isset(self::$myRandomGenerator)) {
self::$myRandomGenerator = new Random();
}
return self::$myRandomGenerator->name($length, TRUE);
}
/**
* Tests getting a single group permission.
*
......@@ -746,9 +774,9 @@ class PermissionEventTest extends UnitTestCase {
// Supply a random entity type ID, bundle ID and array of group content
// bundle IDs for each data set.
foreach ($permissions as &$item) {
$item[] = Random::machineName();
$item[] = Random::machineName();
$item[] = [Random::machineName() => [Random::machineName()]];
$item[] = self::myRandomMachineName();
$item[] = self::myRandomMachineName();
$item[] = [self::myRandomMachineName() => [self::myRandomMachineName()]];
}
return $permissions;
......@@ -865,9 +893,9 @@ class PermissionEventTest extends UnitTestCase {
// Supply a random entity type ID, bundle ID and array of group content
// bundle IDs for each data set.
foreach ($permissions as &$item) {
$item[] = Random::machineName();
$item[] = Random::machineName();
$item[] = [Random::machineName() => [Random::machineName()]];
$item[] = self::myRandomMachineName();
$item[] = self::myRandomMachineName();
$item[] = [self::myRandomMachineName() => [self::myRandomMachineName()]];
}
return $permissions;
......@@ -964,9 +992,9 @@ class PermissionEventTest extends UnitTestCase {
// Supply a random entity type ID, bundle ID and array of group content
// bundle IDs for each data set.
foreach ($permissions as &$item) {
$item[] = Random::machineName();
$item[] = Random::machineName();
$item[] = [Random::machineName() => [Random::machineName()]];
$item[] = self::myRandomMachineName();
$item[] = self::myRandomMachineName();
$item[] = [self::myRandomMachineName() => [self::myRandomMachineName()]];
}
return $permissions;
......
......
......@@ -5,10 +5,11 @@ declare(strict_types=1);
namespace Drupal\Tests\og\Unit\Plugin\OgGroupResolver;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Http\InputBag;
use Drupal\og\OgResolvedGroupCollectionInterface;
use Drupal\og\Plugin\OgGroupResolver\RequestQueryArgumentResolver;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\InputBag as SymfonyInputBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
......@@ -83,7 +84,13 @@ class RequestQueryArgumentResolverTest extends OgGroupResolverTestBase {
if ($group_type) {
$bag[RequestQueryArgumentResolver::GROUP_TYPE_ARGUMENT] = $group_type;
}
// This class was removed in Drupal 10.
if (class_exists('\Drupal\Core\Http\InputBag')) {
$request->query = new InputBag($bag);
}
else {
$request->query = new SymfonyInputBag($bag);
}
// The plugin may try to load the entity that is described in the query
// arguments.
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment