Skip to content

Commit

Permalink
Merge pull request nuvoleweb#292 from nuvoleweb/291_drupal9_compatibi…
Browse files Browse the repository at this point in the history
…lity

Drupal 9 compatibility
  • Loading branch information
ademarco authored Jun 11, 2020
2 parents edb9ae0 + a84a59e commit f792de0
Show file tree
Hide file tree
Showing 46 changed files with 306 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/phpunit.xml
/docker-compose.override.yml
/runner.yml
/.editorconfig
/.gitattributes
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@ sudo: required
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4

services:
- docker

env:
global:
- DOCKER_COMPOSE_VERSION=1.17.1
- DOCKER_COMPOSE_VERSION=1.25.5
matrix:
- DRUPAL_VERSION=~8.6
- DRUPAL_VERSION=~8.7
- DRUPAL_VERSION=8.8.x-dev
- DRUPAL_VERSION=~8.8.7 GRUMPHP_CONFIG=grumphp.drupal8.yml
- DRUPAL_VERSION=~8.9.0 GRUMPHP_CONFIG=grumphp.drupal8.yml
- DRUPAL_VERSION=~9.0.0 GRUMPHP_CONFIG=grumphp.yml
- DRUPAL_VERSION=9.1.x-dev GRUMPHP_CONFIG=grumphp.yml

matrix:
allow_failures:
- env: DRUPAL_VERSION=8.8.x-dev
- env: DRUPAL_VERSION=9.1.x-dev

before_install:
- docker-compose up -d

install:
- docker-compose exec -u root php composer require webflo/drupal-core-require-dev:$DRUPAL_VERSION --dev
- docker-compose exec -u root php composer require drupal/core-recommended:$DRUPAL_VERSION --dev
- docker-compose exec -u root php chown -R www-data:www-data build

script:
- docker-compose exec -u www-data php ./vendor/bin/grumphp run
- docker-compose exec -u www-data php ./vendor/bin/grumphp run -c $GRUMPHP_CONFIG
- docker-compose exec -u www-data php ./vendor/bin/phpunit

notifications:
email: false
email: false

