Skip to content

Commit 353e787

Browse files
author
gthomas2
committed
MDL-58052 behat: user session function - use to edit current profile
1 parent 3c45d26 commit 353e787

File tree

29 files changed

+119
-83
lines changed

29 files changed

+119
-83
lines changed

admin/tool/behat/tests/behat/manipulate_forms.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Feature: Forms manipulation
77
@javascript
88
Scenario: Basic forms manipulation
99
Given I log in as "admin"
10-
And I follow "Preferences" in the user menu
11-
And I click on "Edit profile" "link" in the "region-main" "region"
10+
And I open my profile in edit mode
1211
When I set the field "First name" to "Field value"
1312
And I set the field "Select a country" to "Japan"
1413
And I set the field "New password" to "TestPass"

admin/tool/behat/tests/behat/nasty_strings.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Feature: Transform steps arguments
1010
| fullname | shortname | category |
1111
| Course 1 | C1 | 0 |
1212
And I log in as "admin"
13-
And I follow "Preferences" in the user menu
14-
And I click on "Edit profile" "link" in the "region-main" "region"
13+
And I open my profile in edit mode
1514

1615
Scenario: Use nasty strings on steps arguments
1716
When I set the field "Surname" to "$NASTYSTRING1"

badges/tests/behat/award_badge.feature

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ Feature: Award badges
3030
And I should not see "Criteria for this badge have not been set up yet."
3131
And I press "Enable access"
3232
And I press "Continue"
33-
And I click on "Admin User" "link"
34-
And I choose "Profile" in the open action menu
35-
And I click on "Edit profile" "link" in the "region-main" "region"
33+
And I open my profile in edit mode
3634
And I expand all fieldsets
3735
And I set the field "Phone" to "123456789"
3836
And I press "Update profile"

course/tests/behat/navigate_course_list.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ Feature: Browse course list and return back from enrolment page
4242
And I press "Save changes"
4343
And I log out
4444
When I log in as "user2"
45-
And I follow "Preferences" in the user menu
46-
And I click on "Edit profile" "link" in the "region-main" "region"
45+
And I open my profile in edit mode
4746
And I expand "Courses" node
4847
And I expand "Sample category" node
4948
And I follow "Course 1"

lib/behat/behat_base.php

+19
Original file line numberDiff line numberDiff line change
@@ -925,4 +925,23 @@ protected function execute($contextapi, $params = array()) {
925925
// Look for exceptions.
926926
$this->look_for_exceptions();
927927
}
928+
929+
/**
930+
* Get the actual user in the behat session (note $USER does not correspond to the behat session's user).
931+
* @return mixed
932+
* @throws coding_exception
933+
*/
934+
protected function get_session_user() {
935+
global $DB;
936+
937+
$sid = $this->getSession()->getCookie('MoodleSession');
938+
if (empty($sid)) {
939+
throw new coding_exception('failed to get moodle session');
940+
}
941+
$userid = $DB->get_field('sessions', 'userid', ['sid' => $sid]);
942+
if (empty($userid)) {
943+
throw new coding_exception('failed to get user from seession id '.$sid);
944+
}
945+
return $DB->get_record('user', ['id' => $userid]);
946+
}
928947
}

lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature

