[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 @mod @mod_data 2 Feature: Users can be required to specify certain fields when adding entries to database activities 3 In order to constrain user input 4 As a teacher 5 I need to specify certain fields as required when I add entries to databases 6 7 Background: 8 Given the following "users" exist: 9 | username | firstname | lastname | email | 10 | student1 | Student | 1 | student1@example.com | 11 | teacher1 | Teacher | 1 | teacher1@example.com | 12 And the following "courses" exist: 13 | fullname | shortname | category | 14 | Course 1 | C1 | 0 | 15 And the following "course enrolments" exist: 16 | user | course | role | 17 | teacher1 | C1 | editingteacher | 18 | student1 | C1 | student | 19 And the following "activities" exist: 20 | activity | name | intro | course | idnumber | 21 | data | Test database name | n | C1 | data1 | 22 And I log in as "teacher1" 23 And I follow "Course 1" 24 And I add a "Text input" field to "Test database name" database and I fill the form with: 25 | Field name | Base Text input | 26 | Required | yes | 27 | Field description | Base Text input | 28 And I add a "Checkbox" field to "Test database name" database and I fill the form with: 29 | Field name | Required Checkbox | 30 | Field description | Required Checkbox | 31 | Required | yes | 32 | Options | Required Checkbox Option 1 | 33 And I follow "Fields" 34 And I select "Checkbox" from the "newtype" singleselect 35 And I set the following fields to these values: 36 | Field name | Required Two-Option Checkbox | 37 | Field description | Required Two-Option Checkbox | 38 | Required | yes | 39 And I set the field "Options" to multiline 40 """ 41 RTOC Option 1 42 RTOC Option 2 43 """ 44 And I press "Add" 45 And I add a "Latlong" field to "Test database name" database and I fill the form with: 46 | Field name | Required Latlong | 47 | Field description | Required Latlong | 48 | Required | yes | 49 And I add a "Menu" field to "Test database name" database and I fill the form with: 50 | Field name | Required Menu | 51 | Field description | Required Menu | 52 | Required | yes | 53 | Options | Option 1 | 54 And I add a "Number" field to "Test database name" database and I fill the form with: 55 | Field name | Required Number | 56 | Field description | Required Number | 57 | Required | yes | 58 And I add a "Radio button" field to "Test database name" database and I fill the form with: 59 | Field name | Required Radio | 60 | Field description | Required Radio | 61 | Required | yes | 62 | Options | Required Radio Option 1 | 63 And I add a "Text input" field to "Test database name" database and I fill the form with: 64 | Field name | Required Text input | 65 | Field description | Required Text input | 66 | Required | yes | 67 And I add a "Text area" field to "Test database name" database and I fill the form with: 68 | Field name | Required Text area | 69 | Field description | Required Text area | 70 | Required | yes | 71 And I add a "URL" field to "Test database name" database and I fill the form with: 72 | Field name | Required URL | 73 | Field description | Required URL | 74 | Required | yes | 75 And I add a "Multimenu" field to "Test database name" database and I fill the form with: 76 | Field name | Required Multimenu | 77 | Field description | Required Multimenu | 78 | Required | yes | 79 | Options | Option 1 | 80 And I follow "Fields" 81 And I select "Multimenu" from the "newtype" singleselect 82 And I set the following fields to these values: 83 | Field name | Required Two-Option Multimenu | 84 | Field description | Required Two-Option Multimenu | 85 | Required | yes | 86 And I set the field "Options" to multiline 87 """ 88 Option 1 89 Option 2 90 """ 91 And I press "Add" 92 And I add a "Checkbox" field to "Test database name" database and I fill the form with: 93 | Field name | Not required Checkbox | 94 | Field description | Not required Checkbox | 95 | Options | Not required Checkbox Option 1 | 96 And I add a "Latlong" field to "Test database name" database and I fill the form with: 97 | Field name | Not required Latlong | 98 | Field description | Not required Latlong | 99 And I add a "Menu" field to "Test database name" database and I fill the form with: 100 | Field name | Not required Menu | 101 | Field description | Not required Menu | 102 | Options | Option 1 | 103 And I add a "Number" field to "Test database name" database and I fill the form with: 104 | Field name | Not required Number | 105 | Field description | Not required Number | 106 And I add a "Radio button" field to "Test database name" database and I fill the form with: 107 | Field name | Not required Radio | 108 | Field description | Not required Radio | 109 | Options | Not required Radio Option 1 | 110 And I add a "Text input" field to "Test database name" database and I fill the form with: 111 | Field name | Not required Text input | 112 | Field description | Not required Text input | 113 And I add a "Text area" field to "Test database name" database and I fill the form with: 114 | Field name | Not required Text area | 115 | Field description | Not required Text area | 116 And I add a "URL" field to "Test database name" database and I fill the form with: 117 | Field name | Not required URL | 118 | Field description | Not required URL | 119 And I add a "Multimenu" field to "Test database name" database and I fill the form with: 120 | Field name | Not required Multimenu | 121 | Field description | Not required Multimenu | 122 | Options | Option 1 | 123 And I follow "Templates" 124 And I log out 125 126 Scenario: Students receive errors for empty required fields but not for optional fields 127 When I log in as "student1" 128 And I follow "Course 1" 129 And I add an entry to "Test database name" database with: 130 | Base Text input | Some input to allow us to submit the otherwise empty form | 131 And I press "Save and view" 132 Then ".alert.alert-error" "css_element" should exist in the "Required Checkbox" "table_row" 133 And ".alert.alert-error" "css_element" should exist in the "Required Two-Option Checkbox" "table_row" 134 And ".alert.alert-error" "css_element" should exist in the "Required Latlong" "table_row" 135 And ".alert.alert-error" "css_element" should exist in the "Required Menu" "table_row" 136 And ".alert.alert-error" "css_element" should exist in the "Required Number" "table_row" 137 And ".alert.alert-error" "css_element" should exist in the "Required Radio" "table_row" 138 And ".alert.alert-error" "css_element" should exist in the "Required Text input" "table_row" 139 And ".alert.alert-error" "css_element" should exist in the "Required Text area" "table_row" 140 And ".alert.alert-error" "css_element" should exist in the "Required URL" "table_row" 141 And ".alert.alert-error" "css_element" should exist in the "Required Multimenu" "table_row" 142 And ".alert.alert-error" "css_element" should exist in the "Required Two-Option Multimenu" "table_row" 143 And ".alert.alert-error" "css_element" should not exist in the "Not required Checkbox" "table_row" 144 And ".alert.alert-error" "css_element" should not exist in the "Not required Latlong" "table_row" 145 And ".alert.alert-error" "css_element" should not exist in the "Not required Menu" "table_row" 146 And ".alert.alert-error" "css_element" should not exist in the "Not required Number" "table_row" 147 And ".alert.alert-error" "css_element" should not exist in the "Not required Radio" "table_row" 148 And ".alert.alert-error" "css_element" should not exist in the "Not required Text input" "table_row" 149 And ".alert.alert-error" "css_element" should not exist in the "Not required Text area" "table_row" 150 And ".alert.alert-error" "css_element" should not exist in the "Not required URL" "table_row" 151 And ".alert.alert-error" "css_element" should not exist in the "Not required Multimenu" "table_row" 152 And I follow "View list" 153 And I should see "No entries in database" 154 155 Scenario: Students recieve no error for filled in required fields 156 When I log in as "student1" 157 And I follow "Course 1" 158 And I add an entry to "Test database name" database with: 159 | Base Text input | Some input to allow us to submit the otherwise empty form | 160 | Required Checkbox Option 1 | 1 | 161 | RTOC Option 1 | 1 | 162 | Latitude | 0 | 163 | Longitude | 0 | 164 | Required Menu | 1 | 165 | Required Number | 1 | 166 | Required Radio Option 1 | 1 | 167 | Required Text input | New entry text | 168 | Required Text area | More text | 169 | Required URL | http://example.com/ | 170 | Required Multimenu | 1 | 171 | Required Two-Option Multimenu | 1 | 172 And I press "Save and view" 173 And I follow "View list" 174 Then I should not see "No entries in database" 175 And I should see "New entry text" 176 177 Scenario: Fields refill with data after having an error 178 When I log in as "student1" 179 And I follow "Course 1" 180 And I add an entry to "Test database name" database with: 181 | RTOC Option 1 | 1 | 182 | Latitude | 0 | 183 | Longitude | 0 | 184 | Required Menu | 1 | 185 | Required Number | 1 | 186 | Required Radio Option 1 | 1 | 187 | Required Text input | New entry text | 188 | Required Text area | More text | 189 | Required URL | http://example.com/ | 190 | Required Multimenu | 1 | 191 | Required Two-Option Multimenu | 1 | 192 And I press "Save and view" 193 Then the following fields match these values: 194 | Base Text input | | 195 | Latitude | 0 | 196 | Longitude | 0 | 197 | Required Menu | Option 1 | 198 | Required Number | 1 | 199 | Required Radio Option 1 | 1 | 200 | Required Text input | New entry text | 201 | Required Text area | More text | 202 | Required URL | http://example.com/ | 203 | Required Multimenu | Option 1 | 204 | Required Two-Option Multimenu | Option 1 | 205 206 Scenario: A student fills in Latitude but not Longitude will see an error 207 Given I log in as "student1" 208 And I follow "Course 1" 209 When I add an entry to "Test database name" database with: 210 | Base Text input | Some input to allow us to submit the otherwise empty form | 211 | Required Checkbox Option 1 | 1 | 212 | RTOC Option 1 | 1 | 213 | Latitude | 24 | 214 | Required Menu | 1 | 215 | Required Number | 1 | 216 | Required Radio Option 1 | 1 | 217 | Required Text input | New entry text | 218 | Required Text area | More text | 219 | Required URL | http://example.com/ | 220 | Required Multimenu | 1 | 221 | Required Two-Option Multimenu | 1 | 222 And I set the field with xpath "//div[@title='Not required Latlong']//tr[td/label[normalize-space(.)='Latitude']]/td/input" to "20" 223 And I press "Save and view" 224 Then ".alert.alert-error" "css_element" should exist in the "Required Latlong" "table_row" 225 And ".alert.alert-error" "css_element" should exist in the "Not required Latlong" "table_row" 226 227 Scenario: A student filling in number and text fields with zero will not see an error. 228 Given I log in as "student1" 229 And I follow "Course 1" 230 When I add an entry to "Test database name" database with: 231 | Base Text input | Some input to allow us to submit the otherwise empty form | 232 | Required Checkbox Option 1 | 1 | 233 | RTOC Option 1 | 1 | 234 | Latitude | 0 | 235 | Longitude | 0 | 236 | Required Menu | 1 | 237 | Required Number | 0 | 238 | Required Radio Option 1 | 1 | 239 | Required Text input | 0 | 240 | Required Text area | 0 | 241 | Required URL | http://example.com/ | 242 | Required Multimenu | 1 | 243 | Required Two-Option Multimenu | 1 | 244 And I press "Save and view" 245 And I follow "View list" 246 Then I should not see "No entries in database" 247 And I should see "Some input to allow us to submit the otherwise empty form"
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |