Skip to content

Commit b911452

Browse files
authored
fix: fix dotenv loader to work without request matcher and fix tests (#71)
* tests: fix tests to work after updates * fix: fix dotenv loader to work without request matcher and to support grouping * Update test-drupal-setup.yml
1 parent 8d442cc commit b911452

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.github/workflows/test-drupal-setup.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66
branches:
77
- '6.**'
88
pull_request:
9-
types: [opened, reopened]
9+
types: [opened, reopened, edited]
1010
jobs:
1111
test-drupal-setup:
1212
name: Build and install drupal project
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 10
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717
- name: Setup PHP
1818
run: |
1919
sudo update-alternatives --set php /usr/bin/php8.1
@@ -37,6 +37,7 @@ jobs:
3737
- name: Install composer dependencies.
3838
run: |
3939
composer config platform-check false
40+
composer config --no-plugins allow-plugins.phpstan/extension-installer true
4041
composer create-project
4142
composer install
4243
- name: Setup the environment
@@ -54,4 +55,4 @@ jobs:
5455
docker-compose exec cli phapp install --no-build
5556
- name: Check connection and response of the site
5657
run: |
57-
curl -v http://example.drupal-project.localdev.space | grep "Drupal 9"
58+
curl -v http://example.drupal-project.localdev.space | grep "Drupal 10"

dotenv/loader.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ public static function prepareAppEnvironment() {
111111
if (file_exists(__DIR__ . '/sites/all.env')) {
112112
$vars .= file_get_contents(__DIR__ . '/sites/all.env') . "\n";
113113
}
114+
// Support dots in the environment name and load files by prefix.
115+
// This allows grouping environments by host having shared settings.
116+
if (strpos($phapp_env, '.') !== FALSE) {
117+
$parts = explode('.', $phapp_env, 2);
118+
if (file_exists(__DIR__ . '/sites/all.env-' . $parts[0] . '.env')) {
119+
$vars .= file_get_contents(__DIR__ . '/sites/all.env-' . $parts[0] . '.env') . "\n";
120+
}
121+
}
114122
// Support per-environment all.env files.
115123
if (file_exists(__DIR__ . '/sites/all.env-' . $phapp_env . '.env')) {
116124
$vars .= file_get_contents(__DIR__ . '/sites/all.env-' . $phapp_env . '.env') . "\n";
@@ -209,7 +217,6 @@ public static function getSiteVariables($site = NULL, $site_variant = '') {
209217
$dotenv->populate($dotenv->parse(PhappEnvironmentLoader::prepareDeterminedEnvironment()), TRUE);
210218

211219
// Match the request and prepare site-specific dotenv vars.
212-
$site = drunomics\MultisiteRequestMatcher\RequestMatcher::getInstance()
213-
->match();
220+
$site = PhappEnvironmentLoader::determineActiveSite();
214221
$dotenv->populate($dotenv->parse(PhappEnvironmentLoader::prepareAppEnvironment()), TRUE);
215222
}

0 commit comments

Comments
 (0)