+6-12
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto accessibility checker
55
@javascript
66
Scenario: Images with no alt
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "<p>Some plain text</p><img src='/broken-image' width='1' height='1'/><p>Some more text</p>"
1110
When I click on "Show more buttons" "button"
1211
And I click on "Accessibility checker" "button"
@@ -31,8 +30,7 @@ Feature: Atto accessibility checker
3130
@javascript
3231
Scenario: Low contrast
3332
Given I log in as "admin"
34-
And I follow "Profile" in the user menu
35-
And I click on "Edit profile" "link" in the "region-main" "region"
33+
And I open my profile in edit mode
3634
And I set the field "Description" to "<p style='color: #7c7cff; background-color: #ffffff;'>Hard to read</p>"
3735
When I click on "Show more buttons" "button"
3836
And I click on "Accessibility checker" "button"
@@ -41,8 +39,7 @@ Feature: Atto accessibility checker
4139
@javascript
4240
Scenario: No headings
4341
Given I log in as "admin"
44-
And I follow "Profile" in the user menu
45-
And I click on "Edit profile" "link" in the "region-main" "region"
42+
And I open my profile in edit mode
4643
And I set the field "Description" to "<p>Sweet roll oat cake jelly-o macaroon donut oat cake. Caramels macaroon cookie sweet roll croissant cheesecake candy jelly-o. Gummies sugar plum sugar plum gingerbread dessert. Tiramisu bonbon jujubes danish marshmallow cookie chocolate cake cupcake tiramisu. Bear claw oat cake chocolate bar croissant. Lollipop cookie topping liquorice croissant. Brownie cookie cupcake lollipop cupcake cupcake. Fruitcake dessert sweet biscuit dragée caramels marzipan brownie. Chupa chups gingerbread apple pie cookie liquorice caramels carrot cake cookie gingerbread. Croissant candy jelly beans. Tiramisu apple pie dessert apple pie macaroon soufflé. Brownie powder carrot cake chocolate. Tart applicake croissant dragée macaroon chocolate donut.</p><p>Jelly beans gingerbread tootsie roll. Sugar plum tiramisu cotton candy toffee pie cotton candy tiramisu. Carrot cake chocolate bar sesame snaps cupcake cake dessert sweet fruitcake wafer. Marshmallow cupcake gingerbread pie sweet candy canes powder gummi bears. Jujubes cake muffin marshmallow candy jelly beans tootsie roll pie. Gummi bears applicake chocolate cake sweet jelly sesame snaps lollipop lollipop carrot cake. Marshmallow cake jelly beans. Jelly beans sesame snaps muffin halvah cookie ice cream candy canes carrot cake. Halvah donut marshmallow tiramisu. Cookie dessert gummi bears. Sugar plum apple pie jelly beans gummi bears tart chupa chups. Liquorice macaroon gummi bears gummies macaroon marshmallow sweet roll cake topping. Lemon drops caramels pie icing danish. Chocolate cake oat cake dessert halvah danish carrot cake apple pie.</p>"
4744
When I click on "Show more buttons" "button"
4845
And I click on "Accessibility checker" "button"
@@ -51,8 +48,7 @@ Feature: Atto accessibility checker
5148
@javascript
5249
Scenario: Merged cells
5350
Given I log in as "admin"
54-
And I follow "Profile" in the user menu
55-
And I click on "Edit profile" "link" in the "region-main" "region"
51+
And I open my profile in edit mode
5652
And I set the field "Description" to "<table><caption>Dogs that look good in pants</caption><tr><th>Breed</th><th>Coolness</th></tr><tr><td>Poodle</td><td rowspan='2'>NOT COOL</td></tr><tr><td>Doberman</td></tr></table>"
5753
When I click on "Show more buttons" "button"
5854
And I click on "Accessibility checker" "button"
@@ -61,8 +57,7 @@ Feature: Atto accessibility checker
6157
@javascript
6258
Scenario: Table missing row/column headers
6359
Given I log in as "admin"
64-
And I follow "Profile" in the user menu
65-
And I click on "Edit profile" "link" in the "region-main" "region"
60+
And I open my profile in edit mode
6661
And I set the field "Description" to "<table><caption>Dogs that look good in pants</caption><tr><th>Breed</th><td>Coolness</td></tr><tr><td>Poodle</td><td>NOT COOL</td></tr><tr><td>Doberman</td><td>COOL</td></tr></table>"
6762
When I click on "Show more buttons" "button"
6863
And I click on "Accessibility checker" "button"
@@ -71,8 +66,7 @@ Feature: Atto accessibility checker
7166
@javascript
7267
Scenario: Table missing caption
7368
Given I log in as "admin"
74-
And I follow "Profile" in the user menu
75-
And I click on "Edit profile" "link" in the "region-main" "region"
69+
And I open my profile in edit mode
7670
And I set the field "Description" to "<table><tr><th>Breed</th><th>Coolness</th></tr><tr><td>Poodle</td><td>NOT COOL</td></tr><tr><td>Doberman</td><td>COOL</td></tr></table>"
7771
When I click on "Show more buttons" "button"
7872
And I click on "Accessibility checker" "button"

lib/editor/atto/plugins/accessibilityhelper/tests/behat/accessibilityhelper.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto accessibility helper
55
@javascript
66
Scenario: Images and links
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "<p>Some plain text</p><img src='/broken-image' alt='Image 1'/><p><a href='#fsd'>Some link text</a></p>"
1110
And I select the text in the "Description" Atto editor
1211
When I click on "Show more buttons" "button"
@@ -21,8 +20,7 @@ Feature: Atto accessibility helper
2120
@javascript
2221
Scenario: Styles
2322
Given I log in as "admin"
24-
And I follow "Profile" in the user menu
25-
And I click on "Edit profile" "link" in the "region-main" "region"
23+
And I open my profile in edit mode
2624
And I set the field "Description" to "<p>Some plain text</p>"
2725
When I click on "Show more buttons" "button"
2826
And I select the text in the "Description" Atto editor

