diff --git a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php index 144d28fdd..f046a70ed 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php @@ -44,6 +44,17 @@ class CmsFormsContext extends BehatContext { return $this->getMainContext()->getSession($name); } + /** + * Returns fixed step argument (with \\" replaced back to "). + * Copied from {@see MinkContext} + * + * @param string $argument + * @return string + */ + protected function fixStepArgument($argument) { + return str_replace('\\"', '"', $argument); + } + /** * @Then /^I should( not? |\s*)see an edit page form$/ */ @@ -63,8 +74,8 @@ class CmsFormsContext extends BehatContext { * @When /^I fill in "(?P(?:[^"]|\\")*)" for the "(?P(?:[^"]|\\")*)" HTML field$/ */ public function stepIFillInTheHtmlFieldWith($field, $value) { - $field = MinkContext::fixStepArgument($field); - $value = MinkContext::fixStepArgument($value); + $field = $this->fixStepArgument($field); + $value = $this->fixStepArgument($value); $page = $this->getSession()->getPage(); $inputField = $page->findField($field); @@ -81,8 +92,8 @@ class CmsFormsContext extends BehatContext { * @When /^I append "(?P(?:[^"]|\\")*)" to the "(?P(?:[^"]|\\")*)" HTML field$/ */ public function stepIAppendTotheHtmlField($field, $value) { - $field = MinkContext::fixStepArgument($field); - $value = MinkContext::fixStepArgument($value); + $field = $this->fixStepArgument($field); + $value = $this->fixStepArgument($value); $page = $this->getSession()->getPage(); $inputField = $page->findField($field); @@ -99,7 +110,7 @@ class CmsFormsContext extends BehatContext { * @Then /^the "(?P(?:[^"]|\\")*)" HTML field should(?P not? |\s*)contain "(?P.*)"$/ */ public function theHtmlFieldShouldContain($locator, $negative, $html) { - $locator = MinkContext::fixStepArgument($locator); + $locator = $this->fixStepArgument($locator); $page = $this->getSession()->getPage(); $element = $page->findField($locator); assertNotNull($element, sprintf('HTML field "%s" not found', $locator)); @@ -143,7 +154,7 @@ class CmsFormsContext extends BehatContext { * @Given /^"(?P([^"]*))" in the "(?P(?:[^"]|\\")*)" HTML field should(?P(?: not)?) be (?P(.*))$/ */ public function stepContentInHtmlFieldShouldHaveFormatting($text, $field, $negate, $formatting) { - $field = MinkContext::fixStepArgument($field); + $field = $this->fixStepArgument($field); $page = $this->getSession()->getPage(); $inputField = $page->findField($field); assertNotNull($inputField, sprintf('HTML field "%s" not found', $field)); @@ -181,7 +192,7 @@ class CmsFormsContext extends BehatContext { * @When /^I select "(?P([^"]*))" in the "(?P(?:[^"]|\\")*)" HTML field$/ */ public function stepIHighlightTextInHtmlField($text, $field) { - $field = MinkContext::fixStepArgument($field); + $field = $this->fixStepArgument($field); $page = $this->getSession()->getPage(); $inputField = $page->findField($field); assertNotNull($inputField, sprintf('HTML field "%s" not found', $field));