Skip to content

Commit b00b51a

Browse files
abgreevejunpataleta
authored andcommitted
Merge branch 'MDL-66770-master-2' of https://github.com/ryanwyllie/moodle
2 parents fd8c021 + 9cec5dc commit b00b51a

File tree

4 files changed

+156
-48
lines changed

4 files changed

+156
-48
lines changed

mod/forum/templates/forum_action_menu.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
}
5151
}}
5252
<div class="ml-auto dropdown">
53-
<button class="{{^settings.excludetext}}dropdown-toggle{{/settings.excludetext}} btn btn-link {{#settings.togglemoreicon}}btn-icon colour-inherit{{/settings.togglemoreicon}}"
53+
<a href="#" class="{{^settings.excludetext}}dropdown-toggle{{/settings.excludetext}} btn btn-link {{#settings.togglemoreicon}}btn-icon colour-inherit text-decoration-none d-flex align-items-center justify-content-center{{/settings.togglemoreicon}}"
54+
role="button"
5455
data-toggle="dropdown"
5556
aria-haspopup="true"
5657
tabindex="0"
@@ -65,7 +66,7 @@
6566
{{^settings.excludetext}}
6667
{{#str}} settings, mod_forum {{/str}}
6768
{{/settings.excludetext}}
68-
</button>
69+
</a>
6970
<div class="dropdown-menu dropdown-menu-right"
7071
aria-labelledby="forum-action-menu-{{id}}-menu"
7172
data-rel="menu-content"

mod/forum/tests/behat/behat_mod_forum.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,66 @@ public function the_following_forum_replies_exist(string $coursename, TableNode
252252
}
253253
}
254254

255+
/**
256+
* Checks if the user can subscribe to the forum.
257+
*
258+
* @Given /^I can subscribe to this forum$/
259+
*/
260+
public function i_can_subscribe_to_this_forum() {
261+
if ($this->running_javascript()) {
262+
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
263+
}
264+
265+
$this->execute('behat_general::assert_page_contains_text', [get_string('subscribe', 'mod_forum')]);
266+
267+
if ($this->running_javascript()) {
268+
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
269+
}
270+
}
271+
272+
/**
273+
* Checks if the user can unsubscribe from the forum.
274+
*
275+
* @Given /^I can unsubscribe from this forum$/
276+
*/
277+
public function i_can_unsubscribe_from_this_forum() {
278+
if ($this->running_javascript()) {
279+
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
280+
}
281+
282+
$this->execute('behat_general::assert_page_contains_text', [get_string('unsubscribe', 'mod_forum')]);
283+
284+
if ($this->running_javascript()) {
285+
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
286+
}
287+
}
288+
289+
/**
290+
* Subscribes to the forum.
291+
*
292+
* @Given /^I subscribe to this forum$/
293+
*/
294+
public function i_subscribe_to_this_forum() {
295+
if ($this->running_javascript()) {
296+
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
297+
}
298+
299+
$this->execute('behat_general::click_link', [get_string('subscribe', 'mod_forum')]);
300+
}
301+
302+
/**
303+
* Unsubscribes from the forum.
304+
*
305+
* @Given /^I unsubscribe from this forum$/
306+
*/
307+
public function i_unsubscribe_from_this_forum() {
308+
if ($this->running_javascript()) {
309+
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
310+
}
311+
312+
$this->execute('behat_general::click_link', [get_string('unsubscribe', 'mod_forum')]);
313+
}
314+
255315
/**
256316
* Fetch user ID from its username.
257317
*

mod/forum/tests/behat/discussion_subscriptions.feature

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,29 @@ Feature: A user can control their own subscription preferences for a discussion
3434
When I log in as "student1"
3535
And I am on "Course 1" course homepage
3636
And I follow "Test forum name"
37-
Then I click on "Actions menu" "link"
38-
And I should see "Subscribe to this forum"
37+
Then I can subscribe to this forum
3938
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
4039
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
4140
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
42-
And I click on "Actions menu" "link"
43-
And I should see "Subscribe to this forum"
41+
And I can subscribe to this forum
4442
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
4543
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
4644
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
47-
And I click on "Actions menu" "link"
48-
And I should see "Subscribe to this forum"
45+
And I can subscribe to this forum
4946
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
5047
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
5148
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
52-
And I click on "Actions menu" "link"
53-
And I should see "Subscribe to this forum"
49+
And I can subscribe to this forum
5450
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
5551
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
56-
And I follow "Subscribe to this forum"
52+
And I subscribe to this forum
5753
And I should see "Student One will be notified of new posts in 'Test forum name'"
58-
And I click on "Actions menu" "link"
59-
And I should see "Unsubscribe from this forum"
54+
And I can unsubscribe from this forum
6055
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
6156
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
62-
And I follow "Unsubscribe from this forum"
57+
And I unsubscribe from this forum
6358
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
64-
And I click on "Actions menu" "link"
65-
And I should see "Subscribe to this forum"
59+
And I can subscribe to this forum
6660
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
6761
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
6862

@@ -83,35 +77,29 @@ Feature: A user can control their own subscription preferences for a discussion
8377
When I log in as "student1"
8478
And I am on "Course 1" course homepage
8579
And I follow "Test forum name"
86-
Then I click on "Actions menu" "link"
87-
And I should see "Unsubscribe from this forum"
80+
Then I can unsubscribe from this forum
8881
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
8982
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
9083
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
91-
And I click on "Actions menu" "link"
92-
And I should see "Unsubscribe from this forum"
84+
And I can unsubscribe from this forum
9385
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
9486
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
9587
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
96-
And I click on "Actions menu" "link"
97-
And I should see "Unsubscribe from this forum"
88+
And I can unsubscribe from this forum
9889
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
9990
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
10091
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
101-
And I click on "Actions menu" "link"
102-
And I should see "Unsubscribe from this forum"
92+
And I can unsubscribe from this forum
10393
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
10494
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
105-
And I follow "Unsubscribe from this forum"
95+
And I unsubscribe from this forum
10696
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
107-
And I click on "Actions menu" "link"
108-
And I should see "Subscribe to this forum"
97+
And I can subscribe to this forum
10998
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
11099
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
111-
And I follow "Subscribe to this forum"
100+
And I subscribe to this forum
112101
And I should see "Student One will be notified of new posts in 'Test forum name'"
113-
And I click on "Actions menu" "link"
114-
And I should see "Unsubscribe from this forum"
102+
And I can unsubscribe from this forum
115103
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
116104
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
117105

@@ -132,13 +120,11 @@ Feature: A user can control their own subscription preferences for a discussion
132120
And I log in as "student1"
133121
And I am on "Course 1" course homepage
134122
And I follow "Test forum name"
135-
And I click on "Actions menu" "link"
136-
And I should see "Subscribe to this forum"
123+
And I can subscribe to this forum
137124
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
138125
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
139126
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
140-
And I click on "Actions menu" "link"
141-
And I should see "Subscribe to this forum"
127+
And I can subscribe to this forum
142128
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
143129
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
144130
And I log out
@@ -153,14 +139,12 @@ Feature: A user can control their own subscription preferences for a discussion
153139
And I log in as "student1"
154140
And I am on "Course 1" course homepage
155141
And I follow "Test forum name"
156-
And I click on "Actions menu" "link"
157-
And I should see "Unsubscribe from this forum"
142+
And I can unsubscribe from this forum
158143
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
159144
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
160-
When I follow "Unsubscribe from this forum"
145+
When I unsubscribe from this forum
161146
Then I should see "Student One will NOT be notified of new posts in 'Test forum name'"
162-
And I click on "Actions menu" "link"
163-
And I should see "Subscribe to this forum"
147+
And I can subscribe to this forum
164148
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
165149
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
166150

@@ -181,13 +165,11 @@ Feature: A user can control their own subscription preferences for a discussion
181165
And I log in as "student1"
182166
And I am on "Course 1" course homepage
183167
And I follow "Test forum name"
184-
And I click on "Actions menu" "link"
185-
And I should see "Subscribe to this forum"
168+
And I can subscribe to this forum
186169
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
187170
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
188171
And I click on "label[for^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
189-
And I click on "Actions menu" "link"
190-
And I should see "Subscribe to this forum"
172+
And I can subscribe to this forum
191173
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
192174
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
193175
And I log out
@@ -202,14 +184,12 @@ Feature: A user can control their own subscription preferences for a discussion
202184
And I log in as "student1"
203185
And I am on "Course 1" course homepage
204186
And I follow "Test forum name"
205-
And I click on "Actions menu" "link"
206-
And I should see "Unsubscribe from this forum"
187+
And I can unsubscribe from this forum
207188
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
208189
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
209-
When I follow "Unsubscribe from this forum"
190+
When I unsubscribe from this forum
210191
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
211-
And I click on "Actions menu" "link"
212-
Then I should see "Subscribe to this forum"
192+
And I can subscribe to this forum
213193
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
214194
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
215195

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
* Step definitions related to mod_forum overrides for the Classic theme.
19+
*
20+
* @package theme_classic
21+
* @category test
22+
* @copyright 2019 Ryan Wyllie <ryan@moodle.com>
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
27+
28+
require_once(__DIR__ . '/../../../../mod/forum/tests/behat/behat_mod_forum.php');
29+
30+
/**
31+
* Step definitions related to mod_forum overrides for the Classic theme.
32+
*
33+
* @package theme_classic
34+
* @category test
35+
* @copyright 2019 Ryan Wyllie <ryan@moodle.com>
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class behat_theme_classic_behat_mod_forum extends behat_mod_forum {
39+
40+
/**
41+
* Checks if the user can subscribe to the forum.
42+
*/
43+
public function i_can_subscribe_to_this_forum() {
44+
$this->execute('behat_general::assert_page_contains_text', [get_string('subscribe', 'mod_forum')]);
45+
}
46+
47+
/**
48+
* Checks if the user can unsubscribe from the forum.
49+
*/
50+
public function i_can_unsubscribe_from_this_forum() {
51+
$this->execute('behat_general::assert_page_contains_text', [get_string('unsubscribe', 'mod_forum')]);
52+
}
53+
54+
/**
55+
* Subscribes to the forum.
56+
*/
57+
public function i_subscribe_to_this_forum() {
58+
$this->execute('behat_general::click_link', [get_string('subscribe', 'mod_forum')]);
59+
}
60+
61+
/**
62+
* Unsubscribes from the forum.
63+
*/
64+
public function i_unsubscribe_from_this_forum() {
65+
$this->execute('behat_general::click_link', [get_string('unsubscribe', 'mod_forum')]);
66+
}
67+
}

0 commit comments

Comments
 (0)