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 |
use Behat\Gherkin\Node\TableNode,
|
|
|
18 |
Behat\Mink\Exception\ExpectationException as ExpectationException;
|
|
|
19 |
|
|
|
20 |
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Behat steps for tool_courserating
|
|
|
24 |
*
|
|
|
25 |
* @package tool_courserating
|
|
|
26 |
* @copyright 2022 Marina Glancy <marina.glancy@gmail.com>
|
|
|
27 |
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
28 |
*/
|
|
|
29 |
class behat_tool_courserating extends behat_base {
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Return the list of partial named selectors.
|
|
|
34 |
*
|
|
|
35 |
* @return array
|
|
|
36 |
*/
|
|
|
37 |
public static function get_partial_named_selectors(): array {
|
|
|
38 |
return [
|
|
|
39 |
new behat_component_named_selector('Review', [
|
|
|
40 |
<<<XPATH
|
|
|
41 |
.//div[@data-for='tool_courserating-user-rating' and contains(string(), %locator%)]
|
|
|
42 |
XPATH
|
|
|
43 |
,
|
|
|
44 |
], true),
|
|
|
45 |
new behat_component_named_selector('Coursebox', [
|
|
|
46 |
<<<XPATH
|
|
|
47 |
//div[contains(concat(' ', @class, ' '), ' coursebox ') and
|
|
|
48 |
contains(.//div[contains(concat(' ', @class, ' '), ' info ')]/., %locator%)]
|
|
|
49 |
XPATH
|
|
|
50 |
,
|
|
|
51 |
], true),
|
|
|
52 |
];
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* Checks if given plugin is installed, and skips the current scenario if not.
|
|
|
57 |
*
|
|
|
58 |
* @Given reportbuilder is available for tool_courserating
|
|
|
59 |
* @throws \Moodle\BehatExtension\Exception\SkippedException
|
|
|
60 |
*/
|
|
|
61 |
public function reportbuilder_is_available(): void {
|
|
|
62 |
$path = core_component::get_component_directory('core_reportbuilder');
|
|
|
63 |
if (!$path) {
|
|
|
64 |
throw new \Moodle\BehatExtension\Exception\SkippedException(
|
|
|
65 |
'Skipping this scenario because the reportbuilder is not avialable.');
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
}
|