MDL-76564 behat: final removal of deprecated pre-404 step definitions.

This commit is contained in:
Paul Holden 2024-09-30 19:21:36 +01:00
parent 30692df849
commit 8e2ad49afe
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
5 changed files with 0 additions and 547 deletions

View File

@ -1,59 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
/**
* Steps definitions that are now deprecated and will be removed in the next releases.
*
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
* file in the same directory where the steps were defined.
*
* @package core_calendar
* @category test
* @copyright 2024 Mathew May <mathew.solutions>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_calendar_deprecated extends behat_deprecated_base {
/**
* Hover over today in the calendar.
*
* @Given /^I hover over today in the calendar$/
*
* @deprecated since 4.4 MDL-73117.
* @TODO MDL-79721: This will be deleted in Moodle 4.8.
*/
public function i_hover_over_today_in_the_calendar() {
$this->deprecated_message('behat_calendar::i_hover_over_today_in_the_calendar');
$todaysday = date('j');
$summarytitle = userdate(time(), get_string('strftimemonthyear'));
// The current month table.
$currentmonth = "table[descendant::*[self::caption[contains(concat(' ', normalize-space(.), ' '), ' {$summarytitle} ')]]]";
// Strings for the class cell match.
$cellclasses = "contains(concat(' ', normalize-space(@class), ' '), ' day ')";
$daycontains = "text()[contains(concat(' ', normalize-space(.), ' '), ' {$todaysday} ')]";
$daycell = "td[{$cellclasses}]";
$dayofmonth = "a[{$daycontains}]";
$xpath = '//' . $currentmonth . '/descendant::' . $daycell . '/' . $dayofmonth;
$this->execute("behat_general::i_hover", [$xpath, "xpath_element"]);
}
}

View File

@ -1,117 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
use Behat\Gherkin\Node\TableNode as TableNode;
/**
* Steps definitions that are now deprecated and will be removed in the next releases.
*
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
* file in the same directory where the steps were defined.
*
* @package core_course
* @category test
* @copyright 2024 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_course_deprecated extends behat_deprecated_base {
/**
* Opens the activity chooser and opens the activity/resource form page. Sections 0 and 1 are also allowed on frontpage.
*
* @Given /^I add a "(?P<activity_or_resource_name_string>(?:[^"]|\\")*)" to section "(?P<section_number>\d+)"$/
* @param string $activity
* @param int $section
* @throws \Behat\Mink\Exception\ElementNotFoundException Thrown by behat_base::find
* @deprecated Since Moodle 4.4
*/
public function i_add_to_section($activity, $section) {
$this->deprecated_message([
'behat_course::i_add_to_course_section',
'behat_course::i_add_to_section_using_the_activity_chooser',
]);
$this->require_javascript('Please use the \'the following "activity" exists:\' data generator instead.');
if ($this->getSession()->getPage()->find('css', 'body#page-site-index') && (int)$section <= 1) {
// We are on the frontpage.
if ($section) {
// Section 1 represents the contents on the frontpage.
$sectionxpath = "//body[@id='page-site-index']" .
"/descendant::div[contains(concat(' ',normalize-space(@class),' '),' sitetopic ')]";
} else {
// Section 0 represents "Site main menu" block.
$sectionxpath = "//*[contains(concat(' ',normalize-space(@class),' '),' block_site_main_menu ')]";
}
} else {
// We are inside the course.
$sectionxpath = "//li[@id='section-" . $section . "']";
}
// Clicks add activity or resource section link.
$sectionnode = $this->find('xpath', $sectionxpath);
$this->execute('behat_general::i_click_on_in_the', [
"//button[@data-action='open-chooser' and not(@data-beforemod)]",
'xpath',
$sectionnode,
'NodeElement',
]);
// Clicks the selected activity if it exists.
$activityliteral = behat_context_helper::escape(ucfirst($activity));
$activityxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' modchooser ')]" .
"/descendant::div[contains(concat(' ', normalize-space(@class), ' '), ' optioninfo ')]" .
"/descendant::div[contains(concat(' ', normalize-space(@class), ' '), ' optionname ')]" .
"[normalize-space(.)=$activityliteral]" .
"/parent::a";
$this->execute('behat_general::i_click_on', [$activityxpath, 'xpath']);
}
/**
* Adds the selected activity/resource filling the form data with the specified field/value pairs.
*
* Sections 0 and 1 are also allowed on frontpage.
*
* @When /^I add a "(?P<activity_or_resource_name_string>(?:[^"]|\\")*)" to section "(?P<section_number>\d+)" and I fill the form with:$/
* @param string $activity The activity name
* @param int $section The section number
* @param TableNode $data The activity field/value data
* @deprecated Since Moodle 4.4
*/
public function i_add_to_section_and_i_fill_the_form_with($activity, $section, TableNode $data) {
$this->deprecated_message(['behat_course::i_add_to_course_section_and_i_fill_the_form_with']);
// Add activity to section.
$this->execute(
"behat_course::i_add_to_section",
[$this->escape($activity), $this->escape($section)]
);
// Wait to be redirected.
$this->execute('behat_general::wait_until_the_page_is_ready');
// Set form fields.
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $data);
// Save course settings.
$this->execute("behat_forms::press_button", get_string('savechangesandreturntocourse'));
}
}

