MDL-53194 tool_lp: Behat tests linking evidence and competencies

This commit is contained in:
Serge Gauthier 2016-03-08 09:37:05 -05:00 committed by Frederic Massart
parent 3ed982e143
commit 75cbdd979b
2 changed files with 121 additions and 1 deletions

View file

@ -71,6 +71,14 @@ class behat_tool_lp_data_generators extends behat_base {
'userevidence' => array(
'datagenerator' => 'user_evidence',
'required' => array('user')
),
'plancompetencies' => array(
'datagenerator' => 'plan_competency',
'required' => array('plan', 'competency')
),
'userevidencecompetencies' => array(
'datagenerator' => 'user_evidence_competency',
'required' => array('userevidence', 'competency')
)
);
@ -194,7 +202,7 @@ class behat_tool_lp_data_generators extends behat_base {
* @return array
*/
protected function preprocess_user_evidence($data) {
global $DB;
global $DB;
if (isset($data['user'])) {
$user = $DB->get_record('user', array('username' => $data['user']), '*', MUST_EXIST);
@ -204,4 +212,50 @@ class behat_tool_lp_data_generators extends behat_base {
return $data;
}
/**
* Adapt creating plan_competency from plan name and competency shortname.
*
* @param array $data
* @return array
*/
protected function preprocess_plan_competency($data) {
global $DB;
if (isset($data['plan'])) {
$plan = $DB->get_record('tool_lp_plan', array('name' => $data['plan']), '*', MUST_EXIST);
$data['planid'] = $plan->id;
}
unset($data['plan']);
if (isset($data['competency'])) {
$competency = $DB->get_record('tool_lp_competency', array('shortname' => $data['competency']), '*', MUST_EXIST);
$data['competencyid'] = $competency->id;
}
unset($data['competency']);
return $data;
}
/**
* Adapt creating plan_competency from user evidence name and competency shortname.
*
* @param array $data
* @return array
*/
protected function preprocess_user_evidence_competency($data) {
global $DB;
if (isset($data['userevidence'])) {
$userevidence = $DB->get_record('tool_lp_user_evidence', array('name' => $data['userevidence']), '*', MUST_EXIST);
$data['userevidenceid'] = $userevidence->id;
}
unset($data['userevidence']);
if (isset($data['competency'])) {
$competency = $DB->get_record('tool_lp_competency', array('shortname' => $data['competency']), '*', MUST_EXIST);
$data['competencyid'] = $competency->id;
}
unset($data['competency']);
return $data;
}
}

View file

@ -0,0 +1,66 @@
@tool @javascript @tool_lp @tool_lp_user_evidence_comp_link
Feature: Manage competencies linked to evidence of prior learning
To link or unlink competency to evidence of prior learning
As learning plan admin
I need to link and unlink competencies from evidence of prior learning
Background:
Given the following lp "frameworks" exist:
| shortname | idnumber |
| Test-Framework | ID-FW1 |
And the following lp "competencies" exist:
| shortname | framework |
| Test-Comp1 | ID-FW1 |
| Test-Comp2 | ID-FW1 |
And the following lp "plans" exist:
| name | user | description |
| Test-Plan | admin | Plan description |
And the following lp "plancompetencies" exist:
| plan | competency |
| Test-Plan | Test-Comp1 |
| Test-Plan | Test-Comp2 |
And the following lp "userevidence" exist:
| name | description | user |
| Test-Evidence | Description evidence | admin |
When I log in as "admin"
And I follow "Profile" in the user menu
And I follow "Learning plans"
Then I should see "Evidence of prior learning"
Scenario: Link competency to evidence of prior learning from page
Given I follow "Evidence of prior learning"
And I should see "List of evidence"
And I should see "Test-Evidence"
And I click on "Test-Evidence" "link"
And I should see "Linked competencies"
And I press "Link competencies"
And "Competency picker" "dialogue" should be visible
And I select "Test-Comp1" of the competency tree
When I click on "Add" "button" in the "Competency picker" "dialogue"
Then "Test-Comp1" "table_row" should exist
Scenario: Link competency to evidence of prior learning from list
Given I follow "Evidence of prior learning"
And I should see "List of evidence"
And I should see "Test-Evidence"
And I click on "Link" of edit menu in the "Test-Evidence" row
And "Competency picker" "dialogue" should be visible
And I select "Test-Comp2" of the competency tree
When I click on "Add" "button" in the "Competency picker" "dialogue"
Then "Test-Comp2" "table_row" should exist
Scenario: Unlink competency from evidence of prior learning
Given the following lp "userevidencecompetencies" exist:
| userevidence | competency |
| Test-Evidence | Test-Comp1 |
| Test-Evidence | Test-Comp2 |
And I follow "Evidence of prior learning"
And I should see "List of evidence"
And I should see "Test-Evidence"
And I click on "Test-Evidence" "link"
And I should see "Linked competencies"
And I should see "Test-Comp1"
And I should see "Test-Comp2"
When I click on "Delete" "link" in the "Test-Comp1" "table_row"
Then I should not see "Test-Comp1"
And I should see "Test-Comp2"