diff --git a/features/field_handlers.feature b/features/field_handlers.feature index bb54e342..b6d6ab8c 100644 --- a/features/field_handlers.feature +++ b/features/field_handlers.feature @@ -110,7 +110,7 @@ Feature: FieldHandlers And I should see "150-0040" @d7 @d8 - Scenario: Test various user field handlers in Drupal 7 + Scenario: Test various user field handlers in Drupal 7. Given "tags" terms: | name | | Tag one | @@ -122,11 +122,13 @@ Feature: FieldHandlers | Page three | And users: | name | mail | field_tags | field_post_reference | field_post_address | + | Jane Doe | | | | | | John Doe | john@doe.com | Tag one, Tag two | Page one, Page two | country: BE - locality: Brussel - thoroughfare: Louisalaan 1 - postal_code: 1000 | And I am logged in as a user with the "administrator" role When I visit "admin/people" - Then I should see the link "John Doe" - And I click "John Doe" + Then I should see the link "Jane Doe" + And I should see the link "John Doe" + When I click "John Doe" Then I should see the link "Tag one" And I should see the link "Tag two" But I should not see the link "Tag three" @@ -163,11 +165,21 @@ Feature: FieldHandlers | title | body | promote | field_tags | | Article by Joe | PLACEHOLDER BODY | 1 | Tag one, Tag two, Tag three | | Article by Mike | PLACEHOLDER BODY | 1 | Tag four | + | Article by Jane | | | | + And I am logged in as a user with the "administrator" role + When I visit "admin/content" + Then I should see the link "Article by Joe" + And I should see the link "Article by Mike" + And I should see the link "Article by Jane" When I am on the homepage Then I should see the link "Article by Joe" And I should see the link "Tag one" And I should see the link "Tag two" And I should see the link "Tag three" + And I should see the link "Article by Mike" + And I should see the link "Tag four" + And I should see the link "Article by Joe" + And I should not see the link "Article by Jane" @d7 # There is no support for date ranges in D8 yet, so only test D7 for now. diff --git a/src/Drupal/DrupalExtension/Context/RawDrupalContext.php b/src/Drupal/DrupalExtension/Context/RawDrupalContext.php index 7ef8ac30..f6e07106 100644 --- a/src/Drupal/DrupalExtension/Context/RawDrupalContext.php +++ b/src/Drupal/DrupalExtension/Context/RawDrupalContext.php @@ -390,13 +390,22 @@ public function parseEntityFields($entity_type, \stdClass $entity) { // Replace regular fields inline in the entity after parsing. if (!$is_multicolumn) { $entity->$field_name = $values; + // Don't specify any value if the step author has left it blank. + if ($field_value === '') { + unset($entity->$field_name); + } } } } // Add the multicolumn fields to the entity. foreach ($multicolumn_fields as $field_name => $columns) { - $entity->$field_name = $columns; + // Don't specify any value if the step author has left it blank. + if (count(array_filter($columns, function ($var) { + return ($var !== ''); + })) > 0) { + $entity->$field_name = $columns; + } } }