lib/editor/atto/plugins/align/tests/behat/align.feature

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto align text
55
@javascript
66
Scenario: Right align some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "<p>Fascism</p>"
1110
And I click on "Show more buttons" "button"
1211
And I select the text in the "Description" Atto editor
@@ -22,8 +21,7 @@ Feature: Atto align text
2221
@javascript
2322
Scenario: Left align some text
2423
Given I log in as "admin"
25-
And I follow "Profile" in the user menu
26-
And I click on "Edit profile" "link" in the "region-main" "region"
24+
And I open my profile in edit mode
2725
And I set the field "Description" to "<p>Communism</p>"
2826
And I click on "Show more buttons" "button"
2927
And I select the text in the "Description" Atto editor
@@ -40,8 +38,7 @@ Feature: Atto align text
4038
@javascript
4139
Scenario: Center align some text
4240
Given I log in as "admin"
43-
And I follow "Profile" in the user menu
44-
And I click on "Edit profile" "link" in the "region-main" "region"
41+
And I open my profile in edit mode
4542
And I set the field "Description" to "<p>United Future</p>"
4643
And I click on "Show more buttons" "button"
4744
And I select the text in the "Description" Atto editor

lib/editor/atto/plugins/bold/tests/behat/bold.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto bold button
55
@javascript
66
Scenario: Bold some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Badger"
1110
And I select the text in the "Description" Atto editor
1211
When I click on "Bold" "button"
@@ -21,8 +20,7 @@ Feature: Atto bold button
2120
@javascript
2221
Scenario: Unbold some text
2322
Given I log in as "admin"
24-
And I follow "Profile" in the user menu
25-
And I click on "Edit profile" "link" in the "region-main" "region"
23+
And I open my profile in edit mode
2624
And I set the field "Description" to "Mouse"
2725
And I select the text in the "Description" Atto editor
2826
When I click on "Bold" "button"

lib/editor/atto/plugins/charmap/tests/behat/charmap.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto charmap button
55
@javascript
66
Scenario: Insert symbols
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "<p>1980 Mullet</p>"
1110
And I select the text in the "Description" Atto editor
1211
When I click on "Show more buttons" "button"

lib/editor/atto/plugins/clear/tests/behat/clear.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto clear button
55
@javascript
66
Scenario: Clear formatting
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Pisa"
1110
And I select the text in the "Description" Atto editor
1211
And I click on "Italic" "button"

lib/editor/atto/plugins/collapse/tests/behat/collapse.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto collapse button
55
@javascript
66
Scenario: Toggle toolbar
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
When I click on "Show more buttons" "button"
1110
Then "Equation editor" "button" should be visible
1211
And I click on "Show fewer buttons" "button"

lib/editor/atto/plugins/equation/tests/behat/equation.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto equation editor
55
@javascript
66
Scenario: Create an equation
77
Given I log in as "admin"
8-
When I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
When I open my profile in edit mode
109
And I set the field "Description" to "<p>Equation test</p>"
1110
# Set field on the bottom of page, so equation editor dialogue is visible.
1211
And I expand all fieldsets
@@ -24,8 +23,7 @@ Feature: Atto equation editor
2423
@javascript
2524
Scenario: Edit an equation
2625
Given I log in as "admin"
27-
When I follow "Profile" in the user menu
28-
And I click on "Edit profile" "link" in the "region-main" "region"
26+
When I open my profile in edit mode
2927
And I set the field "Description" to "<p>\( \pi \)</p>"
3028
# Set field on the bottom of page, so equation editor dialogue is visible.
3129
And I expand all fieldsets

lib/editor/atto/plugins/html/tests/behat/html.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto edit HTML
55
@javascript
66
Scenario: Edit the html source
77
Given I log in as "admin"
8-
When I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
When I open my profile in edit mode
109
And I set the field "Description" to "<p style=\"color: blue;\">Smurf</p>"
1110
And I click on "Show more buttons" "button"
1211
And I click on "HTML" "button"

lib/editor/atto/plugins/image/tests/behat/image.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Feature: Add images to Atto
88
And I follow "Manage private files..."
99
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
1010
And I click on "Save changes" "button"
11-
And I follow "Profile" in the user menu
12-
And I click on "Edit profile" "link" in the "region-main" "region"
11+
And I open my profile in edit mode
1312
When I set the field "Description" to "<p>Image test</p>"
1413
And I select the text in the "Description" Atto editor
1514
And I click on "Image" "button"
@@ -52,8 +51,7 @@ Feature: Add images to Atto
5251
@javascript
5352
Scenario: Manually inserting an image
5453
Given I log in as "admin"
55-
And I follow "Profile" in the user menu
56-
And I click on "Edit profile" "link" in the "region-main" "region"
54+
And I open my profile in edit mode
5755
And I set the field "Description" to "<p>Image: <img src='/nothing/here'>.</p>"
5856
And I select the text in the "Description" Atto editor
5957
When I click on "Image" "button"

