Skip to content

Commit

Permalink
create users for automated tests in integration_test profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Jan 27, 2025
1 parent 4402b22 commit f40cb29
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
This playbook configures a moodle instance with AdLer.

The following roles are available:
- test_users: Creates test users
- test_users: Creates test users for manual use
- moodle_dev_env: For moodle development (don't install plugins)
- integration_test: For integration and end-to-end tests (activate mobile services)
- integration_test: For integration and end-to-end tests (activate mobile services, create test users for automated tests)

The following environment variables are used:
- DECLARATIVE_SETUP_MANAGER_PASSWORD: Password for the manager user
- DECLARATIVE_SETUP_STUDENT_PASSWORD: Password for the student user
- DECLARATIVE_SETUP_MANAGER_PASSWORD: Password for the manager user (role: test_users)
- DECLARATIVE_SETUP_STUDENT_PASSWORD: Password for the student user (role: test_users)
- DECLERATIVE_SETUP_INTEGRATION_TEST_MANAGER_PASSWORD: Password for the integration test manager user (role: integration_test)
- DECLERATIVE_SETUP_INTEGRATION_TEST_STUDENT_PASSWORD: Password for the integration test student user (role: integration_test)

## files/plugins.json
This file is required if `moodle_dev_env` role is not used. Get the current version from
Expand Down
24 changes: 24 additions & 0 deletions classes/playbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@ protected function playbook_implementation(): void {
));
$play->play();

if ($this->has_role('integration_test')) {
// Create test users
$play = new user(new user_model(
'manager',
$this->get_environment_variable('INTEGRATION_TEST_MANAGER_PASSWORD'),
));
$play->play();
$play = new user(new user_model(
'student',
$this->get_environment_variable('INTEGRATION_TEST_STUDENT_PASSWORD'),
));
$play->play();

// create adler course category for test users
$play = new course_category(new course_category_model(
'/adler/integration_test',
users: [
new role_user_model('integration_test_manager', ['adler_manager']),
new role_user_model('integration_test_student', []),
],
));
$play->play();
}

if ($this->has_role('test_users')) {
// Create test users
$play = new user(new user_model(
Expand Down

0 comments on commit f40cb29

Please sign in to comment.