Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit b4d60b8

Browse files
author
danielbannert
committed
added tests for #88
1 parent 46bb997 commit b4d60b8

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/Automatic/Configurator/EnvConfigurator.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ public function configure(PackageContract $package): void
3838
continue;
3939
}
4040

41-
$value = self::expandTargetDir($this->options, (string) $value);
41+
if (\is_string($value)) {
42+
$value = self::expandTargetDir($this->options, $value);
43+
} elseif (\filter_var($value, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) !== null) {
44+
$value = \var_export($value, true);
45+
}
4246

4347
if (\strpbrk($value, " \t\n&!\"") !== false) {
4448
$value = '"' . \str_replace(['\\', '"', "\t", "\n"], ['\\\\', '\\"', '\t', '\n'], $value) . '"';
4549
}
4650

47-
$data .= "${key}=${value}\n";
51+
$data .= $key . '=' . $value . "\n";
4852
}
4953

5054
if (! \file_exists($this->path->getWorkingDir() . \DIRECTORY_SEPARATOR . '.env')) {

tests/Automatic/Configurator/EnvConfiguratorTest.php

+14-11
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,18 @@ public function testConfigure(): void
7979
$package->setConfig([
8080
ConfiguratorContract::TYPE => [
8181
EnvConfigurator::getName() => [
82-
'APP_ENV' => 'test bar',
83-
'APP_DEBUG' => '0',
84-
'APP_PARAGRAPH' => "foo\n\"bar\"\\t",
85-
'DATABASE_URL' => 'mysql://[email protected]:3306/narrowspark?charset=utf8mb4&serverVersion=5.7',
86-
'MAILER_URL' => 'null://localhost',
87-
'MAILER_USER' => 'narrow',
88-
'#1' => 'Comment 1',
89-
'#2' => 'Comment 3',
90-
'#TRUSTED_SECRET' => 's3cretf0rt3st"<>',
91-
'APP_SECRET' => 's3cretf0rt3st"<>',
82+
'APP_ENV' => 'test bar',
83+
'APP_DEBUG' => '0',
84+
'APP_PARAGRAPH' => "foo\n\"bar\"\\t",
85+
'DATABASE_URL' => 'mysql://[email protected]:3306/narrowspark?charset=utf8mb4&serverVersion=5.7',
86+
'MAILER_URL' => 'null://localhost',
87+
'MAILER_USER' => 'narrow',
88+
'#1' => 'Comment 1',
89+
'#2' => 'Comment 3',
90+
'#TRUSTED_SECRET' => 's3cretf0rt3st"<>',
91+
'APP_SECRET' => 's3cretf0rt3st"<>',
92+
'BOOL' => false,
93+
'VALID_NUMBER_TRUE' => 1,
9294
],
9395
],
9496
]);
@@ -107,10 +109,11 @@ public function testConfigure(): void
107109
# Comment 3
108110
#TRUSTED_SECRET="s3cretf0rt3st\"<>"
109111
APP_SECRET="s3cretf0rt3st\"<>"
112+
BOOL=false
113+
VALID_NUMBER_TRUE=1
110114
###< fixtures/test ###
111115

112116
EOF;
113-
114117
// Skip on second call
115118
$this->configurator->configure($package);
116119

0 commit comments

Comments
 (0)