diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index f65ab4c..233cfcc 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -602,6 +602,15 @@ function drupal_settings_initialize() {
   if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
     include_once DRUPAL_ROOT . '/' . conf_path() . '/settings.php';
   }
+
+  // Enable simpletest to include additional settings so overrides and requests
+  // that don't use the database can be tested
+  if ($test_prefix = drupal_valid_test_ua()) {
+    if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/settings/simpletest_settings.php')) {
+      include_once DRUPAL_ROOT . '/' . conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/settings/simpletest_settings.php';
+    }
+  }
+
   $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
 
   if (isset($base_url)) {
@@ -2184,12 +2193,12 @@ function _drupal_bootstrap_page_cache() {
     require_once DRUPAL_ROOT . '/' . $include;
   }
   // Check for a cache mode force from settings.php.
-  if (variable_get('page_cache_without_database')) {
+  $config = config('system.performance');
+  if ($config->get('page_cache_without_database')) {
     $cache_enabled = TRUE;
   }
   else {
     drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
-    $config = config('system.performance');
     $cache_enabled = $config->get('cache');
   }
   drupal_block_denied(ip_address());
diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php
index 63ae7b4..6302847 100644
--- a/core/lib/Drupal/Core/Config/DatabaseStorage.php
+++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php
@@ -18,11 +18,13 @@ class DatabaseStorage extends StorageBase {
     // read without actually having the database available. In this case,
     // catch the exception and just return an empty array so the caller can
     // handle it if need be.
-    try {
-      return db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $this->name))->fetchField();
-    } catch (Exception $e) {
-      return array();
+    if (function_exists('db_query')) {
+      try {
+        return db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $this->name))->fetchField();
+      } catch (Exception $e) {
+      }
     }
+    return array();
   }
 
   /**
diff --git a/core/modules/config/config.test b/core/modules/config/config.test
index f69dde9..a41535e 100644
--- a/core/modules/config/config.test
+++ b/core/modules/config/config.test
@@ -293,3 +293,37 @@ class ConfUpdate7to8TestCase extends WebTestBase {
     $this->assertEqual($config->get('config_test_bar'), $this->testContent);
   }
 }
+
+/**
+ * Tests using Configuration if the database is not available
+ */
+class ConfEarlyConfigGetTestCase extends WebTestBase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Configuration use if database unavailable',
+      'description' => 'Tests the ability to access config if database is
+        unavailable eg. if page_cache_without_database is set.',
+      'group' => 'Configuration',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('config_upgrade');
+    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+  }
+
+  /**
+   * Test getting a page from the site when page_cache_without_database is set
+   * to TRUE. This will use use system.performance config.
+   */
+  function testGetFrontPageCacheWithoutDatabase() {
+    $conf_lines = array(
+      "\$conf['system.performance']['page_cache_without_database'] = TRUE;",
+    );
+    $this->createSimpletestSettingsFile($conf_lines);
+    $this->drupalGet('<front>');
+    // The page should contain the default frontpage content
+    $this->assertText(t('No front page content has been created yet.'));
+  }
+}
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 277e97b..78f9112 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -144,6 +144,11 @@ abstract class WebTestBase extends TestBase {
   protected $redirect_count;
 
   /**
+   * A directory for simpletest to write a settings file to.
+   */
+  protected $simpletestSettingsDir;
+
+  /**
    * Constructor for Drupal\simpletest\WebTestBase.
    */
   function __construct($test_id = NULL) {
@@ -635,6 +640,14 @@ abstract class WebTestBase extends TestBase {
     $this->configFileDirectory = $this->originalFileDirectory . '/' . $GLOBALS['config_directory_name'];
     file_prepare_directory($this->configFileDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
 
+    // Create and set a new directory to store a settings.phpand signature key.
+    // The child site automatically adjusts conf_path to use a seetings.php file
+    // stored here.
+    // @see config_get_config_directory()
+    $this->simpletestSettingsDir = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10) . '/settings';
+    file_prepare_directory($this->simpletestSettingsDir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+    file_save_htaccess($this->simpletestSettingsDir);
+
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', $this->public_files_directory . '/error.log');
@@ -2863,4 +2876,30 @@ abstract class WebTestBase extends TestBase {
       $this->verbose(t('Email:') . '<pre>' . print_r($mail, TRUE) . '</pre>');
     }
   }
+
+  /**
+   * Creates simpletest_settings.php file.
+   *
+   * @param array $lines
+   *   Lines to add to the simpletest_settings.php, for eaxmple:
+   *   @code
+   *     array(
+   *       "\$conf['page_cache_without_database'] = TRUE;",
+   *     );
+   *   @endcode
+   */
+  protected function createSimpletestSettingsFile($lines = array()) {
+    $header = <<<EOD
+<?php
+/**
+ * @file
+ * Simpletest specific configuration file.
+ *
+ */
+
+EOD;
+
+    $contents = array_merge(array($header), $lines) + array("");
+    file_put_contents($this->simpletestSettingsDir . '/simpletest_settings.php', implode("\n", $contents));
+  }
 }
