Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Behat generates proper snippets for arguments followed by non-word ch…

…aracter
  • Loading branch information...
commit 932b5ca9884ae1cbcf9aed6e2cbbc209916f6b0c 1 parent 68e56f0
Konstantin Kudryashov everzet authored
6 src/Behat/Behat/Definition/Pattern/Policy/RegexPatternPolicy.php
View
@@ -24,9 +24,9 @@ class RegexPatternPolicy implements PatternPolicy
* @var string[string]
*/
private static $replacePatterns = array(
- "/(?<= |^)\\\'(?:((?!\\').)*)\\\'(?= |$)/" => "\\'([^\']*)\\'", // Single quoted strings
- '/(?<= |^)\"(?:[^\"]*)\"(?= |$)/' => "\"([^\"]*)\"", // Double quoted strings
- '/(\d+)/' => "(\\d+)", // Numbers
+ "/(?<=\W|^)\\\'(?:((?!\\').)*)\\\'(?=\W|$)/" => "'([^']*)'", // Single quoted strings
+ '/(?<=\W|^)\"(?:[^\"]*)\"(?=\W|$)/' => "\"([^\"]*)\"", // Double quoted strings
+ '/(?<=\W|^)(\d+)(?=\W|$)/' => "(\\d+)", // Numbers
);
/**
8 src/Behat/Behat/Definition/Pattern/Policy/TurnipPatternPolicy.php
View
@@ -28,9 +28,9 @@ class TurnipPatternPolicy implements PatternPolicy
* @var string[]
*/
private static $placeholderPatterns = array(
- "/(?<=\s|^)\"[^\"]+\"(?=\s|$)/",
- "/(?<=\s|^)'[^']+'(?=\s|$)/",
- "/(?<=\s|^)\d+/"
+ "/(?<=\W|^)\"[^\"]+\"(?=\W|$)/",
+ "/(?<=\W|^)'[^']+'(?=\W|$)/",
+ "/(?<=\W|^)\d+(?=\W|$)/"
);
/**
@@ -82,7 +82,7 @@ public function transformPatternToRegex($pattern)
self::PLACEHOLDER_REGEXP,
function ($match) {
return sprintf(
- "[\"']?(?P<%s>(?<=\")[^\"]+(?=\")|(?<=')[^']+(?=')|(?<=\s)\w+(?=\s|$))['\"]?",
+ "[\"']?(?P<%s>(?<=\")[^\"]+(?=\")|(?<=')[^']+(?=')|(?<=\W)\w+(?=\W|$))['\"]?",
$match[1]
);
},
Please sign in to comment.
Something went wrong with that request. Please try again.