lib/editor/atto/plugins/indent/tests/behat/indent.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Feature: Indent text in Atto
2222
@javascript
2323
Scenario: Indent and outdent
2424
Given I log in as "admin"
25-
And I follow "Profile" in the user menu
26-
When I click on "Edit profile" "link" in the "region-main" "region"
25+
And I open my profile in edit mode
2726
And I set the field "Description" to "<p>I need some space.</p>"
2827
And I select the text in the "Description" Atto editor
2928
And I click on "Show more buttons" "button"

lib/editor/atto/plugins/italic/tests/behat/italic.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto italic button
55
@javascript
66
Scenario: Italicise some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Tower of Pisa"
1110
And I select the text in the "Description" Atto editor
1211
When I click on "Italic" "button"
@@ -21,8 +20,7 @@ Feature: Atto italic button
2120
@javascript
2221
Scenario: Toggle italics in some text
2322
Given I log in as "admin"
24-
And I follow "Profile" in the user menu
25-
And I click on "Edit profile" "link" in the "region-main" "region"
23+
And I open my profile in edit mode
2624
And I set the field "Description" to "GHD - for hair"
2725
And I select the text in the "Description" Atto editor
2826
When I click on "Italic" "button"

lib/editor/atto/plugins/link/tests/behat/link.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Feature: Add links to Atto
88
And I follow "Manage private files..."
99
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
1010
And I click on "Save changes" "button"
11-
When I follow "Profile" in the user menu
12-
And I click on "Edit profile" "link" in the "region-main" "region"
11+
When I open my profile in edit mode
1312
And I set the field "Description" to "Super cool"
1413
And I select the text in the "Description" Atto editor
1514
And I click on "Link" "button"

lib/editor/atto/plugins/orderedlist/tests/behat/orderedlist.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto ordered list button
55
@javascript
66
Scenario: Make a list from some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Have you heard the news everyone's talking<br/> Life is good 'cause everything's awesome<br/>"
1110
And I select the text in the "Description" Atto editor
1211
When I click on "Ordered list" "button"

lib/editor/atto/plugins/strike/tests/behat/strike.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto strike button
55
@javascript
66
Scenario: Strike some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "MUA"
1110
And I select the text in the "Description" Atto editor
1211
And I click on "Show more buttons" "button"

lib/editor/atto/plugins/subscript/tests/behat/subscript.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto subscript button
55
@javascript
66
Scenario: Subscript some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Submarine"
1110
And I select the text in the "Description" Atto editor
1211
And I click on "Show more buttons" "button"
@@ -22,8 +21,7 @@ Feature: Atto subscript button
2221
@javascript
2322
Scenario: Subscript some text in enclosed in superscript
2423
Given I log in as "admin"
25-
And I follow "Profile" in the user menu
26-
And I click on "Edit profile" "link" in the "region-main" "region"
24+
And I open my profile in edit mode
2725
And I set the field "Description" to "<sup>Submarine</sup>"
2826
And I select the text in the "Description" Atto editor
2927
And I click on "Show more buttons" "button"

lib/editor/atto/plugins/superscript/tests/behat/superscript.feature

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto superscript button
55
@javascript
66
Scenario: Subscript some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Helicopter"
1110
And I select the text in the "Description" Atto editor
1211
And I click on "Show more buttons" "button"
@@ -22,8 +21,7 @@ Feature: Atto superscript button
2221
@javascript
2322
Scenario: Superscript some text that is enclosed in subscript
2423
Given I log in as "admin"
25-
And I follow "Profile" in the user menu
26-
And I click on "Edit profile" "link" in the "region-main" "region"
24+
And I open my profile in edit mode
2725
And I set the field "Description" to "<sub>Helicopter</sub>"
2826
And I select the text in the "Description" Atto editor
2927
And I click on "Show more buttons" "button"

lib/editor/atto/plugins/title/tests/behat/title.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto title
55
@javascript
66
Scenario: Create a heading
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "How The Rock Has Made the WWE World Heavyweight Title More Important Than Ever"
1110
And I select the text in the "Description" Atto editor
1211
When I click on "Paragraph styles" "button"

lib/editor/atto/plugins/underline/tests/behat/underline.feature

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Feature: Atto underline button
55
@javascript
66
Scenario: Underline some text
77
Given I log in as "admin"
8-
And I follow "Profile" in the user menu
9-
And I click on "Edit profile" "link" in the "region-main" "region"
8+
And I open my profile in edit mode
109
And I set the field "Description" to "Deprecated HTML Tag"
1110
And I select the text in the "Description" Atto editor
1211
And I click on "Show more buttons" "button"

0 commit comments

Comments
 (0)