Commit dedb9738 authored by David Monllaó's avatar David Monllaó Committed by David Monllao
Browse files

MDL-39635 behat: Replacing hardcoded language strings

Using get_string() instead.
parent 3194dc83
......@@ -62,7 +62,7 @@ class behat_admin extends behat_base {
}
// Search by label.
$searchbox = $this->find_field('Search in settings');
$searchbox = $this->find_field(get_string('searchinsettings', 'admin'));
$searchbox->setValue($label);
$submitsearch = $this->find('css', 'form.adminsearchform input[type=submit]');
$submitsearch->press();
......@@ -90,7 +90,7 @@ class behat_admin extends behat_base {
$field = behat_field_manager::get_field_instance($type, $fieldnode, $this->getSession());
$field->set_value($value);
$this->find_button('Save changes')->press();
$this->find_button(get_string('savechanges'))->press();
}
}
......
......@@ -49,10 +49,10 @@ class behat_auth extends behat_base {
public function i_log_in_as($username) {
return array(new Given('I am on homepage'),
new Given('I follow "Log in"'),
new Given('I fill in "Username" with "'.$username.'"'),
new Given('I fill in "Password" with "'.$username.'"'),
new Given('I press "Log in"')
new Given('I follow "' . get_string('login') . '"'),
new Given('I fill in "' . get_string('username') . '" with "'.$username.'"'),
new Given('I fill in "' . get_string('password') . '" with "'.$username.'"'),
new Given('I press "' . get_string('login') . '"')
);
}
......@@ -62,7 +62,7 @@ class behat_auth extends behat_base {
* @Given /^I log out$/
*/
public function i_log_out() {
return new When('I follow "Log out"');
return new When('I follow "' . get_string('logout') . '"');
}
}
......@@ -61,25 +61,25 @@ class behat_backup extends behat_base {
$this->find_link($backupcourse)->click();
// Click the backup link.
$this->find_link('Backup')->click();
$this->find_link(get_string('backup'))->click();
// Initial settings.
$this->fill_backup_restore_form($options);
$this->find_button('Next')->press();
$this->find_button(get_string('backupstage1action', 'backup'))->press();
// Schema settings.
$this->fill_backup_restore_form($options);
$this->find_button('Next')->press();
$this->find_button(get_string('backupstage2action', 'backup'))->press();
// Confirmation and review, backup filename can also be specified.
$this->fill_backup_restore_form($options);
$this->find_button('Perform backup')->press();
$this->find_button(get_string('backupstage4action', 'backup'))->press();
// Waiting for it to finish.
$this->wait(10);
// Last backup continue button.
$this->find_button('Continue')->press();
$this->find_button(get_string('backupstage16action', 'backup'))->press();
}
/**
......@@ -106,7 +106,7 @@ class behat_backup extends behat_base {
$this->find_link($tocourse)->click();
// Click the backup link.
$this->find_link('Import')->click();
$this->find_link(get_string('import'))->click();
// Select the course.
$exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', $this->getSession());
......@@ -119,22 +119,22 @@ class behat_backup extends behat_base {
$radionode->check();
$radionode->click();
$this->find_button('Continue')->press();
$this->find_button(get_string('continue'))->press();
// Initial settings.
$this->fill_backup_restore_form($options);
$this->find_button('Next')->press();
$this->find_button(get_string('importbackupstage1action', 'backup'))->press();
// Schema settings.
$this->fill_backup_restore_form($options);
$this->find_button('Next')->press();
$this->find_button(get_string('importbackupstage2action', 'backup'))->press();
// Run it.
$this->find_button('Perform import')->press();
$this->find_button(get_string('importbackupstage4action', 'backup'))->press();
$this->wait();
// Continue and redirect to 'to' course.
$this->find_button('Continue')->press();
$this->find_button(get_string('continue'))->press();
}
/**
......@@ -160,7 +160,8 @@ class behat_backup extends behat_base {
$radionode->click();
// Pressing the continue button of the restore into an existing course section.
$continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-existing-course')]/descendant::input[@type='submit'][@value='Continue']");
$continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-existing-course')]" .
"/descendant::input[@type='submit'][@value='" . get_string('continue') . "']");
$continuenode->click();
$this->wait();
......@@ -188,7 +189,8 @@ class behat_backup extends behat_base {
$radionode->click();
// Pressing the continue button of the restore into an existing course section.
$continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-new-course')]/descendant::input[@type='submit'][@value='Continue']");
$continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-new-course')]" .
"/descendant::input[@type='submit'][@value='" . get_string('continue') . "']");
$continuenode->click();
$this->wait();
......@@ -216,7 +218,7 @@ class behat_backup extends behat_base {
// Pressing the continue button of the restore merging section.
$continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]" .
"/descendant::input[@type='submit'][@value='Continue']");
"/descendant::input[@type='submit'][@value='" . get_string('continue') . "']");
$continuenode->click();
$this->wait();
......@@ -244,7 +246,7 @@ class behat_backup extends behat_base {
// Pressing the continue button of the restore merging section.
$continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]" .
"/descendant::input[@type='submit'][@value='Continue']");
"/descendant::input[@type='submit'][@value='" . get_string('continue') . "']");
$continuenode->click();
$this->wait();
......@@ -263,12 +265,12 @@ class behat_backup extends behat_base {
// Using xpath as there are other restore links before this one.
$exception = new ExpectationException('The "' . $backupfilename . '" backup file can not be found in this page', $this->getSession());
$xpath = "//tr[contains(., '" . $backupfilename . "')]/descendant::a[contains(., 'Restore')]";
$xpath = "//tr[contains(., '" . $backupfilename . "')]/descendant::a[contains(., '" . get_string('restore') . "')]";
$restorelink = $this->find('xpath', $xpath, $exception);
$restorelink->click();
// Confirm the backup contents.
$restore = $this->find_button('Continue')->press();
$restore = $this->find_button(get_string('continue'))->press();
}
/**
......@@ -284,18 +286,18 @@ class behat_backup extends behat_base {
// Settings.
$this->fill_backup_restore_form($options);
$this->find_button('Next')->press();
$this->find_button(get_string('restorestage4action', 'backup'))->press();
// Schema.
$this->fill_backup_restore_form($options);
$this->find_button('Next')->press();
$this->find_button(get_string('restorestage8action', 'backup'))->press();
// Review, no options here.
$this->find_button('Perform restore')->press();
$this->find_button(get_string('restorestage16action', 'backup'))->press();
$this->wait(10);
// Last restore continue button, redirected to restore course after this.
$this->find_button('Continue')->press();
$this->find_button(get_string('restorestage32action', 'backup'))->press();
}
/**
......
......@@ -63,7 +63,7 @@ class behat_block_comments extends behat_base {
$commentstextarea = $this->find('css', '.comment-area textarea', $exception);
$commentstextarea->setValue($comment);
$this->find_link('Save comment')->click();
$this->find_link(get_string('savecomment'))->click();
// Wait for the AJAX request.
$this->getSession()->wait(4 * 1000, false);
......
......@@ -52,7 +52,7 @@ class behat_blocks extends behat_base {
if (!$this->running_javascript()) {
$steps = array(
$steps,
new Given('I click on "Go" "button" in the "#add_block" "css_element"')
new Given('I click on "' . get_string('go') . '" "button" in the "#add_block" "css_element"')
);
}
return $steps;
......
......@@ -54,10 +54,10 @@ class behat_cohort extends behat_base {
$userid = $DB->get_field('user', 'id', array('username' => $username));
$steps = array(
new Given('I click on "Assign" "link" in the "//table[@id=\'cohorts\']//tr[contains(., \'' . $cohortidnumber . '\')]" "xpath_element"'),
new Given('I select "' . $userid . '" from "Potential users"'),
new Given('I press "Add"'),
new Given('I press "Back to cohorts"')
new Given('I click on "' . get_string('assign', 'cohort') . '" "link" in the "//table[@id=\'cohorts\']//tr[contains(., \'' . $cohortidnumber . '\')]" "xpath_element"'),
new Given('I select "' . $userid . '" from "' . get_string('potusers', 'cohort') . '"'),
new Given('I press "' . get_string('add') . '"'),
new Given('I press "' . get_string('backtocohorts', 'cohort') . '"')
);
// If we are not in the cohorts management we should move there before anything else.
......@@ -65,11 +65,11 @@ class behat_cohort extends behat_base {
$steps = array_merge(
array(
new Given('I am on homepage'),
new Given('I collapse "Front page settings" node'),
new Given('I expand "Site administration" node'),
new Given('I expand "Users" node'),
new Given('I expand "Accounts" node'),
new Given('I follow "Cohorts"')
new Given('I collapse "' . get_string('frontpagesettings', 'admin') . '" node'),
new Given('I expand "' . get_string('administrationsite') . '" node'),
new Given('I expand "' . get_string('users', 'admin') . '" node'),
new Given('I expand "' . get_string('accounts', 'admin') . '" node'),
new Given('I follow "' . get_string('cohorts', 'cohort') . '"')
),
$steps
);
......
......@@ -92,12 +92,12 @@ class behat_completion extends behat_base {
$this->find('xpath', "//*[@id='settingsnav']" .
"/descendant::li" .
"/descendant::li[not(contains(@class,'collapsed'))]" .
"/descendant::p[contains(., 'Activity completion')]");
"/descendant::p[contains(., '" . get_string('pluginname', 'report_progress') . "')]");
} catch (ElementNotFoundException $e) {
$steps[] = new Given('I expand "Reports" node');
$steps[] = new Given('I expand "' . get_string('reports') . '" node');
}
$steps[] = new Given('I follow "Activity completion"');
$steps[] = new Given('I follow "' . get_string('pluginname', 'report_progress') . '"');
return $steps;
}
......
......@@ -48,7 +48,7 @@ class behat_course extends behat_base {
* @Given /^I turn editing mode on$/
*/
public function i_turn_editing_mode_on() {
return new Given('I press "Turn editing on"');
return new Given('I press "' . get_string('turneditingon') . '"');
}
/**
......@@ -56,7 +56,7 @@ class behat_course extends behat_base {
* @Given /^I turn editing mode off$/
*/
public function i_turn_editing_mode_off() {
return new Given('I press "Turn editing off"');
return new Given('I press "' . get_string('turneditingoff') . '"');
}
/**
......@@ -68,9 +68,9 @@ class behat_course extends behat_base {
public function i_create_a_course_with(TableNode $table) {
return array(
new Given('I go to the courses management page'),
new Given('I press "Add a new course"'),
new Given('I press "' . get_string('addnewcourse') . '"'),
new Given('I fill the moodle form with:', $table),
new Given('I press "Save changes"')
new Given('I press "' . get_string('savechanges') . '"')
);
}
......@@ -83,9 +83,9 @@ class behat_course extends behat_base {
return array(
new Given('I am on homepage'),
new Given('I expand "Site administration" node'),
new Given('I expand "Courses" node'),
new Given('I follow "Add/edit courses"'),
new Given('I expand "' . get_string('administrationsite') . '" node'),
new Given('I expand "' . get_string('courses', 'admin') . '" node'),
new Given('I follow "' . get_string('coursemgmt', 'admin') . '"'),
);
}
......@@ -102,7 +102,7 @@ class behat_course extends behat_base {
return array(
new Given('I add a "'.$activity.'" to section "'.$section.'"'),
new Given('I fill the moodle form with:', $data),
new Given('I press "Save and return to course"')
new Given('I press "' . get_string('savechangesandreturntocourse') . '"')
);
}
......@@ -765,8 +765,8 @@ class behat_course extends behat_base {
protected function is_course_editor() {
// We don't need to behat_base::spin() here as all is already loaded.
if (!$this->getSession()->getPage()->findButton('Turn editing off') &&
!$this->getSession()->getPage()->findButton('Turn editing on')) {
if (!$this->getSession()->getPage()->findButton(get_string('turneditingoff')) &&
!$this->getSession()->getPage()->findButton(get_string('turneditingon'))) {
return false;
}
......
......@@ -50,11 +50,11 @@ class behat_enrol extends behat_base {
public function i_add_enrolment_method_with($enrolmethod, TableNode $table) {
return array(
new Given('I expand "Users" node'),
new Given('I follow "Enrolment methods"'),
new Given('I select "' . $enrolmethod . '" from "Add method"'),
new Given('I expand "' . get_string('users', 'admin') . '" node'),
new Given('I follow "' . get_string('type_enrol_plural', 'plugin') . '"'),
new Given('I select "' . $enrolmethod . '" from "' . get_string('addinstance', 'enrol') . '"'),
new Given('I fill the moodle form with:', $table),
new Given('I press "Add method"')
new Given('I press "' . get_string('addinstance', 'enrol') . '"')
);
}
......
......@@ -80,7 +80,7 @@ class behat_groups extends behat_base {
$this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")');
// Returning to the main groups page.
$this->find_button('Back to groups')->click();
$this->find_button(get_string('backtogroups', 'group'))->click();
}
}
......@@ -52,14 +52,14 @@ class behat_permissions extends behat_base {
return array(
new Given('I am on homepage'),
new Given('I collapse "Front page settings" node'),
new Given('I expand "Site administration" node'),
new Given('I expand "Users" node'),
new Given('I expand "Permissions" node'),
new Given('I follow "Define roles"'),
new Given('I collapse "' . get_string('frontpagesettings', 'admin') . '" node'),
new Given('I expand "' . get_string('administrationsite') . '" node'),
new Given('I expand "' . get_string('users', 'admin') . '" node'),
new Given('I expand "' . get_string('permissions', 'role') . '" node'),
new Given('I follow "' . get_string('defineroles', 'role') . '"'),
new Given('I follow "Edit ' . $this->escape($rolename) . ' role"'),
new Given('I fill the capabilities form with the following permissions:', $table),
new Given('I press "Save changes"')
new Given('I press "' . get_string('savechanges') . '"')
);
}
......@@ -76,9 +76,9 @@ class behat_permissions extends behat_base {
$roleoption = $this->find('xpath', '//select[@name="roleid"]/option[contains(text(),"' . $this->escape($rolename) . '")]');
return array(
new Given('I select "' . $this->escape($roleoption->getText()) . '" from "Advanced role override"'),
new Given('I select "' . $this->escape($roleoption->getText()) . '" from "' . get_string('advancedoverride', 'role') . '"'),
new Given('I fill the capabilities form with the following permissions:', $table),
new Given('I press "Save changes"')
new Given('I press "' . get_string('savechanges') . '"')
);
}
......@@ -93,9 +93,9 @@ class behat_permissions extends behat_base {
// Ensure we are using the advanced view.
// Wrapped in a try/catch to capture the exception and continue execution, we don't know if advanced mode was already enabled.
try {
$advancedtoggle = $this->find_button('Show advanced');
$advancedtoggle = $this->find_button(get_string('showadvanced', 'form'));
if ($advancedtoggle) {
$this->getSession()->getPage()->pressButton('Show advanced');
$this->getSession()->getPage()->pressButton(get_string('showadvanced', 'form'));
}
} catch (Exception $e) {
// We already are in advanced mode.
......
......@@ -63,10 +63,10 @@ class behat_message extends behat_base {
$steps[] = new Given('I am on homepage');
if ($this->running_javascript()) {
$steps[] = new Given('I expand "My profile" node');
$steps[] = new Given('I expand "' . get_string('myprofile') . '" node');
}
$steps[] = new Given('I follow "Messages"');
$steps[] = new Given('I follow "' . get_string('messages', 'message') . '"');
$steps[] = new Given('I fill in "' . get_string('searchcombined', 'message') . '" with "' . $tofullname . '"');
$steps[] = new Given('I press "' . get_string('searchcombined', 'message') . '"');
$steps[] = new Given('I follow "' . get_string('sendmessageto', 'message', $tofullname) . '"');
......
......@@ -52,7 +52,7 @@ class behat_mod_choice extends behat_base {
return array(
new Given('I follow "' . $this->escape($choiceactivity) . '"'),
new Given('I select "' . $this->escape($option) . '" radio button'),
new Given('I press "Save my choice"')
new Given('I press "' . get_string('savemychoice', 'choice') . '"')
);
}
......
......@@ -51,9 +51,9 @@ class behat_mod_forum extends behat_base {
// Escaping $forumname as it has been stripped automatically by the transformer.
return array(
new Given('I follow "' . $this->escape($forumname) . '"'),
new Given('I press "' . get_string('addanewdiscussion', 'mod_forum') . '"'),
new Given('I press "' . get_string('addanewdiscussion', 'forum') . '"'),
new Given('I fill the moodle form with:', $table),
new Given('I press "' . get_string('posttoforum', 'mod_forum') . '"'),
new Given('I press "' . get_string('posttoforum', 'forum') . '"'),
new Given('I wait to be redirected')
);
}
......@@ -71,9 +71,9 @@ class behat_mod_forum extends behat_base {
return array(
new Given('I follow "' . $this->escape($forumname) . '"'),
new Given('I follow "' . $this->escape($postsubject) . '"'),
new Given('I follow "' . get_string('reply', 'mod_forum') . '"'),
new Given('I follow "' . get_string('reply', 'forum') . '"'),
new Given('I fill the moodle form with:', $table),
new Given('I press "' . get_string('posttoforum', 'mod_forum') . '"'),
new Given('I press "' . get_string('posttoforum', 'forum') . '"'),
new Given('I wait to be redirected')
);
......
......@@ -50,7 +50,7 @@ class behat_mod_glossary extends behat_base {
return array(
new Given('I press "' . get_string('addentry', 'mod_glossary') . '"'),
new Given('I fill the moodle form with:', $data),
new Given('I press "Save changes"')
new Given('I press "' . get_string('savechanges') . '"')
);
}
......@@ -65,7 +65,7 @@ class behat_mod_glossary extends behat_base {
return array(
new Given('I follow "' . get_string('categoryview', 'mod_glossary') . '"'),
new Given('I press "' . get_string('editcategories', 'mod_glossary') . '"'),
new Given('I press "Add Category"'),
new Given('I press "' . get_string('add').' '.get_string('category', 'glossary') . '"'),
new Given('I fill in "name" with "' . $categoryname . '"'),
new Given('I press "' . get_string('savechanges') . '"'),
new Given('I press "' . get_string('back', 'mod_glossary') . '"')
......
......@@ -60,7 +60,7 @@ class behat_question extends behat_base {
new Given('I click on "' . $questiontypexpath . '" "xpath_element"'),
new Given('I click on "Next" "button" in the "#qtypechoicecontainer" "css_element"'),
new Given('I fill the moodle form with:', $questiondata),
new Given('I press "Save changes"')
new Given('I press "' . get_string('savechanges') . '"')
);
}
......
......@@ -56,7 +56,7 @@ class behat_repository_recent extends behat_files {
// Opening the specified file contextual menu from the modal window.
$this->open_element_contextual_menu($filename);
$this->find_button('Select this file')->click();
$this->find_button(get_string('getfile', 'repository'))->click();
// Ensure the file has been selected and we returned to the form page.
$this->wait_until_return_to_form();
......
......@@ -63,7 +63,7 @@ class behat_filepicker extends behat_files {
$dialoginput = $this->find('css', '.fp-mkdir-dlg-text input');
$dialoginput->setValue($foldername);
$this->getSession()->getPage()->pressButton('Create folder');
$this->getSession()->getPage()->pressButton(get_string('makeafolder'));
// Wait until the process finished and modal windows are hidden.
$this->wait_until_return_to_form();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment