public function testGetNamespaces()
     $namespaces_first = $this->loader->getNamespaces();
     $namespace = md5(uniqid());
     $db = \Database::getActiveConnection();
     $db->insert('Config', array('configItem' => $namespace, 'configValue' => 1, 'configGroup' => 'test', 'configNamespace' => $namespace));
     $namespaces_after = $this->loader->getNamespaces();
     $value = array_shift(array_diff($namespaces_after, $namespaces_first));
     $this->assertEquals($namespace, $value);
 public function testSavingNamespacedConfig()
     $group = md5(time() . uniqid());
     $namespace = md5(time() . uniqid());
     $item = '';
     $value = $group;
     $this->saver->save($item, $value, 'testing', $group, $namespace);
     $db = Database::getActiveConnection();
     $result = $db->executeQuery('SELECT configValue FROM Config WHERE configItem=? AND configGroup=? AND configNamespace=?', array($item, $group, $namespace));
     $array = (array) $result->fetch();
     $saved_value = array_shift($array);
     $this->assertEquals($value, $saved_value, "Failed to save namespaced item.");
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  * @param ...
  *   List of modules to enable for the duration of the test.
 protected function setUp()
     global $db_prefix;
     // Store necessary current values before switching to prefixed database.
     $this->originalPrefix = $db_prefix;
     $clean_url_original = variable_get('clean_url', 0);
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     $db_prefix = Database::getActiveConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     include_once DRUPAL_ROOT . '/includes/';
     // Add the specified modules to the list of modules in the default profile.
     $args = func_get_args();
     $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
     // Because the schema is static cached, we need to flush
     // it between each run.  If we don't, then it will contain
     // stale data for the previous run's database prefix and all
     // calls to it will fail.
     drupal_get_schema(NULL, TRUE);
     // Run default profile tasks.
     $task = 'profile';
     default_profile_tasks($task, '');
     // Rebuild caches.
     $this->checkPermissions(array(), TRUE);
     // Restore necessary variables.
     variable_set('install_profile', 'default');
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '*****@*****.**');
     // Use temporary files directory with the same prefix as database.
     $this->originalFileDirectory = file_directory_path();
     variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
     $directory = file_directory_path();
     file_check_directory($directory, FILE_CREATE_DIRECTORY);
     // Create the files directory.