- <?php
- * @file
- * Install, update and uninstall functions for the simpletest module.
- */
-
- * Minimum value of PHP memory_limit for SimpleTest.
- */
- define('SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT', '64M');
-
- * Implements hook_requirements().
- */
- function simpletest_requirements($phase) {
- $requirements = array();
- $t = get_t();
-
- $has_curl = function_exists('curl_init');
- $has_hash = function_exists('hash_hmac');
- $has_domdocument = method_exists('DOMDocument', 'loadHTML');
- $open_basedir = ini_get('open_basedir');
-
- $requirements['curl'] = array(
- 'title' => $t('cURL'),
- 'value' => $has_curl ? $t('Enabled') : $t('Not found'),
- );
- if (!$has_curl) {
- $requirements['curl']['severity'] = REQUIREMENT_ERROR;
- $requirements['curl']['description'] = $t('The testing framework could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php'));
- }
-
-
- if (!$has_hash) {
- $requirements['hash'] = array(
- 'title' => $t('PHP hash extension'),
- 'value' => $t('Not found'),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => $t('The testing framework could not be installed because the PHP <a href="@hash_url">hash</a> extension is disabled.', array('@hash_url' => 'http://php.net/manual/en/book.hash.php')),
- );
- }
-
- $requirements['php_domdocument'] = array(
- 'title' => $t('PHP DOMDocument class'),
- 'value' => $has_domdocument ? $t('Enabled') : $t('Not found'),
- );
- if (!$has_domdocument) {
- $requirements['php_domdocument']['severity'] = REQUIREMENT_ERROR;
- $requirements['php_domdocument']['description'] = $t('The testing framework requires the DOMDocument class to be available. Check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', array('@link-phpinfo' => url('admin/reports/status/php')));
- }
-
-
-
-
- $requirements['php_open_basedir'] = array(
- 'title' => $t('PHP open_basedir restriction'),
- 'value' => $open_basedir ? $t('Enabled') : $t('Disabled'),
- );
- if ($open_basedir) {
- $requirements['php_open_basedir']['severity'] = REQUIREMENT_ERROR;
- $requirements['php_open_basedir']['description'] = $t('The testing framework requires the PHP <a href="@open_basedir-url">open_basedir</a> restriction to be disabled. Check your webserver configuration or contact your web host.', array('@open_basedir-url' => 'http://php.net/manual/en/ini.core.php#ini.open-basedir'));
- }
-
-
-
- $memory_limit = ini_get('memory_limit');
- if (!backdrop_check_memory_limit(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
- $requirements['php_memory_limit']['severity'] = REQUIREMENT_ERROR;
- $requirements['php_memory_limit']['description'] = $t('The testing framework requires the PHP memory limit to be at least %memory_minimum_limit. The current value is %memory_limit. <a href="@url">Follow these steps to continue</a>.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, '@url' => 'http://drupal.org/node/207036'));
- }
-
- return $requirements;
- }
-
- * Implements hook_schema().
- */
- function simpletest_schema() {
- $schema['simpletest'] = array(
- 'description' => 'Stores simpletest messages',
- 'fields' => array(
- 'message_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique simpletest message ID.',
- ),
- 'test_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Test ID, messages belonging to the same ID are reported together',
- ),
- 'test_class' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The name of the class that created this message.',
- ),
- 'status' => array(
- 'type' => 'varchar',
- 'length' => 9,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Message status. Core understands pass, fail, exception.',
- ),
- 'message' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'description' => 'The message itself.',
- ),
- 'message_group' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The message group this message belongs to. For example: warning, browser, user.',
- ),
- 'function' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Name of the assertion function or method that created this message.',
- ),
- 'line' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Line number on which the function is called.',
- ),
- 'file' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Name of the file where the function is called.',
- ),
- ),
- 'primary key' => array('message_id'),
- 'indexes' => array(
- 'reporter' => array('test_class', 'message_id'),
- ),
- );
- $schema['simpletest_prefix'] = array(
- 'description' => 'Stores simpletest test IDs and active database table prefixes.',
- 'fields' => array(
- 'test_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'unsigned' => TRUE,
- 'description' => 'Unique simpletest ID used to group test results together.',
- ),
- 'prefix' => array(
- 'type' => 'varchar',
- 'length' => 60,
- 'not null' => FALSE,
- 'default' => '',
- 'description' => 'The database prefix used during testing. Multiple prefixes may be used at the same time if using the run-scripts.sh script with concurrency.',
- ),
- ),
- 'indexes' => array(
- 'test_id' => array('test_id'),
- 'prefix' => array('prefix'),
- ),
- );
- return $schema;
- }
-
- * Implements hook_uninstall().
- */
- function simpletest_uninstall() {
- backdrop_load('module', 'simpletest');
- simpletest_clean_database();
-
-
- file_unmanaged_delete_recursive('public://simpletest');
- }
-
- * @defgroup updates-7.x-to-1.x Updates from 7.x to 1.x
- * @{
- * Update functions from Drupal 7.x to Backdrop CMS 1.x.
- */
-
- * Update the simpletest_test_id table to hold a list of active prefixes.
- */
- function simpletest_update_1000() {
- if (db_table_exists('simpletest_test_id')) {
- db_drop_table('simpletest_test_id');
- }
- if (!db_table_exists('simpletest_prefix')) {
- $schema = array(
- 'description' => 'Stores simpletest test IDs and active database table prefixes.',
- 'fields' => array(
- 'test_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'unsigned' => TRUE,
- 'description' => 'Unique simpletest ID used to group test results together.',
- ),
- 'prefix' => array(
- 'type' => 'varchar',
- 'length' => 60,
- 'not null' => FALSE,
- 'default' => '',
- 'description' => 'The database prefix used during testing. Multiple prefixes may be used at the same time if using the run-scripts.sh script with concurrency.',
- ),
- ),
- 'indexes' => array(
- 'test_id' => array('test_id'),
- 'prefix' => array('prefix'),
- ),
- );
- db_create_table('simpletest_prefix', $schema);
- }
- }
-
- * Move simpletest settings from variables to config.
- */
- function simpletest_update_1001() {
-
- $config = config('simpletest.settings');
- $config->set('simpletest_clear_results', update_variable_get('simpletest_clear_results', 1));
- $config->set('simpletest_method', update_variable_get('simpletest_httpauth_method', 1));
- $config->set('simpletest_password', update_variable_get('simpletest_httpauth_password', ''));
- $config->set('simpletest_username', update_variable_get('simpletest_httpauth_username', ''));
- $config->set('simpletest_verbose', update_variable_get('simpletest_verbose', 1));
- $config->save();
-
-
- update_variable_del('simpletest_clear_results');
- update_variable_del('simpletest_httpauth_method');
- update_variable_del('simpletest_httpauth_password');
- update_variable_del('simpletest_httpauth_username');
- update_variable_del('simpletest_verbose');
- }
-
- * @} End of "defgroup updates-7.x-to-1.x"
- * The next series of updates should start at 2000.
- */