Skip to content

Commit

Permalink
[TEST] Reconfigure regex parsing/matching
Browse files Browse the repository at this point in the history
Switched back to forward slash delimeters, but now includes extra
escaping for forward slashes.

There were just as many problems with the alternative delimeter, so
it seems that escaping is nescessary no matter which one is chosen.
Might as well use the default :)
  • Loading branch information
polyfractal committed May 8, 2014
1 parent 90aeea4 commit 3d8cc12
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ private function assertFalsey($value)
private function assertRegex($pattern, $actual) {
$pattern = trim($pattern);

// PHP doesn't like unescaped forward slashes, switch to a new delimeter
// to make life easier
// PHP doesn't like unescaped forward slashes
$pattern = substr($pattern, 1, strlen($pattern)-2);
$pattern = "%$pattern%mx";
$pattern = str_replace('/', '\/', $pattern);
$pattern = "/$pattern/mx";
echo "\n> pattern: $pattern\n";
ob_flush();
$result = preg_match($pattern, $actual, $matches);
$this->assertEquals(1, $result);
Expand Down

0 comments on commit 3d8cc12

Please sign in to comment.