Skip to content

Commit

Permalink
Merge pull request #236 from openeuropa/EWPP-4015
Browse files Browse the repository at this point in the history
EWPP-4015: Support D10.2 and drop D9.
  • Loading branch information
nagyad authored Feb 7, 2024
2 parents 1f645be + c9eca21 commit e1e6994
Show file tree
Hide file tree
Showing 30 changed files with 170 additions and 51 deletions.
19 changes: 9 additions & 10 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ services:
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
selenium:
# Newer Selenium Chrome images are not supported at the moment by behat/mink-selenium2-driver.
image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-3.141.59-oxygen
shm_size: 2g
image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-4.1.3-20220405
environment:
- DISPLAY=:99
- SE_OPTS=-debug
- SCREEN_WIDTH=1280
- SCREEN_HEIGHT=800
- SCREEN_WIDTH=1440
- SCREEN_HEIGHT=900
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5

Expand Down Expand Up @@ -70,9 +67,11 @@ pipeline:

matrix:
include:
- CORE_VERSION: 9.4.0
PHP_VERSION: 8.0
- CORE_VERSION: 9.4.0
- CORE_VERSION: 10.1.0
PHP_VERSION: 8.1
- CORE_VERSION: 10.0
- CORE_VERSION: 10.1.0
PHP_VERSION: 8.2
- CORE_VERSION: 10.2.0
PHP_VERSION: 8.1
- CORE_VERSION: 10.2.0
PHP_VERSION: 8.2
25 changes: 24 additions & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,30 @@ default:
javascript_session: selenium2
selenium2:
wd_host: '${selenium.host}:${selenium.port}/wd/hub'
capabilities: { "browser": "${selenium.browser}", "version": "*" }
capabilities:
browser: chrome
nativeEvents: true
marionette: true
browserName: chrome
version: '*'
extra_capabilities:
chromeOptions:
w3c: false
args:
- '--no-sandbox'
- '--start-maximized'
- '--disable-gpu'
- '--window-size=1440,900'
- '--disable-dev-shm-usage'
- '--disable-setuid-sandbox'
- '--disable-web-security'
- '--DNS-prefetch-disable'
- '--disable-translate'
- '--ignore-certificate-errors'
- '--test-type'
- '--disable-extensions'
- '--incognito'
- '--disable-infobars'
ajax_timeout: 10
Drupal\DrupalExtension:
api_driver: "drupal"
Expand Down
19 changes: 12 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.0",
"php": ">=8.1",
"cweagans/composer-patches": "^1.7",
"drupal/core": "^9.4 || ^10",
"drupal/core": "^10",
"drupal/embed": "^1.5",
"drupal/entity_browser": "^2.5",
"drupal/file_link": "^2.1",
Expand All @@ -20,20 +20,21 @@
"drupal/ckeditor": "^1.0",
"drupal/composite_reference": "^2.2",
"drupal/config_devel": "^1.9",
"drupal/core-composer-scaffold": "^9.4 || ^10",
"drupal/core-composer-scaffold": "^10",
"drupal/drupal-extension": "^5.0",
"drupal/entity_reference_revisions": "^1.7",
"drupal/json_field": "^1.1",
"drush/drush": "^11.1",
"drush/drush": "^12.4",
"mikey179/vfsstream": "^1.6",
"nikic/php-parser": "^4.18",
"openeuropa/behat-transformation-context": "^0.2",
"openeuropa/code-review": "^2.0.0-alpha6",
"openeuropa/oe_link_lists": "^0.22",
"openeuropa/oe_oembed": "~0.7.0",
"openeuropa/oe_webtools": "^1.23",
"openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6",
"phpspec/prophecy-phpunit": "^2",
"symfony/phpunit-bridge": "^6.2"
"symfony/phpunit-bridge": "^6.4"
},
"scripts": {
"post-install-cmd": "./vendor/bin/run drupal:site-setup",
Expand All @@ -55,7 +56,8 @@
"Drupal\\Tests\\oe_media\\": "./tests/src",
"Drupal\\Tests\\oe_media_embed\\": "./modules/oe_media_embed/tests/src",
"Drupal\\Tests\\oe_link_lists\\": "./build/modules/contrib/oe_link_lists/tests/src",
"Drupal\\Tests\\oe_link_lists_manual_source\\": "./build/modules/contrib/oe_link_lists/modules/oe_link_lists_manual_source/tests/src"
"Drupal\\Tests\\oe_link_lists_manual_source\\": "./build/modules/contrib/oe_link_lists/modules/oe_link_lists_manual_source/tests/src",
"Drupal\\FunctionalJavascriptTests\\": "./build/core/tests/Drupal/FunctionalJavascriptTests"
}
},
"extra": {
Expand All @@ -76,7 +78,10 @@
"locations": {
"web-root": "./build"
}
}
},
"_readme": [
"Explicit requirement of nikic/php-parser as ^5.0 generates GrumPHP Parser issues."
]
},
"config": {
"allow-plugins": {
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ services:
# @link https://github.com/elgalu/docker-selenium/issues/20
selenium:
# Newer Selenium Chrome images are not supported at the moment by behat/mink-selenium2-driver.
image: selenium/standalone-chrome-debug:3.141.59-oxygen
image: selenium/standalone-chrome:4.1.3-20220405
environment:
- DISPLAY=:99
- SE_OPTS=-debug
- SCREEN_WIDTH=1280
- SCREEN_HEIGHT=800
- SCREEN_WIDTH=1440
- SCREEN_HEIGHT=900
- VNC_NO_PASSWORD=1
ports:
- '4444:4444'
Expand Down
2 changes: 1 addition & 1 deletion modules/oe_media_avportal/oe_media_avportal.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'OpenEuropa Media AV Portal'
description: 'Integrates the OpenEuropa Media module with the AV Portal service.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
dependencies:
- oe_media:oe_media
- views:views
Expand Down
22 changes: 20 additions & 2 deletions modules/oe_media_avportal/src/Plugin/views/query/AVPortalQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,27 @@
*/
class AVPortalQuery extends QueryPluginBase {

/**
* The query where group.
*
* @var array
*/
public $where;

/**
* The total number of rows in the query.
*
* @var int
*
* phpcs:disable Drupal.NamingConventions.ValidVariableName.LowerCamelName
*/
public $total_rows;

/**
* AV Portal client factory.
*
* phpcs:enable Drupal.NamingConventions.ValidVariableName.LowerCamelName
*
* @var \Drupal\media_avportal\AvPortalClientFactory
*/
protected $clientFactory;
Expand Down Expand Up @@ -60,18 +78,18 @@ class AVPortalQuery extends QueryPluginBase {
* The config factory.
* @param \Drupal\Core\Extension\ModuleExtensionList|null $moduleExtensionList
* The module extension list.
*
* phpcs:disable Drupal.Semantics.FunctionTriggerError.TriggerErrorTextLayoutRelaxed
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, AvPortalClientFactory $client_factory, ConfigFactoryInterface $config_factory, ModuleExtensionList $moduleExtensionList = NULL) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->clientFactory = $client_factory;
$this->config = $config_factory->get('media_avportal.settings');

// @codingStandardsIgnoreStart
if (!$moduleExtensionList) {
@trigger_error('Calling ' . __METHOD__ . ' without the $moduleExtensionList argument is deprecated in 1.23.0 and will be required in 2.0.0.', E_USER_DEPRECATED);
$moduleExtensionList = \Drupal::service('extension.list.module');
}
// @codingStandardsIgnoreEnd

$this->moduleExtensionList = $moduleExtensionList;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'OpenEuropa Media AV Portal Test'
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
type: module
dependencies:
- media_avportal:media_avportal_mock
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ public function testWidget(): void {
$this->assertEmpty($entity_type_manager->getStorage('media')->loadMultiple());
$this->getSession()->getPage()->checkField('entity_browser_select[I-163308]');
$this->getSession()->getPage()->pressButton('Select entities');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSingleMediaEntity($media_title);

// Make the same selection again and make sure the entity gets reused.
$this->drupalGet('/entity-browser/iframe/av_portal_entity_browser_test');
$this->getSession()->getPage()->checkField('entity_browser_select[I-163308]');
$this->getSession()->getPage()->pressButton('Select entities');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSingleMediaEntity($media_title);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/oe_media_demo/oe_media_demo.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'OpenEuropa Media Demo'
description: 'Demo module for the OpenEuropa media project.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
dependencies:
- drupal:media
- oe_media:oe_media
Expand Down
3 changes: 1 addition & 2 deletions modules/oe_media_embed/oe_media_embed.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ name: 'OpenEuropa Media Embed'
description: 'Provides the embed functionality of the media types. This is a legacy module as the main logic has been moved to oe_oembed.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
dependencies:
- drupal:views
- media_avportal:media_avportal
- embed:embed
- drupal:ckeditor
- oe_oembed:oe_oembed
2 changes: 1 addition & 1 deletion modules/oe_media_gallery/oe_media_gallery.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Provides media gallery link list bundle and source plugins.'
package: OpenEuropa

type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10

dependencies:
- oe_link_lists:oe_link_lists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Test module for OpenEuropa Media Gallery.'
package: Testing

type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10

dependencies:
- oe_media_gallery:oe_media_gallery
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function setUp(): void {

$this->videoMedia = Media::create([
'bundle' => 'remote_video',
'oe_media_oembed_video' => 'https://www.youtube.com/watch?v=1-g73ty9v04',
'oe_media_oembed_video' => 'https://www.youtube.com/watch?v=OkPW9mK5Vw8',
]);
$this->videoMedia->save();

Expand Down
2 changes: 1 addition & 1 deletion modules/oe_media_iframe/oe_media_iframe.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Provides media types with iframe as media source.'
package: OpenEuropa

type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10

dependencies:
- drupal:filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ public function process($text, $langcode) {
$iframe->removeChild($node);
}

$result->setProcessedText($dom->saveXML($iframe));
// Since the text can come with multiple iframes and other HTML entities
// which we don't want to include in the processed markup, we take only the
// modified iframe and import it in a new HTML document.
$new_dom = Html::load($dom->saveHTML($iframe));

$result->setProcessedText(Html::serialize($new_dom));

return $result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,29 @@ public function testFormat(): void {
*
* @return array
* A list of scenarios.
*
* @todo Remove the version dependent assertions once we drop D10.1 support.
*/
protected function providerTestFormat(): array {
// In D10.2 empty HTML attributes are rendered without assignment (="").
$higher_core_version = (bool) version_compare(\Drupal::VERSION, '10.2', '>');
return [
'complex HTML' => [
'html' => '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0"><a href="#">invalid</a></iframe><script type="text/javascript">alert(\'no js\')</script><p>Lorem</p><div>ipsum</div><strong>dolor</strong><em>sit</em>amet, consectetur adipiscing elit',
'expected' => '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0">invalid</iframe>',
],
'EbS Live embed code' => [
'html' => '<iframe src="http://web:8080/tests/fixtures/example.html" id="videoplayer" width="852" height="480" title="" frameborder="0" scrolling="no" webkitAllowFullScreen="true" mozallowfullscreen="true" allowFullScreen="true"></iframe>',
'expected' => '<iframe src="http://web:8080/tests/fixtures/example.html" width="852" height="480" title="" frameborder="0" scrolling="no" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen="true"></iframe>',
'expected' => $higher_core_version
? '<iframe src="http://web:8080/tests/fixtures/example.html" width="852" height="480" title frameborder="0" scrolling="no" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen="true"></iframe>'
: '<iframe src="http://web:8080/tests/fixtures/example.html" width="852" height="480" title="" frameborder="0" scrolling="no" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen="true"></iframe>',
],
'iframe with all existing iframe attributes' => [
// Lang and dir attributes are always allowed.
'html' => '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0" allow allowfullscreen allowpaymentrequest csp importance loading referrerpolicy sandbox srcdoc mozallowfullscreen webkitAllowFullScreen scrolling accesskey autocapitalize class contenteditable data-test data-test2 dir draggable dropzone exportparts hidden id inputmode is itemid itemprop itemref itemscope itemtype lang part slot spellcheck style tabindex title translate></iframe>',
// The xml:lang attribute gets duplicated due to
// https://www.drupal.org/node/1333730.
'expected' => '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0" allowfullscreen="" importance="" loading="" referrerpolicy="" sandbox="" mozallowfullscreen="" webkitallowfullscreen="" scrolling="" lang="" title="" xml:lang="" xml:lang=""></iframe>',
'expected' => $higher_core_version
? '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0" allowfullscreen importance loading referrerpolicy sandbox mozallowfullscreen webkitallowfullscreen scrolling lang title></iframe>'
: '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0" allowfullscreen="" importance="" loading="" referrerpolicy="" sandbox="" mozallowfullscreen="" webkitallowfullscreen="" scrolling="" lang="" title="" xml:lang="" xml:lang=""></iframe>',
],
'iframe with invalid attribute' => [
'html' => '<iframe src="http://web:8080/tests/fixtures/example.html" width="800" height="600" frameborder="0" invalid-attribute="with random value"></iframe>',
Expand Down
16 changes: 13 additions & 3 deletions modules/oe_media_iframe/tests/src/Unit/FilterIframeTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ public function testProcess(string $html, string $expected): void {
*
* @return array
* The test data.
*
* @todo Remove the version dependent assertions once we drop D10.1 support.
*/
public function processDataProvider(): array {
// In D10.2, the contents of the iframe are considered as text and escaped.
$higher_core_version = (bool) version_compare(\Drupal::VERSION, '10.2', '>');
return [
'single iframe' => [
'<iframe src="http://example.com" width="800" height="600" allowFullScreen="true"></iframe>',
Expand All @@ -56,15 +60,21 @@ public function processDataProvider(): array {
],
'nested tags' => [
'<iframe src="http://example.com"><a href="http://dangerous-domain.example">Click here!</a>Please enable iframes in your browser.</iframe>',
'<iframe src="http://example.com">Please enable iframes in your browser.</iframe>',
$higher_core_version
? '<iframe src="http://example.com">&lt;a href="http://dangerous-domain.example"&gt;Click here!&lt;/a&gt;Please enable iframes in your browser.</iframe>'
: '<iframe src="http://example.com">Please enable iframes in your browser.</iframe>',
],
'nested iframes' => [
'<iframe src="http://example.com/first"><iframe src="http://example.com/second">Inner content.</iframe>Useful content.</iframe>',
'<iframe src="http://example.com/first">Useful content.</iframe>',
$higher_core_version
? '<iframe src="http://example.com/first">&lt;iframe src="http://example.com/second"&gt;Inner content.</iframe>'
: '<iframe src="http://example.com/first">Useful content.</iframe>',
],
'multiple text content' => [
'<iframe src="http://example.com">First node <strong>remove</strong> second node <em>remove</em>.</iframe>',
'<iframe src="http://example.com">First node second node .</iframe>',
$higher_core_version
? '<iframe src="http://example.com">First node &lt;strong&gt;remove&lt;/strong&gt; second node &lt;em&gt;remove&lt;/em&gt;.</iframe>'
: '<iframe src="http://example.com">First node second node .</iframe>',
],
'extra HTML content with iframe' => [
'Lorem ipsum dolor sit amet<iframe src="http://example.com"></iframe><p>Consectetur adipiscing elit</p>Ut finibus vulputate fringilla.',
Expand Down
2 changes: 1 addition & 1 deletion modules/oe_media_js_asset/oe_media_js_asset.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Provides the JS asset media type.
package: OpenEuropa

type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10

dependencies:
- drupal:media
Expand Down
2 changes: 1 addition & 1 deletion modules/oe_media_link_lists/oe_media_link_lists.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'OpenEuropa Media Link Lists'
description: 'Provides internal media support for manual link lists.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
dependencies:
- drupal:media
- oe_link_lists:oe_link_lists_manual_source
2 changes: 1 addition & 1 deletion modules/oe_media_webtools/oe_media_webtools.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'OpenEuropa Media Webtools'
description: 'Provides embeddable webtools media types.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
dependencies:
- drupal:media
- oe_webtools_media:oe_webtools_media
Expand Down
2 changes: 1 addition & 1 deletion oe_media.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'OpenEuropa Media'
description: 'Media features for the OpenEuropa project.'
package: OpenEuropa
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
dependencies:
- media:media
- drupal:options
Expand Down
Loading

0 comments on commit e1e6994

Please sign in to comment.