From 08ca9693239ba44dfa2de5cc83891ef091084b42 Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Wed, 20 Nov 2024 11:48:09 +0100 Subject: [PATCH 1/2] MDL-83035 behat: deprecate admin presets behat steps Signed-off-by: Daniel Ziegenberg --- .upgradenotes/MDL-83035-2025012010463894.yml | 7 +++++++ ...s.php => behat_admin_presets_deprecated.php} | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .upgradenotes/MDL-83035-2025012010463894.yml rename admin/tool/admin_presets/tests/behat/{behat_admin_presets.php => behat_admin_presets_deprecated.php} (88%) diff --git a/.upgradenotes/MDL-83035-2025012010463894.yml b/.upgradenotes/MDL-83035-2025012010463894.yml new file mode 100644 index 00000000000..72d80fabf19 --- /dev/null +++ b/.upgradenotes/MDL-83035-2025012010463894.yml @@ -0,0 +1,7 @@ +issueNumber: MDL-83035 +notes: + tool_admin_presets: + - message: >- + behat_admin_presets::following_in_the_should_download_between_and_bytes + is deprecated. Use: the following element should download a file that: + type: deprecated diff --git a/admin/tool/admin_presets/tests/behat/behat_admin_presets.php b/admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php similarity index 88% rename from admin/tool/admin_presets/tests/behat/behat_admin_presets.php rename to admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php index 23b8f9ff31a..3910183ad6e 100644 --- a/admin/tool/admin_presets/tests/behat/behat_admin_presets.php +++ b/admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php @@ -26,21 +26,22 @@ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. -require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php'); +require_once(__DIR__ . '/../../../../../lib/behat/behat_deprecated_base.php'); require_once(__DIR__ . '/../../../../../lib/behat/behat_field_manager.php'); use Behat\Mink\Exception\ExpectationException as ExpectationException; /** - * Steps definitions related with admin presets. + * Steps definitions that are now deprecated and will be removed in the next releases. * * @package tool_admin_presets * @category test * @copyright 2021 Pimenko * @author Sylvain Revenu | Pimenko * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @todo MDL-78077 This will be deleted in Moodle 6.0. */ -class behat_admin_presets extends behat_base { +class behat_admin_presets_deprecated extends behat_deprecated_base { /** * Downloads the file from a specific link on the page and checks the size is in a given range. @@ -60,9 +61,14 @@ class behat_admin_presets extends behat_base { * @param int $maxexpectedsize the maximum expected file size in bytes. * @return void * @throws ExpectationException + * @deprecated since 5.0 */ final public function following_in_the_should_download_between_and_bytes(string $link, string $selectortype, string $nodeelement, string $nodeselectortype, int $minexpectedsize, int $maxexpectedsize): void { + + $this->deprecated_message("behat_admin_presets::following_in_the_should_download_between_and_bytes + is deprecated. Use: the following element should download a file that:"); + // If the minimum is greater than the maximum then swap the values. if ((int) $minexpectedsize > (int) $maxexpectedsize) { list($minexpectedsize, $maxexpectedsize) = [$maxexpectedsize, $minexpectedsize]; @@ -105,9 +111,14 @@ class behat_admin_presets extends behat_base { * @param string $nodeselectortype The type of selector where we look in * @param string $nodeelement Element we look in * @return string the content of the downloaded file. + * @deprecated since 5.0 */ final public function download_file_from_link_within_node(string $selectortype, string $link, string $nodeselectortype, string $nodeelement): string { + + $this->deprecated_message("behat_admin_presets::following_in_the_should_download_between_and_bytes + is deprecated. Use: the following element should download a file that:"); + // Find the link from ur specific node. $linknode = $this->get_node_in_container($selectortype, $link, $nodeselectortype, $nodeelement); $this->ensure_node_is_visible($linknode); From 750b7a57bc1e0d4e48d607c16befa04fac29fd83 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 22 Jan 2025 10:06:53 +0800 Subject: [PATCH 2/2] MDL-83035 behat: add missing attribute and final polishing Signed-off-by: Simey Lameze --- .../tests/behat/behat_admin_presets_deprecated.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php b/admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php index 3910183ad6e..a953a338824 100644 --- a/admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php +++ b/admin/tool/admin_presets/tests/behat/behat_admin_presets_deprecated.php @@ -52,6 +52,8 @@ class behat_admin_presets_deprecated extends behat_deprecated_base { * The range includes the endpoints. That is, a 10 byte file in considered to * be between "5" and "10" bytes, and between "10" and "20" bytes. * + * @deprecated since 5.0 + * * @Then /^following "(?P[^"]*)" "(?P[^"]*)" in the "(?P(?:[^"]|\\")*)" "(?P[^"]*)" should download between "(?P\d+)" and "(?P\d+)" bytes$/ * @param string $link the text of the link. * @param string $selectortype The type of what we look for @@ -61,8 +63,8 @@ class behat_admin_presets_deprecated extends behat_deprecated_base { * @param int $maxexpectedsize the maximum expected file size in bytes. * @return void * @throws ExpectationException - * @deprecated since 5.0 */ + #[\core\attribute\deprecated('behat_admin_presets::following_in_the_should_download_between_and_bytes', since: '5.0')] final public function following_in_the_should_download_between_and_bytes(string $link, string $selectortype, string $nodeelement, string $nodeselectortype, int $minexpectedsize, int $maxexpectedsize): void { @@ -111,14 +113,9 @@ class behat_admin_presets_deprecated extends behat_deprecated_base { * @param string $nodeselectortype The type of selector where we look in * @param string $nodeelement Element we look in * @return string the content of the downloaded file. - * @deprecated since 5.0 */ final public function download_file_from_link_within_node(string $selectortype, string $link, string $nodeselectortype, string $nodeelement): string { - - $this->deprecated_message("behat_admin_presets::following_in_the_should_download_between_and_bytes - is deprecated. Use: the following element should download a file that:"); - // Find the link from ur specific node. $linknode = $this->get_node_in_container($selectortype, $link, $nodeselectortype, $nodeelement); $this->ensure_node_is_visible($linknode);