Skip to content

Commit 6822b3d

Browse files
committed
allow parametrization of site details
1 parent 242e6f8 commit 6822b3d

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

Diff for: .github/workflows/web-install.yml

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jobs:
1616
behat:
1717
runs-on: ubuntu-latest
1818

19+
env:
20+
MOODLE_SITE_URL: http://localhost:8080/moodle
21+
DB_TYPE: pgsql
22+
DB_HOST: localhost
23+
DB_NAME: test
24+
DB_USER: test
25+
DB_PASS: test
26+
1927
steps:
2028
- name: Setting up DB PostgreSQL
2129
uses: m4nu56/postgresql-action@v1

Diff for: tests/behat/Context/FeatureContext.php

+35
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,41 @@
44
use Behat\MinkExtension\Context\MinkContext;
55
use Behat\Behat\Context\Context;
66

7+
/**
8+
* Defines application features from the specific context.
9+
*/
710
class FeatureContext extends MinkContext implements Context {
811

12+
/**
13+
* @Given I am on the moodle site to be installed
14+
*/
15+
public function iAmOnTheMoodleSiteToBeInstalled() {
16+
$baseurl = getenv('MOODLE_SITE_URL') ?: 'http://localhost';
17+
18+
$this->visitPath("{$baseurl}");
19+
}
20+
21+
/**
22+
* @When I fill in the database type
23+
*/
24+
public function iFillInTheDatabaseType() {
25+
$dbtype = getenv('DB_TYPE') ?: 'pgsql';
26+
27+
$this->fillField('dbtype', $dbtype);
28+
}
29+
30+
/**
31+
* @When I fill in the database settings
32+
*/
33+
public function iFillInTheDatabaseSettings() {
34+
$dbhost = getenv('DB_HOST') ?: 'localhost';
35+
$dbname = getenv('DB_NAME') ?: 'moodle';
36+
$dbuser = getenv('DB_USER') ?: 'postgres';
37+
$dbpass = getenv('DB_PASS') ?: 'moodle';
38+
39+
$this->fillField('dbhost', $dbhost);
40+
$this->fillField('dbname', $dbname);
41+
$this->fillField('dbuser', $dbuser);
42+
$this->fillField('dbpass', $dbpass);
43+
}
944
}

Diff for: tests/behat/install.feature

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: Moodle Web Installation
22

33
Scenario: Verify successful installation of Moodle
4-
Given I am on "http://localhost:8080/moodle"
4+
Given I am on the moodle site to be installed
55

66
# First page: Choose a language
77
And I should see "Installation"
@@ -14,21 +14,20 @@ Feature: Moodle Web Installation
1414
And I press "Next"
1515

1616
# Choose database driver
17-
And I fill in "dbtype" with "pgsql"
17+
And I fill in the database type
1818
And I press "Next"
1919

2020
# Database settings
21-
When I fill in "dbhost" with "localhost"
22-
When I fill in "dbname" with "test"
23-
When I fill in "dbuser" with "test"
24-
When I fill in "dbpass" with "test"
21+
And I fill in the database settings
2522
And I press "Next"
2623

27-
# Configuration completed: --> We only see this part if Moodle could not save the config.php
24+
# Configuration completed: --> Only needed if Moodle could not save the config.php
2825
# And I should see "Configuration completed"
2926
# And I press "Next"
3027

3128
# Installation
29+
And I should see "Installation"
30+
And I should see "Modular Object-Oriented Dynamic Learning Environment"
3231
And I should see "Have you read these conditions and understood them?"
3332
And I press "Continue"
3433

@@ -50,7 +49,7 @@ Feature: Moodle Web Installation
5049
And I fill in "s__shortname" with "sitetest"
5150
And I fill in "s__supportemail" with "[email protected]"
5251
And I fill in "s__noreplyaddress" with "[email protected]"
53-
And I press "Save changes"
52+
When I press "Save changes"
5453

5554
# Installation finished.
56-
And I should see "Welcome, admin!"
55+
Then I should see "Welcome, admin!"

0 commit comments

Comments
 (0)