Skip to content

Instantly share code, notes, and snippets.

@Quilted
Created January 17, 2014 02:46
Show Gist options
  • Save Quilted/8467599 to your computer and use it in GitHub Desktop.
Save Quilted/8467599 to your computer and use it in GitHub Desktop.
Behat: Support taxonomy term entity references when creating new nodes during testing. Edit vender/drupal/drupalextension/src/Drupal/Driver/Core/Drupal7.php in function exandEntityFields().
// Special handling for entity references.
elseif ('entityreference' === $info['module']) {
$values = explode(',', $value);
// Handle taxonomy terms.
// @todo generalize.
if ($info['settings']['target_type'] == 'taxonomy_term') {
$i = 0;
foreach ($values as $tid) {
$new_entity->{$param}[LANGUAGE_NONE][$i]['target_id'] = $tid;
$i++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment