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 |
/**
|
|
|
18 |
* Steps definitions related to mod_unilabel.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_unilabel
|
|
|
21 |
* @category test
|
|
|
22 |
* @author Andreas Grabs <info@grabs-edv.de>
|
|
|
23 |
* @copyright 2018 onwards Grabs EDV {@link https://www.grabs-edv.de}
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
|
|
28 |
use Behat\Gherkin\Node\TableNode as TableNode;
|
|
|
29 |
|
|
|
30 |
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Steps definitions related to mod_feedback.
|
|
|
34 |
*
|
|
|
35 |
* @copyright 2022 Andreas Grabs
|
|
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
37 |
*/
|
|
|
38 |
class behat_mod_unilabel extends behat_base {
|
|
|
39 |
/**
|
|
|
40 |
* Adds the selected activity/resource filling the form data with the specified field/value pairs.
|
|
|
41 |
*
|
|
|
42 |
* Sections 0 and 1 are also allowed on frontpage.
|
|
|
43 |
*
|
|
|
44 |
* @Given I add a unilabel to course :coursefullname section :sectionnum and I fill the form with:
|
|
|
45 |
* @param string $coursefullname The course full name of the course.
|
|
|
46 |
* @param int $section The section number
|
|
|
47 |
* @param TableNode $data The activity field/value data
|
|
|
48 |
*/
|
|
|
49 |
public function i_add_unilabel_and_i_fill_the_form_with($coursefullname, $section, TableNode $data) {
|
|
|
50 |
|
|
|
51 |
// Add activity to section.
|
|
|
52 |
$this->execute(
|
|
|
53 |
"behat_mod_unilabel::i_add_unilabel_to_course_section",
|
|
|
54 |
[$this->escape($coursefullname), $this->escape($section)]
|
|
|
55 |
);
|
|
|
56 |
|
|
|
57 |
// Wait to be redirected.
|
|
|
58 |
$this->execute('behat_general::wait_until_the_page_is_ready');
|
|
|
59 |
|
|
|
60 |
// Set form fields.
|
|
|
61 |
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $data);
|
|
|
62 |
|
|
|
63 |
// Save course settings.
|
|
|
64 |
$this->execute("behat_forms::press_button", get_string('savechangesandreturntocourse'));
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Open a add activity form page.
|
|
|
69 |
*
|
|
|
70 |
* @Given I add a unilabel to course :coursefullname section :sectionnum
|
|
|
71 |
* @throws coding_exception
|
|
|
72 |
* @param string $coursefullname The course full name of the course.
|
|
|
73 |
* @param string $sectionnum The section number.
|
|
|
74 |
*/
|
|
|
75 |
public function i_add_unilabel_to_course_section(string $coursefullname, string $sectionnum): void {
|
|
|
76 |
$addurl = new moodle_url('/course/modedit.php', [
|
|
|
77 |
'add' => 'unilabel',
|
|
|
78 |
'course' => $this->get_course_id($coursefullname),
|
|
|
79 |
'section' => intval($sectionnum),
|
|
|
80 |
]);
|
|
|
81 |
$this->execute('behat_general::i_visit', [$addurl]);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
}
|