Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWPP-2963: Drupal 10 compatibility. #139

Merged
merged 10 commits into from
Feb 23, 2023
34 changes: 10 additions & 24 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,14 @@ services:
- NODE_MAX_SESSION=5

pipeline:
composer-install-highest:
composer-install:
group: prepare
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
volumes:
- /cache:/cache
- /cache/${DRONE_REPO_NAME}:/cache
commands:
- composer self-update --2
- composer install --ansi --no-progress
when:
matrix:
COMPOSER_BOUNDARY: highest

composer-update-lowest:
group: prepare-update
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
volumes:
- /cache:/cache
commands:
- composer self-update --2
- composer update --prefer-lowest --prefer-stable --ansi --no-progress
when:
matrix:
COMPOSER_BOUNDARY: lowest
- composer require drupal/core:~${CORE_VERSION} drupal/core-composer-scaffold:~${CORE_VERSION} --update-with-all-dependencies --ansi --no-progress --no-interaction

site-install:
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
Expand All @@ -84,9 +69,10 @@ pipeline:
- ./vendor/bin/behat --strict

matrix:
COMPOSER_BOUNDARY:
- lowest
- highest
PHP_VERSION:
- 8.0
- 8.1
include:
- CORE_VERSION: 9.4.0
PHP_VERSION: 8.0
- CORE_VERSION: 9.4.0
PHP_VERSION: 8.1
- CORE_VERSION: 10.0
PHP_VERSION: 8.1
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ default:
region_map:
"language switcher": "#block-oe-multilingual-language-switcher"
"language dialog": "#block-oe-multilingual-language-switcher"
"page content": ".region-content"
"page content": "main.site-main"
formatters:
progress: ~
44 changes: 11 additions & 33 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,26 @@
"prefer-stable": true,
"require": {
"php": ">=8.0",
"drupal/core": "^9.4",
"drupal/language_selection_page": "^2.10",
"drupal/core": "^9.4 || ^10",
"drupal/language_selection_page": "dev-2.x",
"drupal/pathauto": "^1.8"
},
"require-dev": {
"behat/behat": "^3.10",
"composer/installers": "~1.5",
"drupal/config_devel": "~1.2",
"drupal/core-composer-scaffold": "^9.4",
"drupal/ctools": "^4.0",
"drupal/devel": "~4.1",
"drupal/drupal-extension": "dev-master",
"composer/installers": "^1.11",
"drupal/core-composer-scaffold": "^9.4 || ^10",
"drupal/drupal-extension": "^5.0",
"drupal/redirect": "^1.6",
"drupal/token": "^1.10",
"drush/drush": "~10.3",
"guzzlehttp/guzzle": "^7.0",
"masterminds/html5": "^2.7.6",
"drush/drush": "^11.1",
"mikey179/vfsstream": "^1.6.10",
"openeuropa/behat-transformation-context": "~0.1",
"openeuropa/code-review": "^2.0",
"openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5",
"openeuropa/behat-transformation-context": "^0.2",
"openeuropa/code-review": "^2.0.0-alpha6",
"openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6",
"phpspec/prophecy-phpunit": "^2",
"symfony/browser-kit": "^4.4.37",
"symfony/css-selector": "^4.4.24",
"symfony/dom-crawler": "^4.4.44",
"symfony/event-dispatcher": "^4.4.30",
"symfony/http-foundation": "^4.4.30",
"symfony/phpunit-bridge": "^6.0",
"symfony/routing": "^4.4.30",
"symfony/validator": "^4.4.30",
"symfony/yaml": "^4.4.29"
"symfony/phpunit-bridge": "^6.2"
},
"_readme": [
"Explicit lower version requirement of drupal/ctools due to Drupal core 9.4 compatibility.",
"Explicit requirement of token module due to lower versions declaring optional parameters before the require one on token_tokens() function.",
"Explicit requirement of behat module due to PHP8 compatibility.",
"Explicit minimum version requirement of symfony packages due to lower versions missing return type on various methods being incompatible with PHP 8.1 parent methods.",
"Explicit minimum version requirement of symfony/phpunit-bridge to replace drupal/core-dev testing classes and traits.",
"Explicit minimum version requirement of mikey179/vfsstream due to lower versions missing return type on vfsStreamDirectory::getIterator() method.",
"Use master branch of drupal/drupal-extension to replace fabpot/goutte with behat/mink-browserkit-driver and the rest of the behat required dependencies.",
"Explicit minimum version requirement of guzzlehttp/guzzle due to lower versions missing return type on CookieJar::getIterator() and CookieJar::count() methods.",
"Explicit minimum version requirement of masterminds/html5 due to lower versions passing NULL parameters instead of string when calling DOMImplementation::createDocument() method."
"Explicit requirement of mikey179/vfsstream to remove when drupal/core-dev is reinstated."
],
"scripts": {
"post-install-cmd": "./vendor/bin/run drupal:site-setup",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ dependencies:
module:
- oe_multilingual
theme:
- bartik
- olivero
id: oe_multilingual_content_language_switcher
theme: bartik
theme: olivero
region: content
weight: 1
provider: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ dependencies:
module:
- language
theme:
- bartik
- olivero
id: oe_multilingual_language_switcher
theme: bartik
region: sidebar_first
theme: olivero
region: sidebar
weight: 1
provider: null
plugin: 'language_block:language_interface'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ label: 'Demo translatable page'
type: 'canonical_entities:node'
pattern: '[node:title]'
selection_criteria:
4c3dfef3-a556-41cf-8639-2d381e6ea498:
id: node_type
bundles:
oe_demo_translatable_page: oe_demo_translatable_page
5b3e57dd-e9d8-4eba-8f46-0bd833fde911:
id: 'entity_bundle:node'
negate: false
uuid: 5b3e57dd-e9d8-4eba-8f46-0bd833fde911
context_mapping:
node: node
uuid: 4c3dfef3-a556-41cf-8639-2d381e6ea498
bundles:
oe_demo_translatable_page: oe_demo_translatable_page
selection_logic: and
weight: -5
relationships: { }
2 changes: 1 addition & 1 deletion modules/oe_multilingual_demo/oe_multilingual_demo.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'OE Multilingual Demo'
type: module
description: 'Demo module for OpenEuropa Multilingual project.'
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10
package: 'OpenEuropa'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'OpenEuropa Multilingual Front page'
type: module
description: 'Provides handling for front page.'
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10
package: 'OpenEuropa'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PathProcessorFrontPageTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->installSchema('system', 'sequences');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'OpenEuropa Multilingual Selection Page'
type: module
description: 'Generates a Language Selection Page used on first access to a multilingual site.'
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10
package: 'OpenEuropa'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'OpenEuropa Multilingual URL Suffix'
type: module
description: 'Provides language detection method based on URL suffix.'
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10
package: 'OpenEuropa'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\oe_multilingual_url_suffix\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Dispatched by LanguageNegotiationUrlSuffix::getUrlSuffixes().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function getUrlSuffixes(): array {
// Allow other modules to alter the list of suffixes available to the
// negotiator.
$event = new UrlSuffixesAlterEvent($url_suffixes);
$this->eventDispatcher->dispatch(UrlSuffixesAlterEvent::EVENT, $event);
$this->eventDispatcher->dispatch($event, UrlSuffixesAlterEvent::EVENT);

return $event->getUrlSuffixes();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'OpenEuropa Multilingual URL Suffix Test'
description: 'Test module to test the language suffix negotiation functionality.'
type: module
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10

dependencies:
- oe_multilingual:oe_multilingual_url_suffix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LanguageNegotiationUrlSuffixTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'starterkit_theme';

/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EntityUrlSuffixLanguageTest extends LanguageTestBase {
*
* @var array
*/
public static $modules = [
protected static $modules = [
'entity_test',
'language',
'user',
Expand All @@ -41,7 +41,7 @@ class EntityUrlSuffixLanguageTest extends LanguageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->installEntitySchema('entity_test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class LanguageNegotiationUrlSuffixTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
// Set up some languages to be used by the language-based path processor.
$language_de = $this->getMockBuilder('\Drupal\Core\Language\LanguageInterface')->getMock();
$language_de = $this->createMock('\Drupal\Core\Language\LanguageInterface');
$language_de->expects($this->any())
->method('getId')
->will($this->returnValue('de'));
$language_en = $this->getMockBuilder('\Drupal\Core\Language\LanguageInterface')->getMock();
$language_en = $this->createMock('\Drupal\Core\Language\LanguageInterface');
$language_en->expects($this->any())
->method('getId')
->will($this->returnValue('en'));
Expand All @@ -64,24 +64,19 @@ protected function setUp() {
];

// Create event dispatcher stub.
$this->eventDispatcher = $this->getMockBuilder('\Symfony\Component\EventDispatcher\EventDispatcherInterface')
->disableOriginalConstructor()
->getMock();
$this->eventDispatcher = $this->createMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');

// Create a language manager stub.
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
->getMock();
$language_manager = $this->createMock('Drupal\language\ConfigurableLanguageManagerInterface');
$language_manager->expects($this->any())
->method('getLanguages')
->will($this->returnValue($this->languages));
$this->languageManager = $language_manager;

// Create a user stub.
$this->user = $this->getMockBuilder('Drupal\Core\Session\AccountInterface')->getMock();
$this->user = $this->createMock('Drupal\Core\Session\AccountInterface');

$cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager = $this->createMock('Drupal\Core\Cache\Context\CacheContextsManager');
$cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
$container = new ContainerBuilder();
$container->set('cache_contexts_manager', $cache_contexts_manager);
Expand Down
2 changes: 1 addition & 1 deletion oe_multilingual.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'OpenEuropa Multilingual'
description: 'Multilingual features for the OpenEuropa project.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10

dependencies:
- drupal:content_translation
Expand Down
4 changes: 2 additions & 2 deletions oe_multilingual.module
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function oe_multilingual_configurable_language_insert(EntityInterface $entity) {

$reader = new PoStreamReader();
$reader->setLangcode($entity->getId());
$file = drupal_get_path('module', 'oe_multilingual') . "/translations/oe_multilingual-{$entity->getId()}.po";
$file = \Drupal::service('extension.list.module')->getPath('oe_multilingual') . "/translations/oe_multilingual-{$entity->getId()}.po";
if (!file_exists($file)) {
return;
}
Expand Down Expand Up @@ -112,7 +112,7 @@ function oe_multilingual_configurable_language_insert(EntityInterface $entity) {
* Implements hook_locale_translation_projects_alter().
*/
function oe_multilingual_locale_translation_projects_alter(&$projects) {
$projects['oe_multilingual']['info']['interface translation server pattern'] = drupal_get_path('module', 'oe_multilingual') . '/translations/%project-%language.po';
$projects['oe_multilingual']['info']['interface translation server pattern'] = \Drupal::service('extension.list.module')->getPath('oe_multilingual') . '/translations/%project-%language.po';
}

/**
Expand Down
11 changes: 5 additions & 6 deletions runner.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ drupal:
post_install:
# Prepare the instance.
- "./vendor/bin/drush en toolbar -y"
- "./vendor/bin/drush en config_devel -y"
- "./vendor/bin/drush theme:enable bartik -y"
- "./vendor/bin/drush theme:enable seven -y"
- "./vendor/bin/drush config-set system.theme default bartik -y"
- "./vendor/bin/drush config-set system.theme admin seven -y"
- "./vendor/bin/drush theme:enable olivero -y"
- "./vendor/bin/drush theme:enable claro -y"
- "./vendor/bin/drush config-set system.theme default olivero -y"
- "./vendor/bin/drush config-set system.theme admin claro -y"
- "./vendor/bin/drush config-set node.settings use_admin_theme 1 -y"
# Enable the modules.
# Activate the module later, so the default Bartik blocks are placed.
# Activate the module later, so the default blocks are placed.
- "./vendor/bin/drush en oe_multilingual -y"
- "./vendor/bin/drush en oe_multilingual_demo -y"
- "./vendor/bin/drush oe-multilingual:import-local-translations"
Expand Down
2 changes: 1 addition & 1 deletion src/LocalTranslationsBatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function createBatch(array $langcodes = []): void {
'title' => $this->t('Importing translations.'),
'progress_message' => '',
'error_message' => $this->t('Error importing translation files'),
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
'file' => \Drupal::service('extension.list.module')->getPath('locale') . '/locale.batch.inc',
];

batch_set($batch);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Translation Importer'
description: 'Test module for importing translations'
core_version_requirement: ^9.4
core_version_requirement: ^9.4 || ^10
type: module
package: Testing

Expand Down
7 changes: 5 additions & 2 deletions tests/src/Behat/DrupalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ public function theDefaultSiteLanguageIs(string $name): void {
* @Given I visit a test :scheme file called :name
*/
public function createTestFile(string $scheme, string $name) {
$file = file_save_data(file_get_contents(drupal_get_path('module', 'oe_multilingual') . '/tests/fixtures/' . $name), "$scheme://$name");
$file = \Drupal::service('file.repository')->writeData(
file_get_contents(\Drupal::service('extension.list.module')->getPath('oe_multilingual') . '/tests/fixtures/' . $name),
"$scheme://$name"
);
$file->setPermanent();
$file->save();

$this->visitPath(file_create_url($file->getFileUri()));
$this->visitPath(\Drupal::service('file_url_generator')->generateAbsoluteString(($file->getFileUri())));
$file->delete();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Functional/ConfigurableLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConfigurableLanguageTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'starterkit_theme';

/**
* {@inheritdoc}
Expand Down
Loading