Skip to content

Commit 40f9a4b

Browse files
committed
Revert "fix: remove class-level .env rename in EncryptionTest to prevent test pollution"
This reverts commit 9fdc43e.
1 parent d558ed8 commit 40f9a4b

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tests/system/Encryption/EncryptionTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ public static function setUpBeforeClass(): void
3535

3636
CodeIgniterServices::injectMock('superglobals', new Superglobals());
3737

38-
putenv('encryption.key');
39-
unset($_ENV['encryption.key']);
40-
service('superglobals')->unsetServer('encryption.key');
38+
if (is_file(ROOTPATH . '.env')) {
39+
rename(ROOTPATH . '.env', ROOTPATH . '.env.bak');
40+
41+
putenv('encryption.key');
42+
unset($_ENV['encryption.key']);
43+
service('superglobals')->unsetServer('encryption.key');
44+
}
4145
}
4246

4347
protected function setUp(): void
@@ -47,6 +51,15 @@ protected function setUp(): void
4751
$this->encryption = new Encryption();
4852
}
4953

54+
public static function tearDownAfterClass(): void
55+
{
56+
parent::tearDownAfterClass();
57+
58+
if (is_file(ROOTPATH . '.env.bak')) {
59+
rename(ROOTPATH . '.env.bak', ROOTPATH . '.env');
60+
}
61+
}
62+
5063
/**
5164
* Covers behavior with config encryption key set or not
5265
*/

0 commit comments

Comments
 (0)