Skip to content

Commit

Permalink
Merge pull request #296 from openeuropa/EWPP-307
Browse files Browse the repository at this point in the history
EWPP-307: Project content type fixes.
  • Loading branch information
ademarco authored Sep 29, 2020
2 parents 73ba1aa + b228c03 commit 785fa45
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ entity_type: node
bundle: oe_project
label: 'Project locations'
description: ''
required: false
required: true
translatable: false
default_value: { }
default_value_callback: ''
Expand Down
13 changes: 13 additions & 0 deletions tests/Behat/Content/Contact/GeneralContactContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@

use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\Tests\oe_content\Behat\Hook\Scope\BeforeParseEntityFieldsScope;
use Drupal\Tests\oe_content\Traits\EntityLoadingTrait;
use Drupal\Tests\oe_content\Traits\EntityReferenceTrait;

/**
* Context to create general contact corporate entities.
*/
class GeneralContactContext extends RawDrupalContext {

use EntityReferenceTrait;
use EntityLoadingTrait;

/**
* Run before fields are parsed by Drupal Behat extension.
*
Expand All @@ -28,6 +33,8 @@ public function alterGeneralContactFields(BeforeParseEntityFieldsScope $scope):
'Organisation' => 'oe_organisation',
'Address' => 'oe_address',
'Email' => 'oe_email',
'Image' => 'oe_image',
'Image caption' => 'oe_image:caption',
'Phone number' => 'oe_phone',
'Mobile number' => 'oe_mobile',
'Fax number' => 'oe_fax',
Expand All @@ -39,6 +46,12 @@ public function alterGeneralContactFields(BeforeParseEntityFieldsScope $scope):

foreach ($scope->getFields() as $key => $value) {
switch ($key) {
// Set Media entity reference fields.
case 'Image':
$fields = $this->getReferenceField($mapping[$key], 'media', $value);
$scope->addFields($fields)->removeField($key);
break;

case 'Published':
$scope->addFields([
$mapping[$key] => (int) ($value === 'Yes'),
Expand Down
13 changes: 13 additions & 0 deletions tests/Behat/Content/Contact/PressContactContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@

use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\Tests\oe_content\Behat\Hook\Scope\BeforeParseEntityFieldsScope;
use Drupal\Tests\oe_content\Traits\EntityLoadingTrait;
use Drupal\Tests\oe_content\Traits\EntityReferenceTrait;

/**
* Context to create press contact corporate entities.
*/
class PressContactContext extends RawDrupalContext {

use EntityReferenceTrait;
use EntityLoadingTrait;

/**
* Run before fields are parsed by Drupal Behat extension.
*
Expand All @@ -28,6 +33,8 @@ public function alterPressContactFields(BeforeParseEntityFieldsScope $scope): vo
'Organisation' => 'oe_organisation',
'Address' => 'oe_address',
'Email' => 'oe_email',
'Image' => 'oe_image',
'Image caption' => 'oe_image:caption',
'Phone number' => 'oe_phone',
'Mobile number' => 'oe_mobile',
'Fax number' => 'oe_fax',
Expand All @@ -39,6 +46,12 @@ public function alterPressContactFields(BeforeParseEntityFieldsScope $scope): vo

foreach ($scope->getFields() as $key => $value) {
switch ($key) {
// Set Media entity reference fields.
case 'Image':
$fields = $this->getReferenceField($mapping[$key], 'media', $value);
$scope->addFields($fields)->removeField($key);
break;

case 'Published':
$scope->addFields([
$mapping[$key] => (int) ($value === 'Yes'),
Expand Down

0 comments on commit 785fa45

Please sign in to comment.