Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Nov 27, 2024
1 parent fbe6fe2 commit 6bf5e4a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
9 changes: 6 additions & 3 deletions admin/tool/lp/tests/behat/plan_workflow.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Feature: Manage plan workflow
| Test-Comp1 | ID-FW1 | Test-Comp1 |
| Test-Comp2 | ID-FW1 | Test-Comp2 |
And the following "core_competency > plans" exist:
| name | user | description |
| Test-Plan1 | user1 | Description of plan for user 1 |
| Test-Plan2 | user2 | Description of plan for user 2 |
| name | user | description | reviewer | status |
| Test-Plan1 | user1 | Description of plan for user 1 | user1 | draft |
| Test-Plan2 | user2 | Description of plan for user 2 | user2 | draft |
And the following "core_competency > plan_competency" exist:
| plan | competency |
| Test-Plan1 | Test-Comp1 |
Expand All @@ -52,13 +52,15 @@ Feature: Manage plan workflow
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| lp | System | 1 | my-index | content |

@javascript
Scenario: User can manages his own plan draft
Given I log in as "user1"
And I follow "Profile" in the user menu
When I follow "Learning plans"
Then I should see "List of learning plans"
And I should see "Test-Plan1"
And I should not see "Test-Plan2"
# And I pause
And I click on "Request review" of edit menu in the "Test-Plan1" row
And I should see "Waiting for review"
And I click on "Cancel review" of edit menu in the "Test-Plan1" row
Expand Down Expand Up @@ -94,6 +96,7 @@ Feature: Manage plan workflow
| Test-Plan3 | user2 | Description of plan 3 for user 1 | waiting for review |
| Test-Plan4 | user1 | Description of plan 3 for user 1 | draft |
When I log in as "manager1"
And I pause
Then I should see "Test-Plan3"
And I should not see "Test-Plan4"
And I log out
Expand Down
28 changes: 26 additions & 2 deletions competency/tests/generator/behat_core_competency_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function get_creatable_entities(): array {
'singular' => 'plan',
'datagenerator' => 'plan',
'required' => ['name'],
'switchids' => ['user' => 'userid'],
'switchids' => ['user' => 'userid', 'status' => 'statusid'],
],
'plan_competencies' => [
'singular' => 'plan_competency',
Expand Down Expand Up @@ -179,6 +179,7 @@ public function process_plan(array $data): void {

unset($data['competencyids']);


$plan = $generator->create_plan($data);

foreach ($competencyids as $competencyid) {
Expand Down Expand Up @@ -243,7 +244,6 @@ protected function preprocess_plan(array $data): array {

return $data + [
'userid' => $USER->id,
'status' => plan::STATUS_ACTIVE,
];
}

Expand Down Expand Up @@ -331,4 +331,28 @@ protected function get_context_id(string $contextid): int {
return $id;
}

protected function get_status_id(string $name): int {
error_log("name: $name");
switch ($name) {
case 'draft':
$status = plan::STATUS_DRAFT;
break;
case 'in review':
$status = plan::STATUS_IN_REVIEW;
break;
case 'waiting for review':
$status = plan::STATUS_WAITING_FOR_REVIEW;
break;
case 'active':
$status = plan::STATUS_ACTIVE;
break;
case 'complete':
$status = plan::STATUS_COMPLETE;
break;
default:
$status = plan::STATUS_ACTIVE;
break;
}
return $status;
}
}

0 comments on commit 6bf5e4a

Please sign in to comment.