1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
|
|
18 |
|
|
|
19 |
require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Steps definitions that are now deprecated and will be removed in the next releases.
|
|
|
23 |
*
|
|
|
24 |
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
|
|
|
25 |
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
|
|
|
26 |
* file in the same directory where the steps were defined.
|
|
|
27 |
*
|
|
|
28 |
* @package core_grades
|
|
|
29 |
* @category test
|
|
|
30 |
* @copyright 2023 Ilya Tregubov
|
|
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
32 |
*/
|
|
|
33 |
class behat_grade_deprecated extends behat_deprecated_base {
|
|
|
34 |
|
|
|
35 |
/**
|
1441 |
ariadna |
36 |
* Confirm if a value is within the search widget within the gradebook.
|
1 |
efrain |
37 |
*
|
1441 |
ariadna |
38 |
* Examples:
|
|
|
39 |
* - I confirm "User" in "user" search within the gradebook widget exists
|
|
|
40 |
* - I confirm "Group" in "group" search within the gradebook widget exists
|
|
|
41 |
* - I confirm "Grade item" in "grade" search within the gradebook widget exists
|
|
|
42 |
*
|
|
|
43 |
* @Given /^I confirm "(?P<needle>(?:[^"]|\\")*)" in "(?P<haystack>(?:[^"]|\\")*)" search within the gradebook widget exists$/
|
|
|
44 |
* @param string $needle The value to search for.
|
|
|
45 |
* @param string $haystack The type of the search widget.
|
|
|
46 |
* @deprecated since 4.5
|
1 |
efrain |
47 |
*/
|
1441 |
ariadna |
48 |
public function i_confirm_in_search_within_the_gradebook_widget_exists($needle, $haystack) {
|
|
|
49 |
$this->deprecated_message('behat_general::i_confirm_in_search_combobox_exists');
|
1 |
efrain |
50 |
|
1441 |
ariadna |
51 |
$this->execute("behat_general::wait_until_the_page_is_ready");
|
1 |
efrain |
52 |
|
1441 |
ariadna |
53 |
// Set the default field to search and handle any special preamble.
|
|
|
54 |
$selector = '.usersearchdropdown';
|
|
|
55 |
if (strtolower($haystack) === 'group') {
|
|
|
56 |
$selector = '.groupsearchdropdown';
|
|
|
57 |
$trigger = ".groupsearchwidget";
|
|
|
58 |
$node = $this->find("css_element", $selector);
|
|
|
59 |
if (!$node->isVisible()) {
|
|
|
60 |
$this->execute("behat_general::i_click_on", [$trigger, "css_element"]);
|
|
|
61 |
}
|
|
|
62 |
} else if (strtolower($haystack) === 'grade') {
|
|
|
63 |
$selector = '.gradesearchdropdown';
|
|
|
64 |
$trigger = ".gradesearchwidget";
|
|
|
65 |
$node = $this->find("css_element", $selector);
|
|
|
66 |
if (!$node->isVisible()) {
|
|
|
67 |
$this->execute("behat_general::i_click_on", [$trigger, "css_element"]);
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
$this->execute("behat_general::assert_element_contains_text",
|
|
|
72 |
[$needle, $selector, "css_element"]);
|
1 |
efrain |
73 |
}
|
1441 |
ariadna |
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Confirm if a value is not within the search widget within the gradebook.
|
|
|
77 |
*
|
|
|
78 |
* Examples:
|
|
|
79 |
* - I confirm "User" in "user" search within the gradebook widget does not exist
|
|
|
80 |
* - I confirm "Group" in "group" search within the gradebook widget does not exist
|
|
|
81 |
* - I confirm "Grade item" in "grade" search within the gradebook widget does not exist
|
|
|
82 |
*
|
|
|
83 |
* @Given /^I confirm "(?P<needle>(?:[^"]|\\")*)" in "(?P<haystack>(?:[^"]|\\")*)" search within the gradebook widget does not exist$/
|
|
|
84 |
* @param string $needle The value to search for.
|
|
|
85 |
* @param string $haystack The type of the search widget.
|
|
|
86 |
* @deprecated since 4.5
|
|
|
87 |
*/
|
|
|
88 |
public function i_confirm_in_search_within_the_gradebook_widget_does_not_exist($needle, $haystack) {
|
|
|
89 |
$this->deprecated_message('behat_general::i_confirm_in_search_combobox_does_not_exist');
|
|
|
90 |
|
|
|
91 |
$this->execute("behat_general::wait_until_the_page_is_ready");
|
|
|
92 |
|
|
|
93 |
// Set the default field to search and handle any special preamble.
|
|
|
94 |
$selector = '.usersearchdropdown';
|
|
|
95 |
if (strtolower($haystack) === 'group') {
|
|
|
96 |
$selector = '.groupsearchdropdown';
|
|
|
97 |
$trigger = ".groupsearchwidget";
|
|
|
98 |
$node = $this->find("css_element", $selector);
|
|
|
99 |
if (!$node->isVisible()) {
|
|
|
100 |
$this->execute("behat_general::i_click_on", [$trigger, "css_element"]);
|
|
|
101 |
}
|
|
|
102 |
} else if (strtolower($haystack) === 'grade') {
|
|
|
103 |
$selector = '.gradesearchdropdown';
|
|
|
104 |
$trigger = ".gradesearchwidget";
|
|
|
105 |
$node = $this->find("css_element", $selector);
|
|
|
106 |
if (!$node->isVisible()) {
|
|
|
107 |
$this->execute("behat_general::i_click_on", [$trigger, "css_element"]);
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
$this->execute("behat_general::assert_element_not_contains_text",
|
|
|
112 |
[$needle, $selector, "css_element"]);
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
/**
|
|
|
116 |
* Clicks on an option from the specified search widget in the current gradebook page.
|
|
|
117 |
*
|
|
|
118 |
* Examples:
|
|
|
119 |
* - I click on "Student" in the "user" search widget
|
|
|
120 |
* - I click on "Group" in the "group" search widget
|
|
|
121 |
* - I click on "Grade item" in the "grade" search widget
|
|
|
122 |
*
|
|
|
123 |
* @Given /^I click on "(?P<needle>(?:[^"]|\\")*)" in the "(?P<haystack>(?:[^"]|\\")*)" search widget$/
|
|
|
124 |
* @param string $needle The value to search for.
|
|
|
125 |
* @param string $haystack The type of the search widget.
|
|
|
126 |
* @deprecated since 4.5
|
|
|
127 |
*/
|
|
|
128 |
public function i_click_on_in_search_widget(string $needle, string $haystack) {
|
|
|
129 |
$this->deprecated_message('behat_general::i_click_on_in_search_combobox');
|
|
|
130 |
|
|
|
131 |
$this->execute("behat_general::wait_until_the_page_is_ready");
|
|
|
132 |
|
|
|
133 |
// Set the default field to search and handle any special preamble.
|
|
|
134 |
$string = get_string('searchusers', 'core');
|
|
|
135 |
$selector = '.usersearchdropdown';
|
|
|
136 |
if (strtolower($haystack) === 'group') {
|
|
|
137 |
$string = get_string('searchgroups', 'core');
|
|
|
138 |
$selector = '.groupsearchdropdown';
|
|
|
139 |
$trigger = ".groupsearchwidget";
|
|
|
140 |
$node = $this->find("css_element", $selector);
|
|
|
141 |
if (!$node->isVisible()) {
|
|
|
142 |
$this->execute("behat_general::i_click_on", [$trigger, "css_element"]);
|
|
|
143 |
}
|
|
|
144 |
} else if (strtolower($haystack) === 'grade') {
|
|
|
145 |
$string = get_string('searchitems', 'core');
|
|
|
146 |
$selector = '.gradesearchdropdown';
|
|
|
147 |
$trigger = ".gradesearchwidget";
|
|
|
148 |
$node = $this->find("css_element", $selector);
|
|
|
149 |
if (!$node->isVisible()) {
|
|
|
150 |
$this->execute("behat_general::i_click_on", [$trigger, "css_element"]);
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
$this->execute("behat_forms::set_field_value", [$string, $needle]);
|
|
|
155 |
$this->execute("behat_general::wait_until_exists", [$needle, "list_item"]);
|
|
|
156 |
|
|
|
157 |
$this->execute('behat_general::i_click_on_in_the', [
|
|
|
158 |
$needle, "list_item",
|
|
|
159 |
$selector, "css_element",
|
|
|
160 |
]);
|
|
|
161 |
$this->execute("behat_general::i_wait_to_be_redirected");
|
|
|
162 |
}
|
1 |
efrain |
163 |
}
|