Navigation Menu

Skip to content

Commit

Permalink
Behat generates proper snippets for arguments followed by non-word ch…
Browse files Browse the repository at this point in the history
…aracter
  • Loading branch information
everzet committed Feb 11, 2014
1 parent 68e56f0 commit 932b5ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Expand Up @@ -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
);

/**
Expand Down
Expand Up @@ -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|$)/"
);

/**
Expand Down Expand Up @@ -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]
);
},
Expand Down

0 comments on commit 932b5ca

Please sign in to comment.