View File

@ -1,250 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
use Behat\Gherkin\Node\TableNode;
require_once(__DIR__ . '/../../../../../lib/behat/behat_deprecated_base.php');
/**
* Steps definitions that are now deprecated and will be removed in the next releases.
*
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
* file in the same directory where the steps were defined.
*
* @package gradereport_grader
* @category test
* @copyright 2023 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_gradereport_grader_deprecated extends behat_deprecated_base {
/**
* Remove focus for a grade value cell.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Given /^I click away from student "([^"]*)" and grade item "([^"]*)" feedback$/
* @param string $student
* @param string $itemname
*/
public function i_click_away_from_student_and_grade_feedback($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_click_away_from_student_and_grade_feedback']);
$xpath = $this->get_student_and_grade_feedback_selector($student, $itemname);
$this->execute('behat_general::i_take_focus_off_field', array($this->escape($xpath), 'xpath_element'));
}
/**
* Look for a feedback editing field.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Then /^I should see a feedback field for "([^"]*)" and grade item "([^"]*)"$/
* @param string $student
* @param string $itemname
*/
public function i_should_see_feedback_field($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_should_see_feedback_field']);
$xpath = $this->get_student_and_grade_feedback_selector($student, $itemname);
$this->execute('behat_general::should_be_visible', array($this->escape($xpath), 'xpath_element'));
}
/**
* Look for a lack of the feedback editing field.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Then /^I should not see a feedback field for "([^"]*)" and grade item "([^"]*)"$/
* @param string $student
* @param string $itemname
*/
public function i_should_not_see_feedback_field($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_should_not_see_feedback_field']);
$xpath = $this->get_student_and_grade_feedback_selector($student, $itemname);
$this->execute('behat_general::should_not_exist', array($this->escape($xpath), 'xpath_element'));
}
/**
* Gets xpath for a particular student/grade item feedback cell.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @throws Exception
* @param string $student
* @param string $itemname
* @return string
*/
protected function get_student_and_grade_feedback_selector($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::get_student_and_grade_feedback_selector']);
$cell = $this->get_student_and_grade_cell_selector($student, $itemname);
return $cell . "//input[contains(@id, 'feedback_') or @name='ajaxfeedback']";
}
/**
* Click a given user grade cell.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Given /^I click on student "([^"]*)" for grade item "([^"]*)"$/
* @param string $student
* @param string $itemname
*/
public function i_click_on_student_and_grade_item($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_click_on_student_and_grade_item']);
$xpath = $this->get_student_and_grade_cell_selector($student, $itemname);
$this->execute("behat_general::i_click_on", array($this->escape($xpath), "xpath_element"));
}
/**
* Remove focus for a grade value cell.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Given /^I click away from student "([^"]*)" and grade item "([^"]*)" value$/
* @param string $student
* @param string $itemname
*/
public function i_click_away_from_student_and_grade_value($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_click_away_from_student_and_grade_value']);
$xpath = $this->get_student_and_grade_value_selector($student, $itemname);
$this->execute('behat_general::i_take_focus_off_field', array($this->escape($xpath), 'xpath_element'));
}
/**
* Checks grade values with or without a edit box.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Then /^the grade for "([^"]*)" in grade item "([^"]*)" should match "([^"]*)"$/
* @throws Exception
* @throws ElementNotFoundException
* @param string $student
* @param string $itemname
* @param string $value
*/
public function the_grade_should_match($student, $itemname, $value) {
$this->deprecated_message(['behat_gradereport_grader::the_grade_should_match']);
$xpath = $this->get_student_and_grade_value_selector($student, $itemname);
$gradefield = $this->getSession()->getPage()->find('xpath', $xpath);
if (!empty($gradefield)) {
// Get the field.
$fieldtype = behat_field_manager::guess_field_type($gradefield, $this->getSession());
if (!$fieldtype) {
throw new Exception('Could not get field type for grade field "' . $itemname . '"');
}
$field = behat_field_manager::get_field_instance($fieldtype, $gradefield, $this->getSession());
if (!$field->matches($value)) {
$fieldvalue = $field->get_value();
throw new ExpectationException(
'The "' . $student . '" and "' . $itemname . '" grade is "' . $fieldvalue . '", "' . $value . '" expected' ,
$this->getSession()
);
}
} else {
// If there isn't a form field, just search for contents.
$valueliteral = behat_context_helper::escape($value);
$xpath = $this->get_student_and_grade_cell_selector($student, $itemname);
$xpath .= "[contains(normalize-space(.)," . $valueliteral . ")]";
$node = $this->getSession()->getDriver()->find($xpath);
if (empty($node)) {
$locatorexceptionmsg = 'Cell for "' . $student . '" and "' . $itemname . '" with value "' . $value . '"';
throw new ElementNotFoundException($this->getSession(), $locatorexceptionmsg, null, $xpath);
}
}
}
/**
* Look for a grade editing field.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Then /^I should see a grade field for "([^"]*)" and grade item "([^"]*)"$/
* @param string $student
* @param string $itemname
*/
public function i_should_see_grade_field($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_should_see_grade_field']);
$xpath = $this->get_student_and_grade_value_selector($student, $itemname);
$this->execute('behat_general::should_be_visible', array($this->escape($xpath), 'xpath_element'));
}
/**
* Look for a lack of the grade editing field.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Then /^I should not see a grade field for "([^"]*)" and grade item "([^"]*)"$/
* @param string $student
* @param string $itemname
*/
public function i_should_not_see_grade_field($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::i_should_not_see_grade_field']);
$xpath = $this->get_student_and_grade_value_selector($student, $itemname);
$this->execute('behat_general::should_not_exist', array($this->escape($xpath), 'xpath_element'));
}
/**
* Gets unique xpath selector for a student/grade item combo.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @throws Exception
* @param string $student
* @param string $itemname
* @return string
*/
protected function get_student_and_grade_cell_selector($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::get_student_and_grade_cell_selector']);
$itemid = 'u' . $this->get_user_id($student) . 'i' . $this->get_grade_item_id($itemname);
return "//table[@id='user-grades']//td[@id='" . $itemid . "']";
}
/**
* Gets xpath for a particular student/grade item grade value cell.
*
* @deprecated since 4.2 - we don't allow ajax edit on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @throws Exception
* @param string $student
* @param string $itemname
* @return string
*/
protected function get_student_and_grade_value_selector($student, $itemname) {
$this->deprecated_message(['behat_gradereport_grader::get_student_and_grade_value_selector']);
$cell = $this->get_student_and_grade_cell_selector($student, $itemname);
return $cell . "//*[contains(@id, 'grade_') or @name='ajaxgrade']";
}
}

