Fixed incorrect testing vars and reset env vars in config test

This commit is contained in:
Dan Brown 2019-06-25 22:52:07 +01:00
parent 52b4c81aff
commit 5c70413784
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 8 additions and 2 deletions

View File

@ -34,8 +34,8 @@
<env name="AVATAR_URL" value=""/>
<env name="LDAP_VERSION" value="3"/>
<env name="STORAGE_TYPE" value="local"/>
<env name="ATTACHMENT_STORAGE_TYPE" value="local"/>
<env name="IMAGE_STORAGE_TYPE" value="local"/>
<env name="STORAGE_ATTACHMENT_TYPE" value="local"/>
<env name="STORAGE_IMAGE_TYPE" value="local"/>
<env name="GITHUB_APP_ID" value="aaaaaaaaaaaaaa"/>
<env name="GITHUB_APP_SECRET" value="aaaaaaaaaaaaaa"/>
<env name="GITHUB_AUTO_REGISTER" value=""/>

View File

@ -16,6 +16,8 @@ class ConfigTest extends TestCase
$this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
$this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
putenv('STORAGE_TYPE=local');
}
public function test_filesystem_attachments_falls_back_to_storage_type_var()
@ -24,6 +26,8 @@ class ConfigTest extends TestCase
$this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
$this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
putenv('STORAGE_TYPE=local');
}
public function test_app_url_blank_if_old_default_value()
@ -45,10 +49,12 @@ class ConfigTest extends TestCase
*/
protected function checkEnvConfigResult(string $envName, $envVal, string $configKey, string $expectedResult)
{
$originalVal = getenv($envName);
$envString = $envName . (is_null($envVal) ? '' : '=') . ($envVal ?? '');
putenv($envString);
$this->refreshApplication();
$this->assertEquals($expectedResult, config($configKey));
putenv($envString = $envName . (empty($originalVal) ? '' : '=') . ($originalVal ?? ''));
}
}