';
+ }
+ $message = t('Processed test @num - %test (remaining: @count of @max).', array('%test' => $test_class, '@num' => $max - $size, '@count' => $size, '@max' => $max));
+ $message .= theme('item_list', $items);
+ $context['message'] = $message;
+ // TODO: Do we want a summary of all?
+
+ // Save working values for the next iteration.
+ $context['sandbox']['tests'] = $test_list;
+ $context['sandbox']['test_results'] = $test_results;
+ // The test_id is the only thing we need to save for the report page.
+ $context['results']['test_id'] = $test_id;
+
+ // Multistep processing: report progress.
+ $context['finished'] = 1 - $size / $max;
+}
+
+function _simpletest_batch_finished($success, $results, $operations) {
+ $_SESSION['test_id'] = $results['test_id'];
+ if ($success) {
+ drupal_set_message(t('The tests have finished running.'));
+ }
+ else {
+ drupal_set_message(t('The tests did not successfully finish.'), 'error');
+ }
+}
+
+/**
+ * Get a list of all of the tests.
+ *
+ * @return
+ * An array of tests, with the class name as the keys and the instantiated
+ * versions of the classes as the values.
+ */
+function simpletest_get_all_tests() {
+ static $formatted_classes;
+ if (!isset($formatted_classes)) {
+ require_once drupal_get_path('module', 'simpletest') . '/drupal_web_test_case.php';
+ $files = array();
+ foreach (array_keys(module_rebuild_cache()) as $module) {
+ $module_path = drupal_get_path('module', $module);
+ $test = $module_path . "/$module.test";
+ if (file_exists($test)) {
+ $files[] = $test;
+ }
+
+ $tests_directory = $module_path . '/tests';
+ if (is_dir($tests_directory)) {
+ foreach (file_scan_directory($tests_directory, '\.test$') as $file) {
+ $files[] = $file->filename;
}
}
- if (count($tests_list) > 0 ) {
- $output = simpletest_run_tests($tests_list);
- break;
+ }
+
+ $existing_classes = get_declared_classes();
+ foreach ($files as $file) {
+ include_once($file);
+ }
+ $classes = array_values(array_diff(get_declared_classes(), $existing_classes));
+ $formatted_classes = array();
+ foreach ($classes as $key => $class) {
+ if (method_exists($class, 'getInfo')) {
+ $formatted_classes[$class] = new $class;
}
- // Fall through
- default:
- drupal_set_message(t('No test has been selected.'), 'error');
+ }
}
+ if (count($formatted_classes) == 0) {
+ drupal_set_message('No test cases found.', 'error');
+ return FALSE;
+ }
+ return $formatted_classes;
+}
- simpletest_running_output($output);
- return FALSE;
+/**
+ * Categorize the tests into groups.
+ *
+ * @param $tests
+ * A list of tests from simpletest_get_all_tests.
+ * @see simpletest_get_all_tests.
+ */
+function simpletest_categorize_tests($tests) {
+ $groups = array();
+ foreach ($tests as $test => $instance) {
+ $info = $instance->getInfo();
+ $groups[$info['group']][] = $instance;
+ }
+ return $groups;
}
/**
@@ -324,13 +502,16 @@
$database = substr($url['path'], 1);
$select = $count ? 'COUNT(table_name)' : 'table_name';
$result = db_query("SELECT $select FROM information_schema.tables WHERE table_schema = '$database' AND table_name LIKE '$db_prefix$base_table%'");
+ $schema = drupal_get_schema_unprocessed('simpletest');
if ($count) {
return db_result($result);
}
$tables = array();
while ($table = db_result($result)) {
- $tables[] = $table;
+ if (!isset($schema[$table])) {
+ $tables[] = $table;
+ }
}
return $tables;
}
@@ -378,65 +559,6 @@
rmdir($path);
}
-/**
- * Actually runs tests
- * @param array $test_list list of tests to run or DEFAULT NULL run all tests
- * @param boolean $html_reporter TRUE if you want results in simple html, FALSE for full drupal page
- */
-function simpletest_run_tests($test_list = NULL, $reporter = 'drupal') {
- static $test_running;
- if (!$test_running) {
- $test_running = TRUE;
- $test = simpletest_get_total_test($test_list);
- switch ($reporter) {
- case 'text':
- $reporter = &new TextReporter();
- break;
- case 'xml':
- $reporter = &new XMLReporter();
- break;
- case 'html':
- $reporter = &new HtmlReporter();
- break;
- case 'drupal':
- $reporter = &new DrupalReporter();
- break;
- }
-
- cache_clear_all();
- $results = $test->run($reporter);
- $test_running = FALSE;
-
- switch (get_class($reporter)) {
- case 'TextReporter':
- case 'XMLReporter':
- case 'HtmlReporter':
- return $results;
- case 'DrupalReporter':
- return $reporter->getOutput();
- }
- }
-}
-
-/**
- * This function makes sure no unnecessary copies of the DrupalTests object are instantiated
- * @param array $classes list of all classes the test should concern or
- * DEFAULT NULL
- * @return DrupalTests object
- */
-function &simpletest_get_total_test($classes = NULL) {
- static $total_test;
- if (!$total_test) {
- simpletest_load();
- $total_test = &new DrupalTests();
- }
- if (!is_null($classes)) {
- $dut = new DrupalTests($classes);
- return $dut;
- }
- return $total_test;
-}
-
function simpletest_settings() {
$form = array();
@@ -473,5 +595,4 @@
);
return system_settings_form($form);
-
}
Index: modules/simpletest/simpletest.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v
retrieving revision 1.3
diff -u -r1.3 simpletest.install
--- modules/simpletest/simpletest.install 10 May 2008 06:55:09 -0000 1.3
+++ modules/simpletest/simpletest.install 23 Jun 2008 19:18:45 -0000
@@ -5,6 +5,7 @@
* Implementation of hook_install().
*/
function simpletest_install() {
+ drupal_install_schema('simpletest');
// Check for files directory.
$path = file_directory_path() . '/simpletest';
if (file_check_directory($path, FILE_CREATE_DIRECTORY)) {
@@ -95,6 +96,7 @@
variable_del('simpletest_httpauth_username');
variable_del('simpletest_httpauth_pass');
variable_del('simpletest_devel');
+ drupal_uninstall_schema('simpletest');
}
/**
@@ -133,3 +135,125 @@
return $requirements;
}
+
+function simpletest_schema() {
+ $schema['simpletest'] = array(
+ 'description' => t('Stores simpletest messages'),
+ 'fields' => array(
+ 'message_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ 'description' => t('Primary Key: Unique simpletest message ID.'),
+ ),
+ 'test_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => t('Test id, messages belonging to the same id are reported together'),
+ ),
+ 'test_class' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => t('The name of the class that created this message.'),
+ ),
+ 'status' => array(
+ 'type' => 'varchar',
+ 'length' => 9,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => t('Message status. Core understands pass, fail, exception.'),
+ ),
+ 'message' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => t('The message itself.'),
+ ),
+ 'message_group' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => t('The message group this message belongs to. For example: warning, browser, user.'),
+ ),
+ 'caller' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => t('Name of the caller function or method that created this message.'),
+ ),
+ 'line' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => t('Line number of the caller.'),
+ ),
+ 'file' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => t('Name of the file where the caller is.'),
+ ),
+ ),
+ 'primary key' => array('message_id'),
+ 'indexes' => array(
+ 'reporter' => array('test_class, message_id'),
+ ),
+ );
+ $schema['simpletest_test_id'] = array(
+ 'description' => t('Stores simpletest test IDs.'),
+ 'fields' => array(
+ 'message_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ 'description' => t('Primary Key: Unique simpletest ID.'),
+ ),
+ ),
+ 'primary key' => array('message_id'),
+ );
+ return $schema;
+}
+
+/**
+ * Create the simpletest tables.
+ */
+function simpletest_update_7000() {
+ $ret = array();
+ $schema = array();
+
+ $schema['simpletest'] = array(
+ 'fields' => array(
+ 'message_id' => array('type' => 'serial', 'not null' => TRUE),
+ 'test_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'test_class' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'status' => array('type' => 'varchar', 'length' => 9, 'not null' => TRUE, 'default' => ''),
+ 'message' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'message_group' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'caller' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'line' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'file' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ ),
+ 'primary key' => array('message_id'),
+ 'indexes' => array(
+ 'reporter' => array('test_class, message_id'),
+ ),
+ );
+
+ $schema['simpletest_test_id'] = array(
+ 'fields' => array(
+ 'message_id' => array('type' => 'serial', 'not null' => TRUE),
+ ),
+ 'primary key' => array('message_id'),
+ );
+
+ foreach ($schema as $name => $definition) {
+ db_create_table($ret, $name, $definition);
+ }
+
+ return $ret;
+}
\ No newline at end of file
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.19
diff -u -r1.19 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php 17 Jun 2008 01:12:50 -0000 1.19
+++ modules/simpletest/drupal_web_test_case.php 23 Jun 2008 19:18:45 -0000
@@ -4,7 +4,7 @@
/**
* Test case for typical Drupal tests.
*/
-class DrupalWebTestCase extends UnitTestCase {
+class DrupalWebTestCase {
protected $_logged_in = FALSE;
protected $_content;
protected $plain_text;
@@ -20,25 +20,286 @@
protected $original_file_directory;
/**
- * Retrieve the test information from getInfo().
+ * Constructor for DrupalWebTestCase.
*
- * @param string $label Name of the test to be used by the SimpleTest library.
+ * @param @test_id
+ * Tests with the same id are reported together.
*/
- function __construct($label = NULL) {
- if (!$label) {
- if (method_exists($this, 'getInfo')) {
- $info = $this->getInfo();
- $label = $info['name'];
+ function __construct($test_id = NULL) {
+ $this->test_id = $test_id;
+ }
+
+ /**
+ * This function stores the assert. Do not call directly.
+ *
+ * @param $status
+ * Can be 'pass', 'fail', 'exception'. TRUE is a synonym for 'pass', FALSE
+ * for 'fail'.
+ * @param $message
+ * The message string.
+ * @param $group
+ * WHich group this assert belongs to.
+ * @param $custom_caller
+ * By default, the assert comes from a function which names start with
+ * 'test'. Instead, you can specify where this assert originates from
+ * by passing in an associative array as $custom_caller. Key 'file' is
+ * the name of the source file, 'line' is the line number and 'function'
+ * is the caller function itself.
+ */
+ protected function _assert($status, $message = '', $group = 'Other', $custom_caller = NULL) {
+ global $db_prefix;
+ if (is_bool($status)) {
+ $status = $status ? 'pass' : 'fail';
+ }
+ if (!isset($custom_caller)) {
+ $callers = debug_backtrace();
+ array_shift($callers);
+ foreach ($callers as $function) {
+ if (substr($function['function'], 0, 6) != 'assert' && $function['function'] != 'pass' && $function['function'] != 'fail') {
+ break;
+ }
}
}
- parent::__construct($label);
+ else {
+ $function = $custom_caller;
+ }
+ $current_db_prefix = $db_prefix;
+ $db_prefix = $this->db_prefix_original;
+ db_query("INSERT INTO {simpletest} (test_id, test_class, status, message, message_group, caller, line, file) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $this->test_id, get_class($this), $status, $message, $group, $function['function'], $function['line'], $function['file']);
+ $db_prefix = $current_db_prefix;
+ return $status;
+ }
+
+ /**
+ * Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
+ *
+ * @param $value
+ * The value on which the assertion is to be done.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertTrue($value, $message = '', $group = 'Other') {
+ return $this->_assert((bool) $value, $message ? $message : t('%value is TRUE', array('%value' => $value)), $group);
+ }
+
+ /**
+ * Check to see if a value is false (an empty string, 0, NULL, or FALSE).
+ *
+ * @param $value
+ * The value on which the assertion is to be done.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertFalse($value, $message = '', $group = 'Other') {
+ return $this->_assert(!$value, $message ? $message : t('%value is FALSE', array('%value' => $value)), $group);
+ }
+
+ /**
+ * Check to see if a value is NULL.
+ *
+ * @param $value
+ * The value on which the assertion is to be done.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertNull($value, $message = '', $group = 'Other') {
+ return $this->_assert(!isset($value), $message ? $message : t('%value is NULL', array('%value' => $value)), $group);
+ }
+
+ /**
+ * Check to see if a value is not NULL.
+ *
+ * @param $value
+ * The value on which the assertion is to be done.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertNotNull($value, $message = '', $group = 'Other') {
+ return $this->_assert(isset($value), $message ? $message : t('%value is not NULL', array('%value' => $value)), $group);
+ }
+
+ /**
+ * Check to see if two values are equal.
+ *
+ * @param $first
+ * The first value to check.
+ * @param $second
+ * The second value to check.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertEqual($first, $second, $message = '', $group = 'Other') {
+ return $this->_assert($first == $second, $message ? $message : t('%first is equal to %second', array('%first' => $first, '%second' => $second)), $group);
+ }
+
+ /**
+ * Check to see if two values are not equal.
+ *
+ * @param $first
+ * The first value to check.
+ * @param $second
+ * The second value to check.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertNotEqual($first, $second, $message = '', $group = 'Other') {
+ return $this->_assert($first != $second, $message ? $message : t('%first is not equal to %second', array('%first' => $first, '%second' => $second)), $group);
+ }
+
+ /**
+ * Check to see if two values are identical.
+ *
+ * @param $first
+ * The first value to check.
+ * @param $second
+ * The second value to check.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
+ return $this->_assert($first === $second, $message ? $message : t('%first is identical to %second', array('%first' => $first, '%second' => $second)), $group);
+ }
+
+ /**
+ * Check to see if two values are not identical.
+ *
+ * @param $first
+ * The first value to check.
+ * @param $second
+ * The second value to check.
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * The status passed in.
+ */
+ protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') {
+ return $this->_assert($first !== $second, $message ? $message : t('%first is not identical to %second', array('%first' => $first, '%second' => $second)), $group);
+ }
+
+ /**
+ * Fire an assertion that is always positive.
+ *
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * TRUE.
+ */
+ protected function pass($message = NULL, $group = 'Other') {
+ return $this->_assert(TRUE, $message, $group);
+ }
+
+ /**
+ * Fire an assertion that is always negative.
+ *
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @return
+ * FALSE.
+ */
+ protected function fail($message = NULL, $group = 'Other') {
+ return $this->_assert(FALSE, $message, $group);
+ }
+
+ /**
+ * Fire an error assertion.
+ *
+ * @param $message
+ * The message to display along with the assertion.
+ * @param $group
+ * The type of assertion - examples are "Browser", "PHP".
+ * @param $custom_caller
+ * The caller of the error.
+ */
+ protected function error($message = '', $group = 'Other', $custom_caller = NULL) {
+ return $this->_assert('exception', $message, $group, $custom_caller);
+ }
+
+ /**
+ * Run all tests in this class.
+ */
+ function run() {
+ set_error_handler(array($this, 'errorHandler'));
+ $this->setUp();
+ $methods = array();
+ // Iterate through all the methods in this class.
+ foreach (get_class_methods(get_class($this)) as $method) {
+ // If the current method starts with "test", run it - it's a test.
+ if (strtolower(substr($method, 0, 4)) == 'test') {
+ $this->$method();
+ }
+ }
+ // Finish up.
+ $this->tearDown();
+ restore_error_handler();
+ }
+
+ /**
+ * Handle errors.
+ *
+ * @see set_error_handler
+ */
+ function errorHandler($severity, $message, $file = NULL, $line = NULL) {
+ $severity = $severity & error_reporting();
+ if ($severity) {
+ $error_map = array(
+ E_STRICT => 'Run-time notice',
+ E_WARNING => 'Warning',
+ E_NOTICE => 'Notice',
+ E_CORE_ERROR => 'Core error',
+ E_CORE_WARNING => 'Core warning',
+ E_USER_ERROR => 'User error',
+ E_USER_WARNING => 'User warning',
+ E_USER_NOTICE => 'User notice',
+ E_RECOVERABLE_ERROR => 'Recoverable error',
+ );
+ $this->error($message, $error_map[$severity], array(
+ 'function' => '',
+ 'line' => $line,
+ 'file' => $file,
+ ));
+ }
+ return TRUE;
}
/**
* Creates a node based on default settings.
*
- * @param settings
- * An assocative array of settings to change from the defaults, keys are
+ * @param $settings
+ * An associative array of settings to change from the defaults, keys are
* node properties, for example 'body' => 'Hello, world!'.
* @return object Created node object.
*/
@@ -62,8 +323,8 @@
);
$defaults['teaser'] = $defaults['body'];
// If we already have a node, we use the original node's created time, and this
- if (isset($settings['created'])) {
- $defaults['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
+ if (isset($defaults['created'])) {
+ $defaults['date'] = format_date($defaults['created'], 'custom', 'Y-m-d H:i:s O');
}
if (empty($settings['uid'])) {
global $user;
@@ -82,10 +343,11 @@
/**
* Creates a custom content type based on default settings.
*
- * @param settings
+ * @param $settings
* An array of settings to change from the defaults.
* Example: 'type' => 'foo'.
- * @return object Created content type.
+ * @return
+ * Created content type.
*/
function drupalCreateContentType($settings = array()) {
// find a non-existent random type name.
@@ -126,9 +388,12 @@
/**
* Get a list files that can be used in tests.
*
- * @param string $type File type, possible values: 'binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'.
- * @param integer $size File size in bytes to match. Please check the tests/files folder.
- * @return array List of files that match filter.
+ * @param $type
+ * File type, possible values: 'binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'.
+ * @param $size
+ * File size in bytes to match. Please check the tests/files folder.
+ * @return
+ * List of files that match filter.
*/
function drupalGetTestFiles($type, $size = NULL) {
$files = array();
@@ -166,9 +431,12 @@
/**
* Generates a random string.
*
- * @param integer $number Number of characters in length to append to the prefix.
- * @param string $prefix Prefix to use.
- * @return string Randomly generated string.
+ * @param $number
+ * Number of characters in length to append to the prefix.
+ * @param $prefix
+ * Prefix to use.
+ * @return
+ * Randomly generated string.
*/
function randomName($number = 4, $prefix = 'simpletest_') {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_';
@@ -185,8 +453,10 @@
* Create a user with a given set of permissions. The permissions correspond to the
* names given on the privileges page.
*
- * @param array $permissions Array of permission names to assign to user.
- * @return A fully loaded user object with pass_raw property, or FALSE if account
+ * @param $permissions
+ * Array of permission names to assign to user.
+ * @return
+ * A fully loaded user object with pass_raw property, or FALSE if account
* creation fails.
*/
function drupalCreateUser($permissions = NULL) {
@@ -218,8 +488,10 @@
/**
* Internal helper function; Create a role with specified permissions.
*
- * @param array $permissions Array of permission names to assign to role.
- * @return integer Role ID of newly created role, or FALSE if role creation failed.
+ * @param $permissions
+ * Array of permission names to assign to role.
+ * @return
+ * Role ID of newly created role, or FALSE if role creation failed.
*/
private function _drupalCreateRole($permissions = NULL) {
// Generate string version of permissions list.
@@ -253,9 +525,12 @@
/**
* Check to make sure that the array of permissions are valid.
*
- * @param array $permissions Permissions to check.
- * @param boolean $reset Reset cached available permissions.
- * @return boolean Valid.
+ * @param $permissions
+ * Permissions to check.
+ * @param $reset
+ * Reset cached available permissions.
+ * @return
+ * TRUE or FALSE depending on whether the permissions are valid.
*/
private function checkPermissions(array $permissions, $reset = FALSE) {
static $available;
@@ -279,9 +554,11 @@
* user out before logging in the specified user. If no user is specified then a new
* user will be created and logged in.
*
- * @param object $user User object representing the user to login.
- * @return object User that was logged in. Useful if no user was passed in order
- * to retreive the created user.
+ * @param $user
+ * User object representing the user to login.
+ * @return
+ * User that was logged in. Useful if no user was passed in order to retrieve
+ * the created user.
*/
function drupalLogin($user = NULL) {
if ($this->_logged_in) {
@@ -369,8 +646,6 @@
$this->original_file_directory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
file_check_directory(file_directory_path(), TRUE); // Create the files directory.
-
- parent::setUp();
}
/**
@@ -423,27 +698,14 @@
// Close the CURL handler.
$this->curlClose();
+ restore_error_handler();
}
- parent::tearDown();
- }
-
- /**
- * Set necessary reporter info.
- */
- function run(&$reporter) {
- $arr = array('class' => get_class($this));
- if (method_exists($this, 'getInfo')) {
- $arr = array_merge($arr, $this->getInfo());
- }
- $reporter->test_info_stack[] = $arr;
- parent::run($reporter);
- array_pop($reporter->test_info_stack);
}
/**
* Initializes the cURL connection and gets a session cookie.
*
- * This function will add authentaticon headers as specified in
+ * This function will add authentication headers as specified in
* simpletest_httpauth_username and simpletest_httpauth_pass variables.
* Also, see the description of $curl_options among the properties.
*/
@@ -471,10 +733,12 @@
}
/**
- * Peforms a cURL exec with the specified options after calling curlConnect().
+ * Performs a cURL exec with the specified options after calling curlConnect().
*
- * @param array $curl_options Custom cURL options.
- * @return string Content returned from the exec.
+ * @param
+ * $curl_options Custom cURL options.
+ * @return
+ * Content returned from the exec.
*/
protected function curlExec($curl_options) {
$this->curlConnect();
@@ -498,9 +762,10 @@
}
/**
- * Parse content returned from curlExec using DOM and simplexml.
+ * Parse content returned from curlExec using DOM and SimpleXML.
*
- * @return SimpleXMLElement A SimpleXMLElement or FALSE on failure.
+ * @return
+ * A SimpleXMLElement or FALSE on failure.
*/
protected function parse() {
if (!$this->elements) {
@@ -523,9 +788,12 @@
/**
* Retrieves a Drupal path or an absolute path.
*
- * @param $path string Drupal path or url to load into internal browser
- * @param array $options Options to be forwarded to url().
- * @return The retrieved HTML string, also available as $this->drupalGetContent()
+ * @param $path
+ * Drupal path or url to load into internal browser
+ * @param $options
+ * Options to be forwarded to url().
+ * @return
+ * The retrieved HTML string, also available as $this->drupalGetContent()
*/
function drupalGet($path, $options = array()) {
$options['absolute'] = TRUE;
@@ -542,14 +810,14 @@
* Execute a POST request on a Drupal page.
* It will be done as usual POST request with SimpleBrowser.
*
- * @param string $path
+ * @param $path
* Location of the post form. Either a Drupal path or an absolute path or
* NULL to post to the current page.
- * @param array $edit
+ * @param $edit
* Field data in an assocative array. Changes the current input fields
* (where possible) to the values indicated. A checkbox can be set to
* TRUE to be checked and FALSE to be unchecked.
- * @param string $submit
+ * @param $submit
* Value of the submit button.
* @param $tamper
* If this is set to TRUE then you can post anything, otherwise hidden and
@@ -604,15 +872,15 @@
* exist and attempt to create POST data in the correct manner for the particular
* field type.
*
- * @param array $post
+ * @param $post
* Reference to array of post values.
- * @param array $edit
+ * @param $edit
* Reference to array of edit values to be checked against the form.
- * @param string $submit
+ * @param $submit
* Form submit button value.
- * @param array $form
+ * @param $form
* Array of form elements.
- * @return boolean
+ * @return
* Submit value matches a valid submit input in the form.
*/
protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
@@ -622,13 +890,12 @@
foreach ($elements as $element) {
// SimpleXML objects need string casting all the time.
$name = (string) $element['name'];
- $id = (string) $element['id'];
// This can either be the type of or the name of the tag itself
// for