MDL-37858 behat: Removing fixStepArgument
It can be managed by a @Transform in a centralized way
This commit is contained in:
@@ -83,9 +83,6 @@ class behat_course extends behat_base {
|
||||
*/
|
||||
public function i_add_to_section($activity, $section) {
|
||||
|
||||
$activity = $this->fixStepArgument($activity);
|
||||
$section = $this->fixStepArgument($section);
|
||||
|
||||
// Clicks add activity or resource section link.
|
||||
$sectionxpath = "//*[@id='section-" . $section . "']/*/*/*/div[@class='section-modchooser']/span/a";
|
||||
$sectionnode = $this->find('xpath', $sectionxpath);
|
||||
|
||||
@@ -51,21 +51,6 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
|
||||
*/
|
||||
const TIMEOUT = 6;
|
||||
|
||||
/**
|
||||
* Returns fixed step argument (with \\" replaced back to ").
|
||||
*
|
||||
* \\ is the chars combination to add when you
|
||||
* want to escape the " character that is used as var
|
||||
* delimiter.
|
||||
*
|
||||
* @see Behat\MinkExtension\Context\MinkContext
|
||||
* @param string $argument
|
||||
* @return string
|
||||
*/
|
||||
protected function fixStepArgument($argument) {
|
||||
return str_replace('\\"', '"', $argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates url, based on provided path.
|
||||
* Override to provide custom routing mechanism.
|
||||
|
||||
@@ -52,7 +52,6 @@ class behat_forms extends behat_base {
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function press_button($button) {
|
||||
$button = $this->fixStepArgument($button);
|
||||
|
||||
// Ensures the button is present.
|
||||
$buttonnode = $this->find_button($button);
|
||||
@@ -75,9 +74,6 @@ class behat_forms extends behat_base {
|
||||
|
||||
unset($fieldnode);
|
||||
|
||||
// Removing \\ that escapes " of the steps arguments.
|
||||
$locator = $this->fixStepArgument($locator);
|
||||
|
||||
// Getting the NodeElement.
|
||||
$fieldnode = $this->find_field($locator);
|
||||
|
||||
@@ -85,7 +81,6 @@ class behat_forms extends behat_base {
|
||||
$field = $this->get_field($fieldnode, $locator);
|
||||
|
||||
// Delegates to the field class.
|
||||
$value = $this->fixStepArgument($value);
|
||||
$field->set_value($value);
|
||||
}
|
||||
}
|
||||
@@ -97,8 +92,6 @@ class behat_forms extends behat_base {
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function fill_field($field, $value) {
|
||||
$field = $this->fixStepArgument($field);
|
||||
$value = $this->fixStepArgument($value);
|
||||
|
||||
$fieldnode = $this->find_field($field);
|
||||
$fieldnode->setValue($value);
|
||||
@@ -111,8 +104,6 @@ class behat_forms extends behat_base {
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function select_option($option, $select) {
|
||||
$select = $this->fixStepArgument($select);
|
||||
$option = $this->fixStepArgument($option);
|
||||
|
||||
$selectnode = $this->find_field($select);
|
||||
$selectnode->selectOption($option);
|
||||
@@ -128,7 +119,6 @@ class behat_forms extends behat_base {
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function check_option($option) {
|
||||
$option = $this->fixStepArgument($option);
|
||||
|
||||
$checkboxnode = $this->find_field($option);
|
||||
$checkboxnode->check();
|
||||
@@ -141,7 +131,6 @@ class behat_forms extends behat_base {
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function uncheck_option($option) {
|
||||
$option = $this->fixStepArgument($option);
|
||||
|
||||
$checkboxnode = $this->find_field($option);
|
||||
$checkboxnode->uncheck();
|
||||
@@ -158,9 +147,6 @@ class behat_forms extends behat_base {
|
||||
*/
|
||||
public function the_field_should_match_value($locator, $value) {
|
||||
|
||||
$locator = $this->fixStepArgument($locator);
|
||||
$value = $this->fixStepArgument($value);
|
||||
|
||||
$fieldnode = $this->find_field($locator);
|
||||
|
||||
// Gets the field instance.
|
||||
@@ -182,7 +168,6 @@ class behat_forms extends behat_base {
|
||||
* @see Behat\MinkExtension\Context\MinkContext
|
||||
*/
|
||||
public function assert_checkbox_checked($checkbox) {
|
||||
$checkbox = $this->fixStepArgument($checkbox);
|
||||
$this->assertSession()->checkboxChecked($checkbox);
|
||||
}
|
||||
|
||||
@@ -193,7 +178,6 @@ class behat_forms extends behat_base {
|
||||
* @see Behat\MinkExtension\Context\MinkContext
|
||||
*/
|
||||
public function assert_checkbox_not_checked($checkbox) {
|
||||
$checkbox = $this->fixStepArgument($checkbox);
|
||||
$this->assertSession()->checkboxNotChecked($checkbox);
|
||||
}
|
||||
|
||||
@@ -208,9 +192,6 @@ class behat_forms extends behat_base {
|
||||
*/
|
||||
public function the_select_box_should_contain($select, $option) {
|
||||
|
||||
$select = $this->fixStepArgument($select);
|
||||
$option = $this->fixStepArgument($option);
|
||||
|
||||
$selectnode = $this->find_field($select);
|
||||
|
||||
$regex = '/' . preg_quote($option, '/') . '/ui';
|
||||
@@ -234,9 +215,6 @@ class behat_forms extends behat_base {
|
||||
*/
|
||||
public function the_select_box_should_not_contain($select, $option) {
|
||||
|
||||
$select = $this->fixStepArgument($select);
|
||||
$option = $this->fixStepArgument($option);
|
||||
|
||||
$selectnode = $this->find_field($select);
|
||||
|
||||
$regex = '/' . preg_quote($option, '/') . '/ui';
|
||||
@@ -258,8 +236,6 @@ class behat_forms extends behat_base {
|
||||
protected function get_field(NodeElement $fieldnode, $locator) {
|
||||
global $CFG;
|
||||
|
||||
$locator = $this->fixStepArgument($locator);
|
||||
|
||||
// Get the field type.
|
||||
$type = $this->get_node_type($fieldnode, $locator);
|
||||
$classname = 'behat_form_' . $type;
|
||||
@@ -289,8 +265,6 @@ class behat_forms extends behat_base {
|
||||
*/
|
||||
protected function get_node_type(NodeElement $fieldnode, $locator) {
|
||||
|
||||
$locator = $this->fixStepArgument($locator);
|
||||
|
||||
// We look for a parent node with 'felement' class.
|
||||
if ($class = $fieldnode->getParent()->getAttribute('class')) {
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ class behat_general extends behat_base {
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function click_link($link) {
|
||||
$link = $this->fixStepArgument($link);
|
||||
|
||||
$linknode = $this->find_link($link);
|
||||
$linknode->click();
|
||||
@@ -109,7 +108,7 @@ class behat_general extends behat_base {
|
||||
* @Then /^I should see "(?P<text_string>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
public function assert_page_contains_text($text) {
|
||||
$this->assertSession()->pageTextContains($this->fixStepArgument($text));
|
||||
$this->assertSession()->pageTextContains($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +118,7 @@ class behat_general extends behat_base {
|
||||
* @Then /^I should not see "(?P<text_string>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
public function assert_page_not_contains_text($text) {
|
||||
$this->assertSession()->pageTextNotContains($this->fixStepArgument($text));
|
||||
$this->assertSession()->pageTextNotContains($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +127,7 @@ class behat_general extends behat_base {
|
||||
* @Then /^I should see "(?P<text_string>(?:[^"]|\\")*)" in the "(?P<element_string>(?:[^"]|\\")*)" element$/
|
||||
*/
|
||||
public function assert_element_contains_text($text, $element) {
|
||||
$this->assertSession()->elementTextContains('css', $element, $this->fixStepArgument($text));
|
||||
$this->assertSession()->elementTextContains('css', $element, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +136,7 @@ class behat_general extends behat_base {
|
||||
* @Then /^I should not see "(?P<text_string>(?:[^"]|\\")*)" in the "(?P<element_string>(?:[^"]|\\")*)" element$/
|
||||
*/
|
||||
public function assert_element_not_contains_text($text, $element) {
|
||||
$this->assertSession()->elementTextNotContains('css', $element, $this->fixStepArgument($text));
|
||||
$this->assertSession()->elementTextNotContains('css', $element, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,8 +47,6 @@ class behat_navigation extends behat_base {
|
||||
*/
|
||||
public function i_expand_node($nodetext) {
|
||||
|
||||
$nodetext = $this->fixStepArgument($nodetext);
|
||||
|
||||
$xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]
|
||||
/descendant::li
|
||||
/descendant::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]
|
||||
|
||||
Reference in New Issue
Block a user