From fc4354c7e30ea14ff50bb5e2c313a0ab50747f80 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 3 Aug 2023 11:22:39 +0200 Subject: [PATCH] MDL-77581 behat: Support finish_generate_ in generators --- lib/behat/classes/behat_generator_base.php | 11 +++++++++++ lib/upgrade.txt | 1 + 2 files changed, 12 insertions(+) diff --git a/lib/behat/classes/behat_generator_base.php b/lib/behat/classes/behat_generator_base.php index 9b9661f7895..262b6f415a6 100644 --- a/lib/behat/classes/behat_generator_base.php +++ b/lib/behat/classes/behat_generator_base.php @@ -279,6 +279,17 @@ abstract class behat_generator_base { ' data generator is not implemented'); } } + + // Notify that the all the elements have been generated. + if (method_exists($this->componentdatagenerator, 'finish_generate_' . $generatortype)) { + // Using the component's own data generator if it exists. + $this->componentdatagenerator->{'finish_generate_' . $generatortype}(); + + } else if (method_exists($this->datagenerator, 'finish_generate_' . $generatortype)) { + // Use a method on the core data geneator, if there is one. + $this->datagenerator->{'finish_generate_' . $generatortype}(); + + } } /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index d18dea49cd8..156fcec04a9 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -6,6 +6,7 @@ information provided here is intended especially for developers. * Added modalform config object `moduleName` param that can be used to define alternative modal type for the modalform. By default 'core/modal_save_cancel' is used. * Add a new parameter to the debounce (core/utils) function to allow for cancellation. * Add a new method core_user::get_initials to get the initials of a user in a way compatible with internationalisation. +* Behat generators can now implement the function finish_generate_ to detect when the whole list of elements have been generated. === 4.3 ===