diff --git a/repository/recent/tests/behat/behat_repository_recent.php b/repository/recent/tests/behat/behat_repository_recent.php new file mode 100644 index 00000000000..2dbce305ea0 --- /dev/null +++ b/repository/recent/tests/behat/behat_repository_recent.php @@ -0,0 +1,65 @@ +. + +/** + * Steps definitions for recent files repository type. + * + * @package repository_recent + * @category test + * @copyright 2013 David Monllaó + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. + +require_once(__DIR__ . '/../../../../lib/behat/behat_files.php'); + +/** + * Steps definitions to deal with recent files and the filepicker. + * + * Extends behat_files rather than behat_base as is file-related. + * + * @package repository_recent + * @category test + * @copyright 2013 David Monllaó + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class behat_repository_recent extends behat_files { + + /** + * Adds the specified file from the 'Recent files' repository to the specified filepicker of the current page. + * + * @When /^I add "(?P(?:[^"]|\\")*)" file from recent files to "(?P(?:[^"]|\\")*)" filepicker$/ + * @param string $filename + * @param string $filepickerelement + */ + public function i_add_file_from_recent_files_to_filepicker($filename, $filepickerelement) { + + $filepickernode = $this->get_filepicker_node($filepickerelement); + + // Opening the select repository window and selecting the recent repository. + $this->open_add_file_window($filepickernode, get_string('pluginname', 'repository_recent')); + + // Opening the specified file contextual menu from the modal window. + $this->open_element_contextual_menu($filename); + + $this->find_button('Select this file')->click(); + + // Wait a while for the file to be selected. + $this->getSession()->wait(3 * 1000, false); + } + +}