5 * Many of the tests here are to check on tweaks made
6 * to maintain backwards compatibility.
10 class ConfigTest extends TestCase
13 public function test_filesystem_images_falls_back_to_storage_type_var()
15 $this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
16 $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
17 $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
21 public function test_filesystem_attachments_falls_back_to_storage_type_var()
23 $this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
24 $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
25 $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
29 public function test_app_url_blank_if_old_default_value()
31 $initUrl = 'https://example.com/docs';
32 $oldDefault = 'http://bookstack.dev';
33 $this->checkEnvConfigResult('APP_URL', $initUrl, 'app.url', $initUrl);
34 $this->checkEnvConfigResult('APP_URL', $oldDefault, 'app.url', '');
38 * Set an environment variable of the given name and value
39 * then check the given config key to see if it matches the given result.
40 * Providing a null $envVal clears the variable.
41 * @param string $envName
42 * @param string|null $envVal
43 * @param string $configKey
44 * @param string $expectedResult
46 protected function checkEnvConfigResult(string $envName, $envVal, string $configKey, string $expectedResult)
48 $this->runWithEnv($envName, $envVal, function() use ($configKey, $expectedResult) {
49 $this->assertEquals($expectedResult, config($configKey));