View File

@ -16,8 +16,6 @@
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
use Behat\Gherkin\Node\TableNode;
require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
/**
@ -34,26 +32,6 @@ require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
*/
class behat_grade_deprecated extends behat_deprecated_base {
/**
* Enters a quick feedback via the gradebook for a specific grade item and user when viewing
* the 'Grader report' with editing mode turned on.
*
* @deprecated since 4.2 - we don't allow edit feedback on grader report anymore.
* @todo MDL-77107 This will be deleted in Moodle 4.6.
* @Given /^I give the feedback "(?P<grade_number>(?:[^"]|\\")*)" to the user "(?P<username_string>(?:[^"]|\\")*)" for the grade item "(?P<grade_activity_string>(?:[^"]|\\")*)"$/
* @param string $feedback
* @param string $userfullname the user's fullname as returned by fullname()
* @param string $itemname
*/
public function i_give_the_feedback($feedback, $userfullname, $itemname) {
$this->deprecated_message(['behat_grade::i_give_the_feedback']);
$gradelabel = $userfullname . ' ' . $itemname;
$fieldstr = get_string('useractivityfeedback', 'gradereport_grader', $gradelabel);
$this->execute('behat_forms::i_set_the_field_to', array($this->escape($fieldstr), $this->escape($feedback)));
}
/**
* Confirm if a value is within the search widget within the gradebook.
*

View File

@ -1,99 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
use Behat\Gherkin\Node\TableNode as TableNode;
require_once(__DIR__ . '/../../../../lib/behat/behat_deprecated_base.php');
/**
* Steps definitions that are now deprecated and will be removed in the next releases.
*
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
* file in the same directory where the steps were defined.
*
* @package mod_data
* @category test
* @copyright 2024 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_mod_data_deprecated extends behat_deprecated_base
{
/**
* Adds a new field to a database
*
* @Given /^I add a "(?P<fieldtype_string>(?:[^"]|\\")*)" field to "(?P<activityname_string>(?:[^"]|\\")*)" database and I fill the form with:$/
*
* @param string $fieldtype
* @param string $activityname
* @param TableNode $fielddata
* @todo MDL-79721 This will be deleted in Moodle 4.8.
*
* @deprecated since 4.4
*/
public function i_add_a_field_to_database_and_i_fill_the_form_with($fieldtype, $activityname, TableNode $fielddata)
{
$this->deprecated_message([
'behat_mod_data::i_add_a_field_to_database_and_i_fill_the_form_with is deprecated',
'mod_data > fields generator',
]);
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'data activity']);
$fieldsstr = get_string('fields', 'mod_data');
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", $fieldsstr);
$this->execute('behat_general::i_click_on', [get_string('newfield', 'mod_data'), "button"]);
$this->execute('behat_general::i_click_on_in_the',
[$this->escape($fieldtype), "link", "#action_bar", "css_element"]
);
if (!$this->running_javascript()) {
$this->execute('behat_general::i_click_on_in_the',
array(get_string('go'), "button", ".fieldadd", "css_element")
);
}
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $fielddata);
$this->execute('behat_forms::press_button', get_string('save'));
}
/**
* Adds an entry to a database.
*
* @Given /^I add an entry to "(?P<activityname_string>(?:[^"]|\\")*)" database with:$/
*
* @param string $activityname
* @param TableNode $entrydata
* @deprecated since 4.4
* @todo MDL-79721 This will be deleted in Moodle 4.8.
*
*/
public function i_add_an_entry_to_database_with($activityname, TableNode $entrydata)
{
$this->deprecated_message([
'behat_mod_data::i_add_an_entry_to_database_with is deprecated',
'mod_data > entries generator',
]);
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'mod_data > add entry']);
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $entrydata);
}
}