当前位置: 首页>>代码示例>>PHP>>正文


PHP install_profile_info函数代码示例

本文整理汇总了PHP中install_profile_info函数的典型用法代码示例。如果您正苦于以下问题:PHP install_profile_info函数的具体用法?PHP install_profile_info怎么用?PHP install_profile_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了install_profile_info函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testModuleList

 /**
  * The basic functionality of retrieving enabled modules.
  */
 function testModuleList()
 {
     // Build a list of modules, sorted alphabetically.
     $profile_info = install_profile_info('testing', 'en');
     $module_list = $profile_info['dependencies'];
     // Installation profile is a module that is expected to be loaded.
     $module_list[] = 'testing';
     sort($module_list);
     // Compare this list to the one returned by the module handler. We expect
     // them to match, since all default profile modules have a weight equal to 0
     // (except for block.module, which has a lower weight but comes first in
     // the alphabet anyway).
     $this->assertModuleList($module_list, 'Testing profile');
     // Try to install a new module.
     $this->moduleHandler()->install(array('ban'));
     $module_list[] = 'ban';
     sort($module_list);
     $this->assertModuleList($module_list, 'After adding a module');
     // Try to mess with the module weights.
     module_set_weight('ban', 20);
     // Move ban to the end of the array.
     unset($module_list[array_search('ban', $module_list)]);
     $module_list[] = 'ban';
     $this->assertModuleList($module_list, 'After changing weights');
     // Test the fixed list feature.
     $fixed_list = array('system' => 'core/modules/system/system.module', 'menu' => 'core/modules/menu/menu.module');
     $this->moduleHandler()->setModuleList($fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
     $this->assertModuleList($new_module_list, t('When using a fixed list'));
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:33,代码来源:ModuleHandlerTest.php

示例2: testModuleList

 /**
  * The basic functionality of retrieving enabled modules.
  */
 function testModuleList()
 {
     // Prime the drupal_get_filename() static cache with the location of the
     // testing profile as it is not the currently active profile and we don't
     // yet have any cached way to retrieve its location.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
     // Build a list of modules, sorted alphabetically.
     $profile_info = install_profile_info('testing', 'en');
     $module_list = $profile_info['dependencies'];
     // Installation profile is a module that is expected to be loaded.
     $module_list[] = 'testing';
     sort($module_list);
     // Compare this list to the one returned by the module handler. We expect
     // them to match, since all default profile modules have a weight equal to 0
     // (except for block.module, which has a lower weight but comes first in
     // the alphabet anyway).
     $this->assertModuleList($module_list, 'Testing profile');
     // Try to install a new module.
     $this->moduleInstaller()->install(array('ban'));
     $module_list[] = 'ban';
     sort($module_list);
     $this->assertModuleList($module_list, 'After adding a module');
     // Try to mess with the module weights.
     module_set_weight('ban', 20);
     // Move ban to the end of the array.
     unset($module_list[array_search('ban', $module_list)]);
     $module_list[] = 'ban';
     $this->assertModuleList($module_list, 'After changing weights');
     // Test the fixed list feature.
     $fixed_list = array('system' => 'core/modules/system/system.module', 'menu' => 'core/modules/menu/menu.module');
     $this->moduleHandler()->setModuleList($fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
     $this->assertModuleList($new_module_list, t('When using a fixed list'));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:38,代码来源:ModuleHandlerTest.php

示例3: testInstallerTranslationCache

 /**
  * Tests profile info caching in non-English languages.
  */
 function testInstallerTranslationCache()
 {
     require_once 'core/includes/install.inc';
     // Prime the drupal_get_filename() static cache with the location of the
     // testing profile as it is not the currently active profile and we don't
     // yet have any cached way to retrieve its location.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
     $info_en = install_profile_info('testing', 'en');
     $info_nl = install_profile_info('testing', 'nl');
     $this->assertFalse(in_array('locale', $info_en['dependencies']), 'Locale is not set when installing in English.');
     $this->assertTrue(in_array('locale', $info_nl['dependencies']), 'Locale is set when installing in Dutch.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:16,代码来源:InstallerLanguageTest.php

示例4: testSetUpWithMissingDependencies

  /**
   * Verifies that the exception message in the profile step is correct.
   */
  public function testSetUpWithMissingDependencies() {
    // Prime the drupal_get_filename() static cache with the location of the
    // testing profile as it is not the currently active profile and we don't
    // yet have any cached way to retrieve its location.
    // @todo Remove as part of https://www.drupal.org/node/2186491
    drupal_get_filename('profile', 'testing_missing_dependencies', 'core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml');

    $info = drupal_verify_profile([
      'parameters' => ['profile' => 'testing_missing_dependencies'],
      'profile_info' => install_profile_info('testing_missing_dependencies'),
    ]);

    $message = $info['required_modules']['description']->render();
    $this->assertContains('Missing_module1', $message);
    $this->assertContains('Missing_module2', $message);
  }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:19,代码来源:InstallerMissingDependenciesTest.php

示例5: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL)
 {
     $form['#title'] = $this->t('Select an installation profile');
     $profiles = array();
     $names = array();
     foreach ($install_state['profiles'] as $profile) {
         /** @var $profile \Drupal\Core\Extension\Extension */
         $details = install_profile_info($profile->getName());
         // Don't show hidden profiles. This is used by to hide the testing profile,
         // which only exists to speed up test runs.
         if ($details['hidden'] === TRUE && !drupal_valid_test_ua()) {
             continue;
         }
         $profiles[$profile->getName()] = $details;
         // Determine the name of the profile; default to file name if defined name
         // is unspecified.
         $name = isset($details['name']) ? $details['name'] : $profile->getName();
         $names[$profile->getName()] = $name;
     }
     // Display radio buttons alphabetically by human-readable name, but always
     // put the core profiles first (if they are present in the filesystem).
     natcasesort($names);
     if (isset($names['minimal'])) {
         // If the expert ("Minimal") core profile is present, put it in front of
         // any non-core profiles rather than including it with them alphabetically,
         // since the other profiles might be intended to group together in a
         // particular way.
         $names = array('minimal' => $names['minimal']) + $names;
     }
     if (isset($names['standard'])) {
         // If the default ("Standard") core profile is present, put it at the very
         // top of the list. This profile will have its radio button pre-selected,
         // so we want it to always appear at the top.
         $names = array('standard' => $names['standard']) + $names;
     }
     // The profile name and description are extracted for translation from the
     // .info file, so we can use $this->t() on them even though they are dynamic
     // data at this point.
     $form['profile'] = array('#type' => 'radios', '#title' => $this->t('Select an installation profile'), '#title_display' => 'invisible', '#options' => array_map(array($this, 't'), $names), '#default_value' => 'standard');
     foreach (array_keys($names) as $profile_name) {
         $form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save and continue'), '#button_type' => 'primary');
     return $form;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:49,代码来源:SelectProfileForm.php

示例6: setUp

 /**
  * Sets up a Backdrop site for running functional and integration tests.
  *
  * Generates a random database prefix and installs Backdrop with the specified
  * installation profile in BackdropWebTestCase::$profile into the
  * prefixed database. Afterwards, installs any additional modules specified by
  * the test.
  *
  * After installation all caches are flushed and several configuration values
  * are reset to the values of the parent site executing the test, since the
  * default values may be incompatible with the environment in which tests are
  * being executed.
  *
  * @param ...
  *   List of modules to enable for the duration of the test. This can be
  *   either a single array or a variable number of string arguments.
  *
  * @see BackdropWebTestCase::prepareDatabasePrefix()
  * @see BackdropWebTestCase::changeDatabasePrefix()
  * @see BackdropWebTestCase::prepareEnvironment()
  */
 protected function setUp()
 {
     global $user, $language, $conf;
     // Create the database prefix for this test.
     $this->prepareDatabasePrefix();
     // Prepare the environment for running tests.
     $this->prepareEnvironment();
     if (!$this->setupEnvironment) {
         return FALSE;
     }
     // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     backdrop_static_reset();
     // Change the database prefix.
     // All static variables need to be reset before the database prefix is
     // changed, since BackdropCacheArray implementations attempt to
     // write back to persistent caches when they are destructed.
     $this->changeDatabasePrefix();
     if (!$this->setupDatabasePrefix) {
         return FALSE;
     }
     // Preset the 'install_profile' system variable, so the first call into
     // system_rebuild_module_data() (in backdrop_install_system()) will register
     // the test's profile as a module. Without this, the installation profile of
     // the parent site (executing the test) is registered, and the test
     // profile's hook_install() and other hook implementations are never invoked.
     config_install_default_config('system');
     config_set('system.core', 'install_profile', $this->profile);
     // Perform the actual Backdrop installation.
     include_once BACKDROP_ROOT . '/core/includes/install.inc';
     backdrop_install_system();
     // Set path variables.
     $core_config = config('system.core');
     $core_config->set('file_default_scheme', 'public');
     $core_config->set('file_public_path', $this->public_files_directory);
     $core_config->set('file_private_path', $this->private_files_directory);
     $core_config->set('file_temporary_path', $this->temp_files_directory);
     $core_config->save();
     // Set 'parent_profile' of simpletest to add the parent profile's
     // search path to the child site's search paths.
     // @see backdrop_system_listing()
     // @todo This may need to be primed like 'install_profile' above.
     config_set('simpletest.settings', 'parent_profile', $this->originalProfile);
     // Ensure schema versions are recalculated.
     backdrop_static_reset('backdrop_get_schema_versions');
     // Include the testing profile.
     config_set('system.core', 'install_profile', $this->profile);
     $profile_details = install_profile_info($this->profile, 'en');
     // Install the modules specified by the testing profile.
     module_enable($profile_details['dependencies'], FALSE);
     // Install modules needed for this test. This could have been passed in as
     // either a single array argument or a variable number of string arguments.
     // @todo Remove this compatibility layer and only accept a single array.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
         $modules = $modules[0];
     }
     if ($modules) {
         $success = module_enable($modules, TRUE);
         $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
     }
     // Run the profile tasks.
     $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField();
     if ($install_profile_module_exists) {
         module_enable(array($this->profile), FALSE);
     }
     // Reset/rebuild all data structures after enabling the modules.
     $this->resetAll();
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     backdrop_cron_run();
     // Ensure that the session is not written to the new environment and replace
     // the global $user session with uid 1 from the new test site.
     backdrop_save_session(FALSE);
     // Login as uid 1.
     $user = user_load(1);
     // Restore necessary variables.
     state_set('install_task', 'done');
     config_set('system.core', 'clean_url', $this->originalCleanUrl);
//.........这里部分代码省略.........
开发者ID:thejimbirch,项目名称:backdropcms.org,代码行数:101,代码来源:backdrop_web_test_case.php

示例7: setUp

 /**
  * 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. This can be
  *   either a single array or a variable number of string arguments.
  */
 protected function setUp()
 {
     global $user, $language, $conf;
     // Generate a temporary prefixed database to ensure that tests have a clean starting point.
     $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
     db_update('simpletest_test_id')->fields(array('last_prefix' => $this->databasePrefix))->condition('test_id', $this->testId)->execute();
     // Clone the current connection and replace the current prefix.
     $connection_info = Database::getConnectionInfo('default');
     Database::renameConnection('default', 'simpletest_original_default');
     foreach ($connection_info as $target => $value) {
         $connection_info[$target]['prefix'] = array('default' => $value['prefix']['default'] . $this->databasePrefix);
     }
     Database::addConnectionInfo('default', 'default', $connection_info['default']);
     // Store necessary current values before switching to prefixed database.
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
     $this->originalProfile = drupal_get_profile();
     $clean_url_original = variable_get('clean_url', 0);
     // Set to English to prevent exceptions from utf8_truncate() from t()
     // during install if the current language is not 'en'.
     // The following array/object conversion is copied from language_default().
     $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
     // Save and clean shutdown callbacks array because it static cached and
     // will be changed by the test run. If we don't, then it will contain
     // callbacks from both environments. So testing environment will try
     // to call handlers from original environment.
     $callbacks =& drupal_register_shutdown_function();
     $this->originalShutdownCallbacks = $callbacks;
     $callbacks = array();
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     // Use temporary files directory with the same prefix as the database.
     $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
     $private_files_directory = $public_files_directory . '/private';
     $temp_files_directory = $private_files_directory . '/temp';
     // Create the directories
     file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
     file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
     $this->generatedTestFiles = FALSE;
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', $public_files_directory . '/error.log');
     // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     drupal_static_reset();
     // Set the test information for use in other parts of Drupal.
     $test_info =& $GLOBALS['drupal_test_info'];
     $test_info['test_run_id'] = $this->databasePrefix;
     $test_info['in_child_site'] = FALSE;
     include_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_install_system();
     $this->preloadRegistry();
     // Set path variables.
     variable_set('file_public_path', $public_files_directory);
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
     // Include the testing profile.
     variable_set('install_profile', $this->profile);
     $profile_details = install_profile_info($this->profile, 'en');
     // Install the modules specified by the testing profile.
     module_enable($profile_details['dependencies'], FALSE);
     // Install modules needed for this test. This could have been passed in as
     // either a single array argument or a variable number of string arguments.
     // @todo Remove this compatibility layer in Drupal 8, and only accept
     // $modules as a single array argument.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
         $modules = $modules[0];
     }
     if ($modules) {
         $success = module_enable($modules, TRUE);
         $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
     }
     // Run the profile tasks.
     $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField();
     if ($install_profile_module_exists) {
         module_enable(array($this->profile), FALSE);
     }
     // Reset/rebuild all data structures after enabling the modules.
     $this->resetAll();
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     drupal_cron_run();
     // Log in with a clean $user.
     $this->originalUser = $user;
     drupal_save_session(FALSE);
     $user = user_load(1);
//.........这里部分代码省略.........
开发者ID:rlugojr,项目名称:livereload-examples,代码行数:101,代码来源:drupal_web_test_case.php

示例8: setUp

 /**
  * 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, $user, $language;
     // Store necessary current values before switching to prefixed database.
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalPrefix = $db_prefix;
     $this->originalFileDirectory = file_directory_path();
     $this->originalProfile = drupal_get_profile();
     $clean_url_original = variable_get('clean_url', 0);
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     db_update('simpletest_test_id')->fields(array('last_prefix' => $db_prefix_new))->condition('test_id', $this->testId)->execute();
     $db_prefix = $db_prefix_new;
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     // Use temporary files directory with the same prefix as the database.
     $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
     $private_files_directory = $public_files_directory . '/private';
     $temp_files_directory = $private_files_directory . '/temp';
     // Create the directories
     file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
     file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
     $this->generatedTestFiles = FALSE;
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', $public_files_directory . '/error.log');
     // Reset all statics so that test is performed with a clean environment.
     drupal_static_reset();
     include_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_install_system();
     $this->preloadRegistry();
     // Include the default profile
     variable_set('install_profile', 'standard');
     $profile_details = install_profile_info('standard', 'en');
     // Install the modules specified by the default profile.
     drupal_install_modules($profile_details['dependencies'], TRUE);
     drupal_static_reset('_node_types_build');
     if ($modules = func_get_args()) {
         // Install modules needed for this test.
         drupal_install_modules($modules, TRUE);
     }
     // 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.
     $install_state = array();
     drupal_install_modules(array('standard'), TRUE);
     // Rebuild caches.
     node_types_rebuild();
     actions_synchronize();
     _drupal_flush_css_js();
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     // Log in with a clean $user.
     $this->originalUser = $user;
     drupal_save_session(FALSE);
     $user = user_load(1);
     // Restore necessary variables.
     variable_set('install_task', 'done');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', 'simpletest@example.com');
     // Set up English language.
     unset($GLOBALS['conf']['language_default']);
     $language = language_default();
     // Set path variables
     variable_set('file_public_path', $public_files_directory);
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
     // Use the test mail class instead of the default mail handler class.
     variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
     drupal_set_time_limit($this->timeLimit);
 }
开发者ID:jacobSingh,项目名称:drupal,代码行数:86,代码来源:drupal_web_test_case.php

示例9: install_load_profile

/**
 * Installation task; load information about the chosen profile.
 *
 * @param $install_state
 *   An array of information about the current installation state. The loaded
 *   profile information will be added here, or an exception will be thrown if
 *   the profile cannot be loaded.
 */
function install_load_profile(&$install_state)
{
    $profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile';
    if (is_file($profile_file)) {
        include_once $profile_file;
        $install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], $install_state['parameters']['locale']);
    } else {
        throw new Exception(st('Sorry, the profile you have chosen cannot be loaded.'));
    }
}
开发者ID:blipp,项目名称:drupal,代码行数:18,代码来源:install.php

示例10: setUpInstall

 /**
  * Perform Drupal installation.
  */
 protected function setUpInstall(array $modules, $public_files_directory, $private_files_directory, $temp_files_directory)
 {
     include_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_install_system();
     $this->preloadRegistry();
     // Set path variables.
     variable_set('file_public_path', $public_files_directory);
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
     // Include the testing profile.
     variable_set('install_profile', $this->profile);
     $profile_details = install_profile_info($this->profile, 'en');
     // Install the modules specified by the testing profile.
     module_enable($profile_details['dependencies'], FALSE);
     // Install modules needed for this test. This could have been passed in as
     // either a single array argument or a variable number of string arguments.
     // @todo Remove this compatibility layer in Drupal 8, and only accept
     // $modules as a single array argument.
     if (isset($modules[0]) && is_array($modules[0])) {
         $modules = $modules[0];
     }
     if ($modules) {
         module_enable($modules, TRUE);
     }
     // Run the profile tasks.
     $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField();
     if ($install_profile_module_exists) {
         module_enable(array($this->profile), FALSE);
     }
     // Reset/rebuild all data structures after enabling the modules.
     $this->resetAll();
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     drupal_cron_run();
     // Log in with a clean $user.
     $this->originalUser = $user;
     drupal_save_session(FALSE);
     $user = user_load(1);
 }
开发者ID:boombatower,项目名称:drupal,代码行数:42,代码来源:drupal_web_test_case.php

示例11: setUp

 /**
  * Sets up a Backdrop site to be used as a cached installation profile.
  */
 protected function setUp()
 {
     global $conf;
     // Prepare the environment for running tests.
     $this->prepareEnvironment();
     if (!$this->setupEnvironment) {
         return FALSE;
     }
     // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     backdrop_static_reset();
     // Change the database prefix.
     // All static variables need to be reset before the database prefix is
     // changed, since BackdropCacheArray implementations attempt to
     // write back to persistent caches when they are destructed.
     $this->changeDatabasePrefix();
     if (!$this->setupDatabasePrefix) {
         return FALSE;
     }
     // Preset the 'install_profile' system variable, so the first call into
     // system_rebuild_module_data() (in backdrop_install_system()) will register
     // the test's profile as a module. Without this, the installation profile of
     // the parent site (executing the test) is registered, and the test
     // profile's hook_install() and other hook implementations are never invoked.
     config_install_default_config('system');
     config_set('system.core', 'install_profile', $this->profile);
     // Perform the actual Backdrop installation.
     include_once BACKDROP_ROOT . '/core/includes/install.inc';
     backdrop_install_system();
     // Set path variables.
     $core_config = config('system.core');
     $core_config->set('file_default_scheme', 'public');
     $core_config->set('file_public_path', $this->public_files_directory);
     $core_config->set('file_private_path', $this->private_files_directory);
     $core_config->set('file_temporary_path', $this->temp_files_directory);
     $core_config->save();
     // Ensure schema versions are recalculated.
     backdrop_static_reset('backdrop_get_schema_versions');
     // Include the testing profile.
     config_set('system.core', 'install_profile', $this->profile);
     $profile_details = install_profile_info($this->profile, 'en');
     // Install the modules specified by the testing profile.
     module_enable($profile_details['dependencies'], FALSE);
     // Install the profile itself.
     $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField();
     if ($install_profile_module_exists) {
         module_enable(array($this->profile), FALSE);
     }
     return TRUE;
 }
开发者ID:serundeputy,项目名称:backdropcms.org,代码行数:53,代码来源:backdrop_web_test_case_cache.php

示例12: setUp

 /**
  * 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. This can be
  *   either a single array or a variable number of string arguments.
  */
 protected function setUp()
 {
     global $user, $language, $conf;
     // Generate a temporary prefixed database to ensure that tests have a clean starting point.
     $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
     db_update('simpletest_test_id')->fields(array('last_prefix' => $this->databasePrefix))->condition('test_id', $this->testId)->execute();
     // Clone the current connection and replace the current prefix.
     $connection_info = Database::getConnectionInfo('default');
     Database::renameConnection('default', 'simpletest_original_default');
     foreach ($connection_info as $target => $value) {
         $connection_info[$target]['prefix'] = array('default' => $value['prefix']['default'] . $this->databasePrefix);
     }
     Database::addConnectionInfo('default', 'default', $connection_info['default']);
     // Store necessary current values before switching to prefixed database.
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalFileDirectory = file_directory_path();
     $this->originalProfile = drupal_get_profile();
     $clean_url_original = variable_get('clean_url', 0);
     // Save and clean shutdown callbacks array because it static cached and
     // will be changed by the test run. If we don't, then it will contain
     // callbacks from both environments. So testing environment will try
     // to call handlers from original environment.
     $callbacks =& drupal_register_shutdown_function();
     $this->originalShutdownCallbacks = $callbacks;
     $callbacks = array();
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     // Use temporary files directory with the same prefix as the database.
     $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
     $private_files_directory = $public_files_directory . '/private';
     $temp_files_directory = $private_files_directory . '/temp';
     // Create the directories
     file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
     file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
     $this->generatedTestFiles = FALSE;
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', $public_files_directory . '/error.log');
     // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     drupal_static_reset();
     // Set the test information for use in other parts of Drupal.
     $test_info =& $GLOBALS['drupal_test_info'];
     $test_info['test_run_id'] = $this->databasePrefix;
     $test_info['in_child_site'] = FALSE;
     include_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_install_system();
     $this->preloadRegistry();
     // Set path variables.
     variable_set('file_public_path', $public_files_directory);
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
     // Include the default profile.
     variable_set('install_profile', 'standard');
     $profile_details = install_profile_info('standard', 'en');
     // Install the modules specified by the default profile.
     module_enable($profile_details['dependencies'], FALSE);
     // Install modules needed for this test. This could have been passed in as
     // either a single array argument or a variable number of string arguments.
     // @todo Remove this compatibility layer in Drupal 8, and only accept
     // $modules as a single array argument.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
         $modules = $modules[0];
     }
     if ($modules) {
         module_enable($modules, TRUE);
     }
     // Run default profile tasks.
     module_enable(array('standard'), FALSE);
     // Rebuild caches.
     drupal_static_reset();
     drupal_flush_all_caches();
     // Register actions declared by any modules.
     actions_synchronize();
     // Reload global $conf array and permissions.
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     // Reset statically cached schema for new database prefix.
     drupal_get_schema(NULL, TRUE);
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     drupal_cron_run();
     // Log in with a clean $user.
     $this->originalUser = $user;
     drupal_save_session(FALSE);
     $user = user_load(1);
//.........这里部分代码省略.........
开发者ID:nagwani,项目名称:debugging_example,代码行数:101,代码来源:drupal_web_test_case.php


注:本文中的install_profile_info函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。