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 for block_people
|
|
|
19 |
*
|
|
|
20 |
* This script is only called from Behat as part of it's integration
|
|
|
21 |
* in Moodle.
|
|
|
22 |
*
|
|
|
23 |
* @package block_people
|
|
|
24 |
* @category test
|
|
|
25 |
* @copyright 2020 Kathrin Osswald <kathrin.osswald@uni-ulm.de>
|
|
|
26 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
27 |
*/
|
|
|
28 |
|
|
|
29 |
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Steps definitions for block_people
|
|
|
33 |
*
|
|
|
34 |
* This script is only called from Behat as part of it's integration
|
|
|
35 |
* in Moodle.
|
|
|
36 |
*
|
|
|
37 |
* @package block_people
|
|
|
38 |
* @category test
|
|
|
39 |
* @copyright 2020 Kathrin Osswald <kathrin.osswald@uni-ulm.de>
|
|
|
40 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
41 |
*/
|
|
|
42 |
class behat_block_people extends behat_base {
|
|
|
43 |
// @codingStandardsIgnoreStart
|
|
|
44 |
/**
|
|
|
45 |
* Checks, that the specified user is listed in the section with the specified role within the block People.
|
|
|
46 |
*
|
|
|
47 |
* @Then /^the user "(?P<username_string>(?:[^"]|\\")*)" should be listed in the section with the role "(?P<rolename_string>(?:[^"]|\\")*)"$/
|
|
|
48 |
*
|
|
|
49 |
* @param string $username
|
|
|
50 |
* @param string $rolename
|
|
|
51 |
*/
|
|
|
52 |
public function user_should_be_listed_in_role_section($username, $rolename) {
|
|
|
53 |
// @codingStandardsIgnoreEnd
|
|
|
54 |
|
|
|
55 |
// Teacher entries without link.
|
|
|
56 |
$elementxpath = "//section[contains(concat(' ',normalize-space(@class),' '),' block_people ')]";
|
|
|
57 |
$elementxpath .= "//h6[contains(text(),'{$rolename}')]";
|
|
|
58 |
$elementxpath .= "/following-sibling::ul//div[contains(text(),'{$username}')]";
|
|
|
59 |
|
|
|
60 |
// Teacher entries with link.
|
|
|
61 |
$elementxpath .= " | ";
|
|
|
62 |
$elementxpath .= "//section[contains(concat(' ',normalize-space(@class),' '),' block_people ')]";
|
|
|
63 |
$elementxpath .= "//h6[contains(text(),'{$rolename}')]";
|
|
|
64 |
$elementxpath .= "/following-sibling::ul//a[contains(text(),'{$username}')]";
|
|
|
65 |
|
|
|
66 |
// Check if the element exists.
|
|
|
67 |
$this->execute("behat_general::should_exist",
|
|
|
68 |
[$elementxpath, "xpath_element"]);
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
// @codingStandardsIgnoreStart
|
|
|
72 |
/**
|
|
|
73 |
* Checks, that the specified user is not listed in the section with the specified role within the block People.
|
|
|
74 |
*
|
|
|
75 |
* @Then /^the user "(?P<username_string>(?:[^"]|\\")*)" should not be listed in the section with the role "(?P<rolename_string>(?:[^"]|\\")*)"$/
|
|
|
76 |
*
|
|
|
77 |
* @param string $username
|
|
|
78 |
* @param string $rolename
|
|
|
79 |
*/
|
|
|
80 |
public function user_should_not_be_listed_in_role_section($username, $rolename) {
|
|
|
81 |
// @codingStandardsIgnoreEnd
|
|
|
82 |
|
|
|
83 |
$elementxpath = "//section[contains(concat(' ',normalize-space(@class),' '),' block_people ')]";
|
|
|
84 |
$elementxpath .= "//h6[contains(text(),'{$rolename}')]";
|
|
|
85 |
$elementxpath .= "/following-sibling::ul//div[contains(text(),'{$username}')]";
|
|
|
86 |
|
|
|
87 |
// Check if the element exists.
|
|
|
88 |
$this->execute("behat_general::should_not_exist",
|
|
|
89 |
[$elementxpath, "xpath_element"]);
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
}
|