1 <?php namespace Tests\Unit;
7 * Many of the tests here are to check on tweaks made
8 * to maintain backwards compatibility.
12 class ConfigTest extends TestCase
15 public function test_filesystem_images_falls_back_to_storage_type_var()
17 $this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
18 $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
19 $this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
23 public function test_filesystem_attachments_falls_back_to_storage_type_var()
25 $this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
26 $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
27 $this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
31 public function test_app_url_blank_if_old_default_value()
33 $initUrl = 'https://example.com/docs';
34 $oldDefault = 'http://bookstack.dev';
35 $this->checkEnvConfigResult('APP_URL', $initUrl, 'app.url', $initUrl);
36 $this->checkEnvConfigResult('APP_URL', $oldDefault, 'app.url', '');
40 * Set an environment variable of the given name and value
41 * then check the given config key to see if it matches the given result.
42 * Providing a null $envVal clears the variable.
43 * @param string $envName
44 * @param string|null $envVal
45 * @param string $configKey
46 * @param string $expectedResult
48 protected function checkEnvConfigResult(string $envName, $envVal, string $configKey, string $expectedResult)
50 $this->runWithEnv($envName, $envVal, function() use ($configKey, $expectedResult) {
51 $this->assertEquals($expectedResult, config($configKey));