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


PHP simpletest_log_read函数代码示例

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


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

示例1: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $user, $language, $settings, $config_directories;
     // In case a fatal error occurred that was not in the test process read the
     // log to pick up any fatal errors.
     simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
     $emailCount = count(state_get('test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
         $this->pass($message, t('E-mail'));
     }
     // Delete temporary files directory.
     file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
     // Remove all prefixed tables.
     $connection_info = Database::getConnectionInfo('default');
     $tables = db_find_tables($connection_info['default']['prefix']['default'] . '%');
     if (empty($tables)) {
         $this->fail('Failed to find test tables to drop.');
     }
     $prefix_length = strlen($connection_info['default']['prefix']['default']);
     foreach ($tables as $table) {
         if (db_drop_table(substr($table, $prefix_length))) {
             unset($tables[$table]);
         }
     }
     if (!empty($tables)) {
         $this->fail('Failed to drop all prefixed tables.');
     }
     // Get back to the original connection.
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
     // Delete the database table prefix record.
     db_delete('simpletest_prefix')->condition('test_id', $this->testId)->condition('prefix', $this->databasePrefix)->execute();
     // Set the configuration direcotires back to the originals.
     $config_directories = $this->originalConfigDirectories;
     // Restore the original settings.
     $settings = $this->originalSettings;
     // Restore original shutdown callbacks array to prevent original
     // environment of calling handlers from test run.
     $callbacks =& backdrop_register_shutdown_function();
     $callbacks = $this->originalShutdownCallbacks;
     // Return the user to the original one.
     $user = $this->originalUser;
     backdrop_save_session(TRUE);
     // Ensure that internal logged in variable and cURL options are reset.
     $this->loggedInUser = FALSE;
     $this->additionalCurlOptions = array();
     // Reload module list and implementations to ensure that test module hooks
     // aren't called after tests.
     module_list(TRUE);
     module_implements_reset();
     // Reset the Field API.
     field_cache_clear();
     // Rebuild caches.
     $this->refreshVariables();
     // Reset public files directory.
     $GLOBALS['conf']['file_public_path'] = $this->originalFileDirectory;
     // Reset language.
     $language = $this->originalLanguage;
     if ($this->originalLanguageDefault) {
         $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
     }
     // Close the CURL handler.
     $this->curlClose();
 }
开发者ID:thejimbirch,项目名称:backdropcms.org,代码行数:69,代码来源:backdrop_web_test_case.php

示例2: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user, $language;
     // In case a fatal error occured that was not in the test process read the
     // log to pick up any fatal errors.
     $db_prefix_temp = $db_prefix;
     $db_prefix = $this->originalPrefix;
     simpletest_log_read($this->testId, $db_prefix, get_class($this), TRUE);
     $db_prefix = $db_prefix_temp;
     $emailCount = count(variable_get('drupal_test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, t('!count e-mail was sent during this test.'), t('!count e-mails were sent during this test.'), array('!count' => $emailCount));
         $this->pass($message, t('E-mail'));
     }
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory.
         file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10));
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         drupal_save_session(TRUE);
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements('', FALSE, TRUE);
         // Reset the Field API.
         field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Reset language.
         $language = $this->originalLanguage;
         if ($this->originalLanguageDefault) {
             $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
         }
         // Close the CURL handler.
         $this->curlClose();
     }
 }
开发者ID:jacobSingh,项目名称:drupal,代码行数:52,代码来源:drupal_web_test_case.php

示例3: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $user, $language;
     // In case a fatal error occurred that was not in the test process read the
     // log to pick up any fatal errors.
     simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
     $emailCount = count(variable_get('drupal_test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
         $this->pass($message, t('E-mail'));
     }
     // Delete temporary files directory.
     file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
     // Remove all prefixed tables (all the tables in the schema).
     $schema = drupal_get_schema(NULL, TRUE);
     foreach ($schema as $name => $table) {
         db_drop_table($name);
     }
     // Get back to the original connection.
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
     // Restore original shutdown callbacks array to prevent original
     // environment of calling handlers from test run.
     $callbacks =& drupal_register_shutdown_function();
     $callbacks = $this->originalShutdownCallbacks;
     // Return the user to the original one.
     $user = $this->originalUser;
     drupal_save_session(TRUE);
     // Ensure that internal logged in variable and cURL options are reset.
     $this->loggedInUser = FALSE;
     $this->additionalCurlOptions = array();
     // Reload module list and implementations to ensure that test module hooks
     // aren't called after tests.
     module_list(TRUE);
     module_implements('', FALSE, TRUE);
     // Reset the Field API.
     field_cache_clear();
     // Rebuild caches.
     $this->refreshVariables();
     // Reset language.
     $language = $this->originalLanguage;
     if ($this->originalLanguageDefault) {
         $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
     }
     // Close the CURL handler.
     $this->curlClose();
 }
