1 bootstrap.test BootstrapOverrideServerVariablesTestCase::testBackdropSettingsOverride()

Test that settings.php variables can be overridden by the server.

File

core/modules/simpletest/tests/bootstrap.test, line 643

Class

BootstrapOverrideServerVariablesTestCase
Tests for overriding server variables via the API.

Code

function testBackdropSettingsOverride() {
  // This test only runs when the "BACKDROP_SETTINGS" environment variable is
  // set. This usually is done through a Apache VirtualHost setting.
  // See backdrop_settings_initialize().
  $raw_settings = array();
  if (isset($_SERVER['BACKDROP_SETTINGS'])) {
    $raw_settings = json_decode($_SERVER['BACKDROP_SETTINGS'], TRUE);
  }
  if (isset($raw_settings['test_setting'])) {
    $this->assertEqual(settings_get('test_setting'), 'foo', 'Custom setting set through the server environment variables in BACKDROP_SETTINGS.');

    $test_database_array = array(
      'default' => array(
        'driver' => 'mysql',
        'database' => 'test_database',
        'username' => 'test_username',
        'password' => 'test_password',
        'host' => 'test_host',
      )
    );
    $this->assertEqual($GLOBALS['databases']['test_database'], $test_database_array, 'Custom database set through the server environment variables in BACKDROP_SETTINGS.');
  }
}