Open Raphhh opened 8 years ago
Maybe there is a dedicated method for working with multiselects?
@aik099 the code of the method will work fine with multiple selects in WebAssert (the builtin step from MinkExtension will not as it cannot build an array here, but a custom step could define the array). The issue in WebAssert is only in the generated error message.
So I suggest we support array values when building the string representation here (probably just using implode(', ', $value)
when it is an array). There is no need to create a dedicated method doing the same assertion except for the error message building.
Agreed.
@stof
Warning: preg_match() expects parameter 2 to be string, array given in vendor/behat/mink/src/WebAssert.php
ex:
if (is_array($actual)) {
$actual = implode(',', $actual);
}
When I use the assert "assertFieldContains" on an element "select" with attribute "multiple", I have this error:
Notice: Array to string conversion in vendor/behat/mink/src/WebAssert.php line 678
This error correspond to the method
WebAssert::fieldValueEquals()
:$message = sprintf('The field "%s" value is "%s", but "%s" expected.', $field, $actual, $value);
$actual
is an array, not a string as for a simple select.Example:
Spec:
PHP 5.6.22 "behat/behat": "^3.0", "behat/mink": "^1.7", "behat/mink-extension": "^2.2",