The ArrayMatcher does not match inside an existing string
thomasbisignani opened this issue · 3 comments
thomasbisignani commented
Hello,
The ArrayMatcher
does not match inside an existing string.
Examples with this following code :
$value = [
'foo' => "http://foo.com/bar"
];
if (!PHPMatcher::match($value, $pattern, $error)) {
echo $error;
} else {
echo "Matched.";
}
This pattern works :
$pattern = [
'foo' => '@string@'
];
Result:
Matched.
This pattern does not work :
$pattern = [
'foo' => 'http://foo.com/@string@'
];
Result:
"http://foo.com/bar" does not match "http://foo.com/@string@".
norberttech commented
http://foo.com/bar
should match @string@.startsWith("http://foo.com/")
thomasbisignani commented
Yes, in our projects we used the @string@.startsWith()
pattern expander.
But we can't match for example these patterns :
http://foo.com/@uuid@
- or more interesting :
http://foo.com/@string@/@uuid@
IMO, that would be very interesting for Behat tests.
norberttech commented
Agree, feel free to open PR! 🍻