context = $parameters; } /** * Get Mink session from MinkContext */ public function getSession($name = null) { return $this->getMainContext()->getSession($name); } /** * @Then /^I should see an edit page form$/ */ public function stepIShouldSeeAnEditPageForm() { $page = $this->getSession()->getPage(); $form = $page->find('css', '#Form_EditForm'); assertNotNull($form, 'I should see an edit page form'); } /** * @When /^I fill in the "(?P([^"]*))" HTML field with "(?P([^"]*))"$/ * @When /^I fill in "(?P([^"]*))" for the "(?P([^"]*))" HTML field$/ */ public function stepIFillInTheHtmlFieldWith($field, $value) { $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, "'") )); } /** * @When /^I append "(?P([^"]*))" to the "(?P([^"]*))" HTML field$/ */ public function stepIAppendTotheHtmlField($field, $value) { $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()->assertSession()->elementContains( 'named', $field, str_replace('\\"', '"', $value) // emulates fixStepArgument() ); } /** * @Given /^I should see a "([^"]*)" button$/ */ public function iShouldSeeAButton($text) { $page = $this->getSession()->getPage(); $els = $page->findAll('named', array('link_or_button', "'$text'")); $matchedEl = null; foreach($els as $el) { if($el->isVisible()) $matchedEl = $el; } assertNotNull($matchedEl, sprintf('%s button not found', $text)); } /** * @Given /^I should not see a "([^"]*)" button$/ */ public function iShouldNotSeeAButton($text) { $page = $this->getSession()->getPage(); $els = $page->findAll('named', array('link_or_button', "'$text'")); $matchedEl = null; foreach($els as $el) { if($el->isVisible()) $matchedEl = $el; } assertNull($matchedEl, sprintf('%s button found', $text)); } }