Skip to content

Commit

Permalink
Merge pull request #8392 from paulbalandan/encryption-test-with-env
Browse files Browse the repository at this point in the history
test: ensure no .env when EncryptionTest is run
  • Loading branch information
paulbalandan authored Jan 2, 2024
2 parents 7b7e63c + 8a7a689 commit 5f655f1
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/system/Encryption/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,40 @@ final class EncryptionTest extends CIUnitTestCase
{
private Encryption $encryption;

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

if (is_file(ROOTPATH . '.env')) {
rename(ROOTPATH . '.env', ROOTPATH . '.env.bak');

putenv('encryption.key');
unset($_ENV['encryption.key'], $_SERVER['encryption.key']);
}
}

protected function setUp(): void
{
parent::setUp();

$this->encryption = new Encryption();
}

public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();

if (is_file(ROOTPATH . '.env.bak')) {
rename(ROOTPATH . '.env.bak', ROOTPATH . '.env');
}
}

/**
* __construct test
*
* Covers behavior with config encryption key set or not
*/
public function testConstructor(): void
{
// Assume no configuration from set_up()
// Assume no configuration from setUp()
$this->assertEmpty($this->encryption->key);

// Try with an empty value
Expand Down

0 comments on commit 5f655f1

Please sign in to comment.