Skip to content

Commit fba050e

Browse files
committed
Fixed tests
1 parent db7d665 commit fba050e

5 files changed

Lines changed: 63 additions & 14 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"php": "^7.4 || ^8.0",
1515
"ext-json": "*",
1616
"composer-plugin-api": "^1.1 || ^2.0",
17-
"symfony/dotenv": "^5.4.5 || ^6.0 || ^7.0"
17+
"symfony/dotenv": "^5.4.42 || ^6.2 || ^7.0"
1818
},
1919
"require-dev": {
2020
"composer/composer": "^1.10 || ^2.0",
@@ -25,7 +25,7 @@
2525
"phpstan/phpstan": "^1.9",
2626
"phpstan/phpstan-nette": "^1.1",
2727
"roave/security-advisories": "dev-latest",
28-
"symfony/console": "^5.4 || ^6.0"
28+
"symfony/console": "^5.4 || ^6.0 || ^7.0"
2929
},
3030
"autoload": {
3131
"psr-4": {

tests/Bridge/Nette/DI/EnvironmentExtensionTest.phpt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ use SixtyEightPublishers\Environment\Debug\EnvDetector;
1515
use SixtyEightPublishers\Environment\Bootstrap\EnvBootstrap;
1616
use function assert;
1717
use function uniqid;
18+
use function explode;
19+
use function implode;
20+
use function array_map;
1821
use function file_exists;
22+
use function version_compare;
1923
use function sys_get_temp_dir;
2024

2125
require __DIR__ . '/../../../bootstrap.php';
@@ -51,7 +55,16 @@ final class EnvironmentExtensionTest extends TestCase
5155

5256
$tester->execute([]);
5357

54-
Assert::same(file_get_contents(__DIR__ . '/expectedDebugOutput.txt'), $tester->getDisplay());
58+
$expectedOutput = file_get_contents(
59+
version_compare($this->getDotenvVersion(), '6.0.0', '<')
60+
? __DIR__ . '/expectedDebugOutput.v5.txt'
61+
: __DIR__ . '/expectedDebugOutput.txt',
62+
);
63+
64+
$expectedOutput = implode("\n", array_map('trim', explode("\n", $expectedOutput)));
65+
$actualOutput = implode("\n", array_map('trim', explode("\n", $tester->getDisplay())));
66+
67+
Assert::same($expectedOutput, $actualOutput);
5568
}
5669

5770
public function createCommandTester(string $name): CommandTester
@@ -84,6 +97,13 @@ final class EnvironmentExtensionTest extends TestCase
8497

8598
return $configurator->createContainer();
8699
}
100+
101+
private function getDotenvVersion(): string
102+
{
103+
$packages = require __DIR__ . '/../../../../vendor/composer/installed.php';
104+
105+
return $packages['versions']['symfony/dotenv']['version'];
106+
}
87107
}
88108

89109
(new EnvironmentExtensionTest())->run();

tests/Bridge/Nette/DI/expectedDebugOutput.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ Scanned Files (in descending priority)
1414
Variables
1515
---------
1616

17-
----------- ------- ---------- ------
18-
Variable Value .env.dev .env
19-
----------- ------- ---------- ------
20-
APP_DEBUG 1 n/a 1
21-
APP_ENV dev n/a n/a
22-
TEST_A a n/a a
23-
TEST_B b n/a b
24-
TEST_C c c n/a
25-
----------- ------- ---------- ------
17+
----------- ------- ---------- ------
18+
Variable Value .env.dev .env
19+
----------- ------- ---------- ------
20+
APP_DEBUG 1 n/a 1
21+
TEST_A a n/a a
22+
TEST_B b n/a b
23+
TEST_C c c n/a
24+
----------- ------- ---------- ------
2625

27-
// Note real values might be different between web and CLI.
26+
// Note that values might be different between web and CLI.
2827

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Dotenv Variables & Files
3+
========================
4+
5+
Scanned Files (in descending priority)
6+
--------------------------------------
7+
8+
* ⨯ .env.local.php
9+
* ⨯ .env.dev.local
10+
* ✓ .env.dev
11+
* ⨯ .env.local
12+
* ✓ .env
13+
14+
Variables
15+
---------
16+
17+
----------- ------- ---------- ------
18+
Variable Value .env.dev .env
19+
----------- ------- ---------- ------
20+
APP_DEBUG 1 n/a 1
21+
TEST_A a n/a a
22+
TEST_B b n/a b
23+
TEST_C c c n/a
24+
----------- ------- ---------- ------
25+
26+
// Note that values might be different between web and CLI.
27+

tests/Command/DumpEnvironmentCommandTest.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ final class DumpEnvironmentCommandTest extends TestCase
113113

114114
$vars = require $envLocalFile;
115115

116-
Assert::same($expected, $vars);
116+
foreach ($expected as $envKey => $envVar) {
117+
Assert::hasKey($envKey, $vars);
118+
Assert::same($envVar, $vars[$envKey]);
119+
}
117120

118121
unlink($envLocalFile);
119122
}

0 commit comments

Comments
 (0)