26 changes: 14 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@
"require-dev": {
"composer/installers": "^1.2",
"cweagans/composer-patches": "~1.4",
"drupal-composer/drupal-scaffold": "^2.2",
"drupal/config_installer": "~1",
"drupal/console": "~1",
"drush/drush": "~9",
"drupal/ds": "~3",
"drupal/field_group": "~1",
"drupal/coffee": "~1",
"drupal/config_devel": "~1",
"drupal/panels": "~4",
"drupal/core-composer-scaffold": "^8.8 || ^9",
"drupal/core-dev": "^8.8 || ^9",
"drupal/core-recommended": "~8.9.0",
"drupal/ds": "~3",
"drupal/field_group": "~3",
"drupal/page_manager": "*",
"drupal/panels": "~4",
"drupal/paragraphs": "~1",
"drupal/token": "~1",
"phpro/grumphp": "~0.14",
"webflo/drupal-core-require-dev": "~8.7",
"openeuropa/task-runner": "~1.0-beta3"
"drush/drush": "~10",
"openeuropa/task-runner": "~1.0-beta3",
"phpro/grumphp": "~0.14"
},
"repositories": [
{
Expand All @@ -48,13 +46,17 @@
}
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"post-install-cmd": "./vendor/bin/run drupal:site-setup",
"post-update-cmd": "./vendor/bin/run drupal:site-setup"
},
"extra": {
"composer-exit-on-patch-failure": true,
"enable-patching": true,
"drupal-scaffold": {
"locations": {
"web-root": "build/"
}
},
"installer-paths": {
"build/core": ["type:drupal-core"],
"build/modules/contrib/{$name}": ["type:drupal-module"],
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "2"
services:

mariadb:
image: wodby/mariadb:10.1-3.3.0
image: wodby/mariadb:10.3-3.8.4
stop_grace_period: 30s
environment:
MYSQL_ROOT_PASSWORD: password
Expand All @@ -12,7 +12,7 @@ services:
MYSQL_PASSWORD: drupal

php:
image: wodby/drupal-php:${TRAVIS_PHP_VERSION}-4.6.3
image: wodby/drupal-php:${TRAVIS_PHP_VERSION}-4.15.9
environment:
DB_HOST: mariadb
DB_USER: drupal
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
grumphp:
ascii:
failed: ~
succeeded: ~
tasks:
phpcs:
standard: vendor/drupal/coder/coder_sniffer/Drupal/
ignore_patterns:
- build/
- vendor/
triggered_by:
- php
- module
- install
- inc
- theme
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: 'UI Patterns Display Suite Test'
type: module
description: 'Test module for UI Patterns.'
core: 8.x
core_version_requirement: ^8 || ^9
hidden: true
package: 'User interface'
dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
class UiPatternsFieldRenderTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* Disable schema validation when running tests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
class UiPatternsFieldSettingsTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* Disable schema validation when running tests.
*
Expand Down
1 change: 1 addition & 0 deletions modules/ui_patterns_ds/ui_patterns_ds.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: UI Patterns Display Suite
type: module
description: Use patterns as Display Suite field templates. It also provides Display Suite pattern sources.
core: 8.x
core_version_requirement: ^8 || ^9
package: User interface
dependencies:
- ds:ds
Expand Down
1 change: 0 additions & 1 deletion modules/ui_patterns_ds/ui_patterns_ds.services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
services:
ui_patterns_ds.field_template_processor:
class: Drupal\ui_patterns_ds\FieldTemplateProcessor

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: 'UI Patterns Field Group Test'
type: module
description: 'Test module for UI Patterns.'
core: 8.x
core_version_requirement: ^8 || ^9
hidden: true
package: 'User interface'
dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
class UiPatternsFieldGroupRenderTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* Disable schema validation when running tests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
*/
class UiPatternsFieldGroupSettingsTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* Disable schema validation when running tests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: UI Patterns Field Group
type: module
description: Use patterns as field groups templates.
core: 8.x
core_version_requirement: ^8 || ^9
package: User interface
dependencies:
- field_group:field_group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: 'UI Patterns Layouts Test'
type: module
description: 'Test module for UI Patterns.'
core: 8.x
core_version_requirement: ^8 || ^9
hidden: true
package: 'User interface'
dependencies:
Expand All @@ -18,4 +19,3 @@ config_devel:
- field.field.node.article.body
- node.type.article
- core.entity_view_display.node.article.default

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
class UiPatternsLayoutsRenderTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* Disable schema validation when running tests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
class UiPatternsLayoutsSettingsTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* Disable schema validation when running tests.
*
Expand Down
1 change: 1 addition & 0 deletions modules/ui_patterns_layouts/ui_patterns_layouts.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: UI Patterns Layouts
type: module
description: Use patterns as layouts via the Layout Discovery module.
core: 8.x
core_version_requirement: ^8 || ^9
package: User interface
dependencies:
- drupal:layout_discovery
Expand Down
12 changes: 10 additions & 2 deletions modules/ui_patterns_library/src/Plugin/Deriver/LibraryDeriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\TypedData\TypedDataManager;
use Drupal\ui_patterns\Plugin\Deriver\AbstractYamlPatternsDeriver;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -80,6 +82,10 @@ class LibraryDeriver extends AbstractYamlPatternsDeriver {
* The base plugin ID.
* @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager
* Typed data manager service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* Messenger.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* File system service.
* @param string $root
* Application root directory.
* @param array $extensions
Expand All @@ -89,8 +95,8 @@ class LibraryDeriver extends AbstractYamlPatternsDeriver {
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* Theme handler service.
*/
public function __construct($base_plugin_id, TypedDataManager $typed_data_manager, $root, array $extensions, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
parent::__construct($base_plugin_id, $typed_data_manager);
public function __construct($base_plugin_id, TypedDataManager $typed_data_manager, MessengerInterface $messenger, FileSystemInterface $file_system, $root, array $extensions, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
parent::__construct($base_plugin_id, $typed_data_manager, $messenger, $file_system);
$this->root = $root;
$this->fileExtensions = $extensions;
$this->moduleHandler = $module_handler;
Expand All @@ -105,6 +111,8 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
$base_plugin_id,
$container->get('typed_data_manager'),
$container->get('messenger'),
$container->get('file_system'),
$container->get('app.root'),
$container->getParameter('ui_patterns_library.file_extensions'),
$container->get('module_handler'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: 'UI Patterns bad definition test'
type: module
core: 8.x
core_version_requirement: ^8 || ^9
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: 'UI Patterns library module test'
type: module
core: 8.x
core_version_requirement: ^8 || ^9
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: 'UI Patterns library theme test'
type: theme
core: 8.x
core_version_requirement: ^8 || ^9
base theme: stark
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
*/
class UiPatternsLibraryBadDefinitionTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
class UiPatternsLibraryOverviewTest extends WebDriverTestBase {

/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'ui_patterns_library_theme_test';

/**
* {@inheritdoc}
*/
Expand All @@ -24,13 +31,9 @@ class UiPatternsLibraryOverviewTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->container->get('theme_installer')->install(['ui_patterns_library_theme_test']);
$this->container->get('theme_handler')->setDefault('ui_patterns_library_theme_test');
$this->container->set('theme.registry', NULL);

$user = $this->drupalCreateUser(['access patterns page']);
$this->drupalLogin($user);
}
Expand All @@ -57,7 +60,7 @@ public function testOverviewPage() {
// Test view single page link.
$session->linkExists("View {$pattern['label']} as stand-alone");
$link = $this->getSession()->getPage()->findLink("View {$pattern['label']} as stand-alone");
$this->assertContains('/patterns/' . $pattern['name'], $link->getAttribute('href'));
$this->assertStringContainsString('/patterns/' . $pattern['name'], $link->getAttribute('href'));
}
}

Expand All @@ -67,7 +70,7 @@ public function testOverviewPage() {
public function testSinglePages() {
$session = $this->assertSession();

foreach ($this->getExpectedPatterns() as $index => $pattern) {
foreach ($this->getExpectedPatterns() as $pattern) {
$this->drupalGet('/patterns/' . $pattern['name']);
$session->elementContains('css', 'h1', $pattern['label']);

Expand Down
Loading

0 comments on commit f792de0

Please sign in to comment.