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 62974c029..7e3591913 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php @@ -55,18 +55,47 @@ class CmsFormsContext extends BehatContext } /** - * @When /^I fill in the content form with "([^"]*)"$/ + * @When /^I fill in the "(?P([^"]*))" HTML field with "(?P([^"]*))"$/ + * @When /^I fill in "(?P([^"]*))" for the "(?P([^"]*))" HTML field$/ */ - public function stepIFillInTheContentFormWith($content) + public function stepIFillInTheHtmlFieldWith($field, $value) { - $this->getSession()->evaluateScript("tinyMCE.get('Form_EditForm_Content').setContent('$content')"); + $page = $this->getSession()->getPage(); + $inputField = $page->findField($field); + assertNotNull($inputField, sprintf('HTML field "%s" not found', $field)); + + $this->getSession()->evaluateScript(sprintf( + "jQuery('#%s').entwine('ss').getEditor().setContent('%s')", + $inputField->getAttribute('id'), + addcslashes($value, "'") + )); } /** - * @Then /^the content form should contain "([^"]*)"$/ + * @When /^I append "(?P([^"]*))" to the "(?P([^"]*))" HTML field$/ */ - public function theContentFormShouldContain($content) + public function stepIAppendTotheHtmlField($field, $value) { - $this->getMainContext()->assertElementContains('#Form_EditForm_Content', $content); + $page = $this->getSession()->getPage(); + $inputField = $page->findField($field); + assertNotNull($inputField, sprintf('HTML field "%s" not found', $field)); + + $this->getSession()->evaluateScript(sprintf( + "jQuery('#%s').entwine('ss').getEditor().insertContent('%s')", + $inputField->getAttribute('id'), + addcslashes($value, "'") + )); + } + + /** + * @Then /^the "(?P([^"]*))" HTML field should contain "(?P([^"]*))"$/ + */ + public function theHtmlFieldShouldContain($field, $value) + { + $page = $this->getSession()->getPage(); + $inputField = $page->findField($field); + assertNotNull($inputField, sprintf('HTML field "%s" not found', $field)); + + $this->getMainContext()->assertElementContains('#' . $inputField->getAttribute('id'), $value); } }