Skip to content

Commit

Permalink
MDL-49513 behat: Set admin config using php api
Browse files Browse the repository at this point in the history
Added a new set to set config using set_config() api
to make steps faster and more efficient
  • Loading branch information
Rajesh Taneja committed Apr 1, 2015
1 parent 20d3883 commit bed97c3
Show file tree
Hide file tree
Showing 47 changed files with 187 additions and 254 deletions.
24 changes: 24 additions & 0 deletions admin/tests/behat/behat_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ public function i_set_the_following_administration_settings_values(TableNode $ta
}
}

/**
* Sets the specified site settings. A table with | config | value | (optional)plugin | is expected.
*
* @Given /^the following config values are set as admin:$/
* @param TableNode $table
*/
public function the_following_config_values_are_set_as_admin(TableNode $table) {

if (!$data = $table->getRowsHash()) {
return;
}

foreach ($data as $config => $value) {
// Default plugin value is null.
$plugin = null;

if (is_array($value)) {
$plugin = $value[1];
$value = $value[0];
}
set_config($config, $value, $plugin);
}
}

/**
* Waits with the provided params if we are running a JS session.
*
Expand Down
8 changes: 3 additions & 5 deletions admin/tests/behat/set_admin_settings_value.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ Feature: Set admin settings value
And I should not see "C_shortname Course fullname"

Scenario: set admin value with full name
Given I set the following administration settings values:
| Display extended course names | 1 |
When I press "Save changes"
Given the following config values are set as admin:
| courselistshortnames | 1 |
And I am on homepage
Then I should see "C_shortname Course fullname"

Scenario: set admin value with short name
Given I set the following administration settings values:
Given the following config values are set as admin:
| courselistshortnames | 1 |
When I press "Save changes"
And I am on homepage
Then I should see "C_shortname Course fullname"
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Feature: Manage availability conditions
Then I should not see "Availability restrictions"

# Enable it and check I can now see and click on it.
And I set the following administration settings values:
| Enable conditional access | 1 |
And the following config values are set as admin:
| enableavailability | 1 |
And I am on homepage
And I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"

Expand All @@ -28,9 +28,9 @@ Feature: Manage availability conditions
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following config values are set as admin:
| enableavailability | 1 |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I am on homepage
When I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"

Expand Down
8 changes: 4 additions & 4 deletions admin/tool/behat/tests/behat/data_generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ Feature: Set up contextual data for tests
And the following "grade outcomes" exist:
| fullname | shortname | course | scale |
| Grade outcome 2 | OT2 | C1 | Test Scale 1 |
And the following config settings values are set as admin:
| enableoutcomes | 1 |
When I log in as "admin"
And I set the following administration settings values:
| Enable outcomes | 1 |
And I follow "Home"
And I follow "Course 1"
And I follow "Outcomes"
Expand All @@ -414,9 +414,9 @@ Feature: Set up contextual data for tests
And the following "grade items" exist:
| itemname | course | outcome | gradecategory |
| Test Outcome Grade Item 1 | C1 | OT1 | Grade category 1 |
And the following config settings values are set as admin:
| enableoutcomes | 1 |
When I log in as "admin"
And I set the following administration settings values:
| Enable outcomes | 1 |
And I follow "Home"
And I follow "Course 1"
And I follow "Grades"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ Feature: availability_completion
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
| Enable completion tracking | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |
| enablecompletion | 1 |

@javascript
Scenario: Test condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ Feature: availability_date
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |

@javascript
Scenario: Test condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ Feature: availability_grade
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |

@javascript
Scenario: Test condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ Feature: availability_group
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |

@javascript
Scenario: Test condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ Feature: availability_grouping
And the following "group members" exist:
| user | group |
| student1 | GI1 |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |

@javascript
Scenario: Test condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ Feature: availability_profile
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |

@javascript
Scenario: Test condition
Expand Down
6 changes: 2 additions & 4 deletions availability/tests/behat/display_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ Feature: display_availability
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enableavailability | 1 |

@javascript
Scenario: Activity availability display
Expand Down
27 changes: 9 additions & 18 deletions availability/tests/behat/edit_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ Feature: edit_availability
When I edit the section "1"
Then "Restrict access" "fieldset" should not exist

When I log out
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And the following config values are set as admin:
| enableavailability | 1 |

When I log out
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Page" to section "1"
Then "Restrict access" "fieldset" should exist

Expand All @@ -58,10 +53,8 @@ Feature: edit_availability
@javascript
Scenario: Edit availability using settings in activity form
# Set up.
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
Given the following config values are set as admin:
| enableavailability | 1 |
And I log in as "teacher1"
And I follow "Course 1"

Expand Down Expand Up @@ -153,10 +146,8 @@ Feature: edit_availability
@javascript
Scenario: Edit availability using settings in section form
# Set up.
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
Given the following config values are set as admin:
| enableavailability | 1 |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
Expand Down Expand Up @@ -186,12 +177,12 @@ Feature: edit_availability
@javascript
Scenario: Use the 'Add group/grouping access restriction' button
# Button should initially be disabled.
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
Given the following config values are set as admin:
| enableavailability | 1 |
And the following "groupings" exist:
| name | course | idnumber |
| GX1 | C1 | GXI1 |
And I log in as "admin"
And I am on homepage
And I follow "Course 1"
And I turn editing mode on
Expand Down
18 changes: 6 additions & 12 deletions badges/tests/behat/award_badge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ Feature: Award badges
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable completion tracking | 1 |
And I follow "Home"
And the following config values are set as admin:
| enablecompletion | 1 |
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Edit settings"
And I set the following fields to these values:
Expand All @@ -141,8 +140,6 @@ Feature: Award badges
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Submit your online text |
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Add a new badge" node in "Course administration > Badges"
And I follow "Add a new badge"
Expand Down Expand Up @@ -181,10 +178,9 @@ Feature: Award badges
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Enable completion tracking | 1 |
And I follow "Home"
And the following config values are set as admin:
| enablecompletion | 1 |
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Edit settings"
And I set the following fields to these values:
Expand All @@ -200,8 +196,6 @@ Feature: Award badges
And I click on "Condition: Activity completion" "link"
And I set the field "Assign - Test assignment name" to "1"
And I press "Save changes"
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I navigate to "Add a new badge" node in "Course administration > Badges"
And I follow "Add a new badge"
Expand Down
4 changes: 2 additions & 2 deletions blocks/navigation/tests/behat/expand_courses_node.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ Feature: Expand the courses nodes within the navigation block
| student1 | c1 | student |
| student1 | c2 | student |
| student1 | c4 | student |
And the following config settings values are set as admin:
| navshowallcourses | 1 |
And I log in as "admin"
And I follow "Course 2"
And I turn editing mode on
And I click on "Edit settings" "link" in the "Administration" "block"
And I set the following fields to these values:
| Allow guest access | Yes |
And I press "Save and display"
And I set the following administration settings values:
| Show all courses | 1 |
And I log out

@javascript
Expand Down
12 changes: 4 additions & 8 deletions blocks/navigation/tests/behat/expand_my_courses_setting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ Feature: Test expand my courses navigation setting

@javascript
Scenario: The My Courses branch is collapsed when expand my courses is off
Given I log in as "admin"
And I set the following administration settings values:
| Show My courses expanded on My home | 0 |
And I log out
Given the following config values are set as admin:
| navexpandmycourses | 0 |
When I log in as "student1"
And I click on "My home" "link" in the "Navigation" "block"
Then I should not see "c1" in the "Navigation" "block"
Expand All @@ -41,10 +39,8 @@ Feature: Test expand my courses navigation setting

@javascript
Scenario: My Courses can be expanded on the My Moodle page when expand my courses is off
Given I log in as "admin"
And I set the following administration settings values:
| Show My courses expanded on My home | 0 |
And I log out
Given the following config values are set as admin:
| navexpandmycourses | 0 |
When I log in as "student1"
And I click on "My home" "link" in the "Navigation" "block"
And I should not see "c1" in the "Navigation" "block"
Expand Down
18 changes: 7 additions & 11 deletions blocks/navigation/tests/behat/view_my_courses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ Feature: View my courses in navigation block
| student1 | c1 | student |
| student1 | c31 | student |
| student1 | c331 | student |
And I log in as "admin"

@javascript
Scenario: The plain list of enrolled courses is shown
Given I set the following administration settings values:
| Show my course categories | 0 |
And I log out
Given the following config values are set as admin:
| navshowmycoursecategories | 0 |
And I log in as "student1"
When I click on "My home" "link" in the "Navigation" "block"
Then I should not see "cat1" in the "Navigation" "block"
Expand All @@ -49,9 +47,8 @@ Feature: View my courses in navigation block

@javascript
Scenario: The nested list of enrolled courses is shown
Given I set the following administration settings values:
| Show my course categories | 1 |
And I log out
Given the following config values are set as admin:
| navshowmycoursecategories | 1 |
And I log in as "student1"
When I click on "My home" "link" in the "Navigation" "block"
Then I should see "cat1" in the "Navigation" "block"
Expand All @@ -69,10 +66,9 @@ Feature: View my courses in navigation block

@javascript
Scenario: I can expand categories and courses as guest
Given I set the following administration settings values:
| Show my course categories | 1 |
| Show all courses | 1 |
And I log out
Given the following config values are set as admin:
| navshowmycoursecategories | 1 |
| navshowallcourses | 1 |
And I expand "Courses" node
And I should see "cat1" in the "Navigation" "block"
And I should see "cat2" in the "Navigation" "block"
Expand Down
6 changes: 2 additions & 4 deletions blocks/recent_activity/tests/behat/structural_changes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ Feature: View structural changes in recent activity block
| GG3 | G2 |

Scenario: Check that Added module information is displayed respecting view capability
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
Given the following config values are set as admin:
| enableavailability | 1 |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
Expand Down
Loading

0 comments on commit bed97c3

Please sign in to comment.