Skip to content

Commit

Permalink
Merge pull request #94 from openeuropa/OEL-70
Browse files Browse the repository at this point in the history
OEL-70: Drupal 9 compatibility fixes.
  • Loading branch information
upchuk authored Sep 7, 2021
2 parents f7377c5 + f201ae1 commit 2228fe2
Show file tree
Hide file tree
Showing 28 changed files with 136 additions and 69 deletions.
1 change: 1 addition & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
shm_size: 2g
environment:
- DISPLAY=:99
- SE_OPTS=-debug
- SCREEN_WIDTH=1280
- SCREEN_HEIGHT=800
- NODE_MAX_INSTANCES=5
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,24 @@ composer install
```

A post command hook (`drupal:site-setup`) is triggered automatically after `composer install`.
It will make sure that the necessary symlinks are properly setup in the development site.
It will also perform token substitution in development configuration files such as `behat.yml.dist`.
This will symlink the module in the proper directory within the test site and perform token substitution in test configuration files such as `behat.yml.dist`.

**Please note:** project files and directories are symlinked within the test site by using the
[OpenEuropa Task Runner's Drupal project symlink](https://github.com/openeuropa/task-runner-drupal-project-symlink) command.

If you add a new file or directory in the root of the project, you need to re-run `drupal:site-setup` in order to make
sure they are be correctly symlinked.

If you don't want to re-run a full site setup for that, you can simply run:

```
$ ./vendor/bin/run drupal:symlink-project
```

* Install test site by running:

```bash
./vendor/bin/run drupal:site-install
$ ./vendor/bin/run drupal:site-install
```

The development site web root should be available in the `build` directory.
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default:
suites:
default:
paths:
- %paths.base%/tests/features
- "%paths.base%/tests/features"
contexts:
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\DrupalContext
Expand Down
38 changes: 18 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,29 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.2",
"drupal/core": "^8.9",
"drupal/emr": "~1.0-beta11",
"drupal/facets": "~1.6",
"php": ">=7.3",
"drupal/core": "^8.9 || ^9.1",
"drupal/emr": "^1.0-beta11",
"drupal/facets": "^1.6",
"drupal/multivalue_form_element": "^1.0@beta",
"drupal/search_api": "~1.17",
"symfony/options-resolver": "~4.0"
"drupal/search_api": "~1.17"
},
"require-dev": {
"composer/installers": "~1.5",
"drupal/core-composer-scaffold": "^8.8",
"composer/installers": "^1.11",
"drupal/core-composer-scaffold": "^8.9 || ^9.1",
"drupal/address": "^1.8",
"drupal/config_devel": "~1.2",
"drupal/drupal-extension": "~4.0",
"drupal/extra_field": "^1.1",
"drupal/config_devel": "^1.2",
"drupal/drupal-extension": "^4.0",
"drush/drush": "^10.3",
"drupal/extra_field": "^2.1",
"drupal/inline_entity_form": "^1.0-rc9",
"drush/drush": "~9.0@stable",
"guzzlehttp/guzzle": "~6.3",
"openeuropa/code-review": "^1.5.0",
"openeuropa/drupal-core-require-dev": "~8.9",
"openeuropa/code-review": "^1.6",
"openeuropa/drupal-core-require-dev": "^8.9 || ^9.1",
"openeuropa/task-runner-drupal-project-symlink": "^1.0",
"phpspec/prophecy-phpunit": "^1 || ^2",
"openeuropa/oe_link_lists": "^0.11",
"openeuropa/oe_multilingual": "^1.5",
"openeuropa/open_vocabularies": "^1.0-alpha4",
"openeuropa/task-runner": "~1.0.0-beta6",
"phpunit/phpunit": "~6.5"
"openeuropa/oe_multilingual": "^1.8",
"openeuropa/open_vocabularies": "^1.0-alpha4"
},
"scripts": {
"post-install-cmd": "./vendor/bin/run drupal:site-setup",
Expand All @@ -50,7 +48,7 @@
"autoload-dev": {
"psr-4": {
"Drupal\\Tests\\oe_list_pages\\": "./tests/src",
"Drupal\\Tests\\oe_link_lists\\": "./build/modules/contrib/oe_link_lists/tests",
"Drupal\\Tests\\oe_link_lists\\": "./build/modules/contrib/oe_link_lists/tests/src",
"Drupal\\Tests\\oe_list_pages_link_list_source\\": "./modules/oe_list_pages_link_list_source/tests/src"
}
},
Expand Down
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ services:
- VNC_NO_PASSWORD=1
ports:
- '4444:4444'
- "5900:5900"
volumes:
- /dev/shm:/dev/shm
- '5900:5900'
shm_size: 2g

#### Mac users: uncomment the "volumes" key to enable the NFS file sharing. You can find more information about Docker for Mac here: https://github.com/openeuropa/openeuropa/blob/master/docs/starting/tooling.md#using-docker-on-macos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: The OpenEuropa List Page content type.
package: OpenEuropa

type: module
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- emr:emr_node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: This submodule adds support for Address fields in List Pages.
package: OpenEuropa

type: module
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- address:address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Provides a link list source plugin that collect links from a list p
package: OpenEuropa

type: module
core: 8.x
core_version_requirement: ^8.9 || ^9.1

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 List Pages Link List Source
package: Testing

type: module
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- oe_list_pages_link_list_source:oe_list_pages_link_list_source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class ListPageLinkSourcePluginTest extends ListPagePluginFormTestBase {
'block',
];

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';

/**
* Tests the plugin configuration form.
*/
Expand Down Expand Up @@ -85,8 +90,8 @@ public function testPluginConfigurationForm(): void {
// Edit the link list and check the values are correctly pre-populated.
$this->drupalGet($link_list->toUrl('edit-form'));

$this->assertOptionSelected('Source entity type', 'Taxonomy term');
$this->assertOptionSelected('Source bundle', 'Vocabulary one');
$this->assertTrue($this->assertSession()->optionExists('Source entity type', 'Taxonomy term')->isSelected());
$this->assertTrue($this->assertSession()->optionExists('Source bundle', 'Vocabulary one')->isSelected());

// Change the source to a Node type.
$this->getSession()->getPage()->selectFieldOption('Source entity type', 'node');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'OpenEuropa List Pages Open Vocabularies'
description: 'This submodule adds support for OpenVocabularies fields in List Pages.'
name: OpenEuropa List Pages Open Vocabularies
description: This submodule adds support for OpenVocabularies fields in List Pages.
package: OpenEuropa

type: module
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- oe_list_pages:oe_list_pages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'OpenEuropa List Pages Open Vocabularies Test'
description: 'Test module for OpenEuropa List Pages Open Vocabularies'
name: OpenEuropa List Pages Open Vocabularies Test
description: Test module for OpenEuropa List Pages Open Vocabularies
package: Testing

type: module
core: 8.x
core_version_requirement: ^8 || ^9

dependencies:
- oe_list_pages:oe_list_pages_open_vocabularies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class OpenVocabulariesFiltersTest extends ListPagePluginFormTestBase {
'search_api_db',
];

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';

/**
* The first association to test.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function testVocabularyAssociationChanges(): void {
// Check values were correctly saved.
$this->assertEquals($values['label'], $facet_1->label());
$this->assertEquals($field_id, $facet_1->getFieldIdentifier());
$this->assertEqual(SearchApiConfigurator::MAX_WEIGHT, $facet_1->getWeight());
$this->assertEquals($facet_1->getWeight(), SearchApiConfigurator::MAX_WEIGHT);
$facet_2 = Facet::load($id_2);
$this->assertNull($facet_2);
// Check fields exists.
Expand All @@ -161,14 +161,14 @@ public function testVocabularyAssociationChanges(): void {
$facet_1 = Facet::load($id_1);
$this->assertEquals('New label', $facet_1->label());
$this->assertEquals($field_id, $facet_1->getFieldIdentifier());
$this->assertEqual(SearchApiConfigurator::MAX_WEIGHT, $facet_1->getWeight());
$this->assertEquals($facet_1->getWeight(), SearchApiConfigurator::MAX_WEIGHT);
$this->assertArrayHasKey('url_processor_handler', $facet_1->getProcessors());
$this->assertArrayHasKey('display_value_widget_order', $facet_1->getProcessors());
$this->assertArrayHasKey('translate_entity', $facet_1->getProcessors());
$facet_2 = Facet::load($id_2);
$this->assertEquals('New label', $facet_2->label());
$this->assertEquals($field_id, $facet_2->getFieldIdentifier());
$this->assertEqual(SearchApiConfigurator::MAX_WEIGHT, $facet_2->getWeight());
$this->assertEquals($facet_2->getWeight(), SearchApiConfigurator::MAX_WEIGHT);

// Check field exists.
$node_index = Index::load('node');
Expand All @@ -189,7 +189,7 @@ public function testVocabularyAssociationChanges(): void {
$this->assertNull($facet_1);
$facet_2 = Facet::load($id_2);
$this->assertEquals('New label', $facet_2->label());
$this->assertEqual(SearchApiConfigurator::MAX_WEIGHT, $facet_2->getWeight());
$this->assertEquals($facet_2->getWeight(), SearchApiConfigurator::MAX_WEIGHT);
$this->assertEquals($field_id, $facet_2->getFieldIdentifier());

// Check field exists.
Expand Down
2 changes: 1 addition & 1 deletion oe_list_pages.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: The OpenEuropa List Pages allows creation and management of list pa
package: OpenEuropa

type: module
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- emr:emr_node
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="${drupal.root}/core/tests/bootstrap.php" backupGlobals="true" colors="true" >
<phpunit bootstrap="${drupal.root}/core/tests/bootstrap.php" backupGlobals="true" colors="true" cacheResult="false">
<php>
<ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/>
Expand All @@ -9,7 +9,7 @@
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["${selenium.browser}", null, "${selenium.host}:${selenium.port}/wd/hub"]'/>
</php>
<testsuites>
<testsuite>
<testsuite name="OpenEuropa List Pages Tests">
<directory>./modules/**/tests/</directory>
<directory>./tests/</directory>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion runner.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ selenium:

commands:
drupal:site-setup:
- { task: "symlink", from: "../../..", to: "${drupal.root}/modules/custom/oe_list_pages" }
- { task: "run", command: "drupal:symlink-project" }
- { task: "run", command: "drupal:drush-setup" }
- { task: "run", command: "drupal:settings-setup" }
- { task: "run", command: "setup:phpunit" }
Expand Down
11 changes: 10 additions & 1 deletion src/FilterConfigurationFormBuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\facets\FacetInterface;
use Drupal\facets\FacetManager\DefaultFacetManager;
Expand All @@ -15,7 +16,7 @@
/**
* Base class for configuration form builders for the list pages.
*/
abstract class FilterConfigurationFormBuilderBase {
abstract class FilterConfigurationFormBuilderBase implements TrustedCallbackInterface {

use StringTranslationTrait;
use DependencySerializationTrait;
Expand All @@ -28,6 +29,13 @@ abstract class FilterConfigurationFormBuilderBase {
*/
protected $facetsManager;

/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return ['preRenderOperationButtons'];
}

/**
* FilterConfigurationFormBuilderBase constructor.
*
Expand Down Expand Up @@ -226,6 +234,7 @@ protected function buildSummaryPresetFilters(array $form, FormStateInterface $fo
get_class($this),
'preRenderOperationButtons',
];

return $form;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: module
description: The test module for OE List Pages plugin event subscriber.

package: Testing
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- oe_list_pages
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: 'OpenEuropa List Pages Filters Test'
name: OpenEuropa List Pages Filters Test
type: module
description: 'The test module for filters of OE List Pages.'
description: The test module for filters of OE List Pages.

package: Testing
core: 8.x
core_version_requirement: ^8.9 || ^9.1

dependencies:
- drupal:entity_reference
- drupal:link
- drupal:options
- drupal:datetime
Expand Down
5 changes: 5 additions & 0 deletions tests/src/FunctionalJavascript/FacetsFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class FacetsFormTest extends WebDriverTestBase {
'datetime',
];

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';

/**
* The state.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/src/FunctionalJavascript/ListPagePluginFormTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
*/
abstract class ListPagePluginFormTestBase extends WebDriverTestBase {

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';

/**
* Runs assertions for the preset filters form level validations.
*
Expand Down Expand Up @@ -320,6 +325,12 @@ public function assertListPagePresetFilters(string $default_value_name_prefix):
$expected_set_filters['body'] = ['key' => 'Body', 'value' => 'cherry'];
$this->assertDefaultValueForFilters($expected_set_filters);

// Assert the Edit and Remove buttons are in the right place.
$edit = $this->getSession()->getPage()->find('css', '.default-filters-table td input[name="default-edit-' . $body_filter_id . '"]');
$this->assertEquals('Edit', $edit->getValue());
$delete = $this->getSession()->getPage()->find('css', '.default-filters-table td input[name="default-delete-' . $body_filter_id . '"]');
$this->assertEquals('Delete', $delete->getValue());

// Set preset filter for Created.
$page->selectFieldOption('Add default value for', 'Created');
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down
Loading

0 comments on commit 2228fe2

Please sign in to comment.