开发者ID:rlugojr,项目名称:livereload-examples,代码行数:51,代码来源:drupal_web_test_case.php

示例4: restoreEnvironment

 /**
  * Cleans up the test environment and restores the original environment.
  *
  * Deletes created files, database tables, and reverts environment changes.
  *
  * This method needs to be invoked for both unit and integration tests.
  *
  * @see TestBase::prepareDatabasePrefix()
  * @see TestBase::changeDatabasePrefix()
  * @see TestBase::prepareEnvironment()
  */
 private function restoreEnvironment()
 {
     // Destroy the session if one was started during the test-run.
     $_SESSION = array();
     if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) {
         session_destroy();
         $params = session_get_cookie_params();
         setcookie(session_name(), '', REQUEST_TIME - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     }
     session_name($this->originalSessionName);
     // Reset all static variables.
     // Unsetting static variables will potentially invoke destruct methods,
     // which might call into functions that prime statics and caches again.
     // In that case, all functions are still operating on the test environment,
     // which means they may need to access its filesystem and database.
     drupal_static_reset();
     if ($this->container && $this->container->has('state') && ($state = $this->container->get('state'))) {
         $captured_emails = $state->get('system.test_mail_collector') ?: array();
         $emailCount = count($captured_emails);
         if ($emailCount) {
             $message = $emailCount == 1 ? '1 email was sent during this test.' : $emailCount . ' emails were sent during this test.';
             $this->pass($message, 'Email');
         }
     }
     // Sleep for 50ms to allow shutdown functions and terminate events to
     // complete. Further information: https://www.drupal.org/node/2194357.
     usleep(50000);
     // Remove all prefixed tables.
     $original_connection_info = Database::getConnectionInfo('simpletest_original_default');
     $original_prefix = $original_connection_info['default']['prefix']['default'];
     $test_connection_info = Database::getConnectionInfo('default');
     $test_prefix = $test_connection_info['default']['prefix']['default'];
     if ($original_prefix != $test_prefix) {
         $tables = Database::getConnection()->schema()->findTables('%');
         foreach ($tables as $table) {
             if (Database::getConnection()->schema()->dropTable($table)) {
                 unset($tables[$table]);
             }
         }
     }
     // In case a fatal error occurred that was not in the test process read the
     // log to pick up any fatal errors.
     simpletest_log_read($this->testId, $this->databasePrefix, get_class($this));
     // Restore original dependency injection container.
     $this->container = $this->originalContainer;
     \Drupal::setContainer($this->originalContainer);
     // Delete test site directory.
     file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback'));
     // Restore original database connection.
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
     // Reset all static variables.
     // All destructors of statically cached objects have been invoked above;
     // this second reset is guaranteed to reset everything to nothing.
     drupal_static_reset();
     // Restore original in-memory configuration.
     $GLOBALS['config'] = $this->originalConfig;
     $GLOBALS['conf'] = $this->originalConf;
     new Settings($this->originalSettings);
     // Restore original statics and globals.
     $GLOBALS['config_directories'] = $this->originalConfigDirectories;
     // Re-initialize original stream wrappers of the parent site.
     // This must happen after static variables have been reset and the original
     // container and $config_directories are restored, as simpletest_log_read()
     // uses the public stream wrapper to locate the error.log.
     $this->originalContainer->get('stream_wrapper_manager')->register();
     if (isset($this->originalPrefix)) {
         drupal_valid_test_ua($this->originalPrefix);
     } else {
         drupal_valid_test_ua(FALSE);
     }
     // Restore original shutdown callbacks.
     $callbacks =& drupal_register_shutdown_function();
     $callbacks = $this->originalShutdownCallbacks;
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:86,代码来源:TestBase.php


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