Commit bed97c39 authored by Rajesh Taneja's avatar Rajesh Taneja
Browse files

MDL-49513 behat: Set admin config using php api

Added a new set to set config using set_config() api
to make steps faster and more efficient
parent 20d38830
......@@ -114,6 +114,30 @@ class behat_admin extends behat_base {
}
}
/**
* 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.
*
......
......@@ -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"
\ No newline at end of file
......@@ -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"
......@@ -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"
......
......@@ -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"
......@@ -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"
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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"
......@@ -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
......@@ -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
......
......@@ -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:
......@@ -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"
......@@ -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:
......@@ -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"
......
......@@ -34,6 +34,8 @@ 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
......@@ -41,8 +43,6 @@ Feature: Expand the courses nodes within the navigation 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
......
......@@ -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"
......@@ -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"
......
......@@ -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"
......@@ -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"
......@@ -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"
......
......@@ -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
......
......@@ -17,11 +17,9 @@ Feature: Allow students to manually mark an activity as complete
| 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 |
| Enable conditional access | 1 |
And I log out
And the following config values are set as admin:
| enablecompletion | 1 |
| enableavailability | 1 |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
......
......@@ -16,10 +16,8 @@ Feature: Restrict activity availability through date conditions
| 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 |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
......
......@@ -17,10 +17,8 @@ Feature: Restrict activity availability through grade conditions
| 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 |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment