palantirnet / palantir-behat-extension

Additional step definitions for testing Drupal sites using Behat.
1 stars 4 forks source link

Assert entity field value fails #13

Closed patrickfweston closed 8 years ago

patrickfweston commented 8 years ago

After updating the Palantir Behat Extension in my project, when running the Behat test And entity field ":field" should contain ":value", the following error is thrown:

I believe I have traced down the problem to a specific commit that updated the syntax to meet coding standards: https://github.com/palantirnet/palantir-behat-extension/commit/c3db3c633696cc226fbadf505b7275915c067ee1#diff-8ffb0019c702b772d868f118a4621955R167 (Line 167 of EntityDataContext.php for commit c3db3c633696cc226fbadf505b7275915c067ee1)

Potential Solution

Line 163 of the above file also seems strange to me:

if (is_array($field_value) === true) {
  $field_value = array($field_value);
}

I may be reading this wrong, but the if statement checks if _$fieldvalue is an array and if it is makes it an array? Changing this to:

if (is_array($field_value) === false) {
  $field_value = array($field_value);
}

fixes my issue.

Update: I think this was translated from:

$field_value = is_array($field_value) ? $field_value : array($field_value);

with the check being backward.

patrickfweston commented 8 years ago

I created a PR with the fix: https://github.com/palantirnet/palantir-behat-extension/pull/14

becw commented 8 years ago

You got it.