Skip to content

Commit 5b58098

Browse files
committed
fix: unset encryption.key variables in RunInSeparateProcess tests
1 parent bd4c41d commit 5b58098

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/system/Config/BaseConfigTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ public function testSetsDefaultValues(): void
197197
#[RunInSeparateProcess]
198198
public function testSetsDefaultValuesEncryptionUsingHex2Bin(): void
199199
{
200+
putenv('encryption.key');
201+
unset($_ENV['encryption.key'], $_SERVER['encryption.key']); // @phpstan-ignore codeigniter.superglobalAccess
202+
200203
$dotenv = new DotEnv($this->fixturesFolder, 'encryption.env');
201204
$dotenv->load();
202205
$config = new Encryption();
@@ -210,6 +213,9 @@ public function testSetsDefaultValuesEncryptionUsingHex2Bin(): void
210213
#[RunInSeparateProcess]
211214
public function testSetDefaultValuesEncryptionUsingBase64(): void
212215
{
216+
putenv('encryption.key');
217+
unset($_ENV['encryption.key'], $_SERVER['encryption.key']); // @phpstan-ignore codeigniter.superglobalAccess
218+
213219
$dotenv = new DotEnv($this->fixturesFolder, 'base64encryption.env');
214220
$dotenv->load();
215221
$config = new Encryption('base64');

tests/system/Config/DotEnvTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use PHPUnit\Framework\Attributes\PreserveGlobalState;
2323
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2424
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
25-
use TypeError;
2625

2726
/**
2827
* @internal
@@ -90,6 +89,9 @@ public static function provideLoadsVars(): iterable
9089
#[RunInSeparateProcess]
9190
public function testLoadsHex2Bin(): void
9291
{
92+
putenv('encryption.key');
93+
unset($_ENV['encryption.key'], $_SERVER['encryption.key']); // @phpstan-ignore codeigniter.superglobalAccess
94+
9395
$dotenv = new DotEnv($this->fixturesFolder, 'encryption.env');
9496
$dotenv->load();
9597

@@ -102,20 +104,16 @@ public function testLoadsHex2Bin(): void
102104
#[RunInSeparateProcess]
103105
public function testLoadsBase64(): void
104106
{
107+
putenv('encryption.key');
108+
unset($_ENV['encryption.key'], $_SERVER['encryption.key']); // @phpstan-ignore codeigniter.superglobalAccess
109+
105110
$dotenv = new DotEnv($this->fixturesFolder, 'base64encryption.env');
106111
$dotenv->load();
107112

108113
$this->assertSame('base64:L40bKo6b8Nu541LeVeZ1i5RXfGgnkar42CPTfukhGhw=', getenv('encryption.key'));
109114
$this->assertSame('OpenSSL', getenv('encryption.driver'));
110115
}
111116

112-
public function testLoadsNoneStringFiles(): void
113-
{
114-
$this->expectException(TypeError::class);
115-
116-
new DotEnv($this->fixturesFolder, 2);
117-
}
118-
119117
public function testCommentedLoadsVars(): void
120118
{
121119
$dotenv = new DotEnv($this->fixturesFolder, 'commented.env');

0 commit comments

Comments
 (0)