Mink
Mink copied to clipboard
Add case-sensitive comparison option to function WebAssert::elementContains
Now function WebAssert::responseContains
does comparison in case-insensitive mode because of usage stripos
php function:
https://github.com/minkphp/Mink/blob/34c0ae0dff39b0ebfc3b028e66b60943e1bed4ce/src/WebAssert.php#L319-L325
And I see no ways to make case-sensitive comparison. So will be good to add option to enable case-sensitive comparison mode via some option. Or it is already exists, please point me out to the solution.
And will be good to explain that this function does case-sensitive comparison by default, because it is a surprise for many developers. For example, this nuance brings that issue in Drupal module: https://www.drupal.org/project/layout_builder_restrictions/issues/3278651
@MurzNN , the WebAssert::responseContains
is indeed case-insensitive and, as far as I can remember, it always was. Probably the DocBlock could be improved to reflect that behavior. The same goes for the \Behat\Mink\WebAssert::responseNotContains
method.
As for the mentioned Drupal issue, you can use the \Behat\Mink\WebAssert::responseMatches
method to do a case-sensitive comparison.
By the way, the Drupal issue uses the \Behat\Mink\WebAssert::elementContains
method currently, which is also, as the majority of assertion methods, case-insensitive.
Yeah, sorry, I've mixed up elementContains
and responseContains
when creating issue!
So, for \Mink\WebAssert::responseContains
we have \Behat\Mink\WebAssert::responseMatches
alternative, that supports regexp and can do a case-sensitive comparison.
But seems we have no similar function \Behat\Mink\WebAssert::elementMatches
, so what is the solution for \Behat\Mink\WebAssert::elementContains
to make a case-sensitive comparison?
What do you think about adding third non-required argument like this to enable case-sensitive comparison, like this https://github.com/minkphp/Mink/pull/830/files ?
If it's ok, I can expand it to all other *Contains()
functions.
Let's wait for @stof opinion on this.
Looking back at the source of all this case-sensitivity issue/PR (checking Restricted
vs Unrestricted
) I'm starting to think, that it's not worth it. As you've suggested altering the project code, that uses Mink, is enough to make the test pass.
@stof, can you please give a short message about your opinion on this?