? .svn ? frameworkpatch ? patch.patch ? php5powah_tests.patch ? prefixing.patch ? simpletest ? simpletest_orig Index: drupal_test_case.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_test_case.php,v retrieving revision 1.62 diff -u -p -r1.62 drupal_test_case.php --- drupal_test_case.php 22 Mar 2008 05:08:39 -0000 1.62 +++ drupal_test_case.php 23 Mar 2008 04:39:02 -0000 @@ -345,7 +345,7 @@ class DrupalTestCase extends UnitTestCas return $user; } - + /* * Logs a user out of the internal browser, then check the login page to confirm logout. */ @@ -448,7 +448,7 @@ class DrupalTestCase extends UnitTestCas * Also, see the description of $curl_options among the properties. */ protected function curlConnect() { - global $base_url; + global $base_url, $db_prefix; if (!isset($this->ch)) { $this->ch = curl_init(); $curl_options = $this->curl_options + array( @@ -457,6 +457,9 @@ class DrupalTestCase extends UnitTestCas CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_RETURNTRANSFER => TRUE, ); + if (preg_match('/simpletest\d+/', $db_prefix)) { + $curl_options[CURLOPT_USERAGENT] = $db_prefix; + } if (!isset($curl_options[CURLOPT_USERPWD]) && ($auth = variable_get('simpletest_httpauth_username', ''))) { if ($pass = variable_get('simpletest_httpauth_pass', '')) { $auth .= ':'. $pass; @@ -529,7 +532,9 @@ class DrupalTestCase extends UnitTestCas */ function drupalPost($path, $edit, $submit, $tamper = FALSE) { if (isset($path)) { + file_put_contents('/tmp/t1.htm', $this->_content); $html = $this->drupalGet($path); + file_put_contents('/tmp/t.htm', $html); } if ($this->parse()) { $edit_save = $edit; @@ -564,6 +569,7 @@ class DrupalTestCase extends UnitTestCas return $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POSTFIELDS => $encoded_post)); } } + // We have not found a form which contained all fields of $edit. $this->fail(t('Found the requested form')); $this->assertTrue($submit_matches, t('Found the @submit button', array('@submit' => $submit))); Index: simpletest.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.info,v retrieving revision 1.5 diff -u -p -r1.5 simpletest.info --- simpletest.info 21 Feb 2008 23:38:28 -0000 1.5 +++ simpletest.info 23 Mar 2008 04:39:02 -0000 @@ -2,4 +2,4 @@ name = "SimpleTest module" description = "Provides simpletest classes to developers as well as some standard tests for Drupal" package = Simpletest -core = 7.x +core = 6.x Index: simpletest.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v retrieving revision 1.36 diff -u -p -r1.36 simpletest.module --- simpletest.module 21 Mar 2008 23:29:49 -0000 1.36 +++ simpletest.module 23 Mar 2008 04:39:02 -0000 @@ -20,13 +20,13 @@ function simpletest_help($path, $arg) { * Implementation of hook_menu(). */ function simpletest_menu() { - $items['admin/build/simpletest'] = array( + $items['admin/build/simpletest'] = array( 'title' => 'Simpletest', 'page callback' => 'simpletest_entrypoint', 'description' => 'Run tests against Drupal core and your active modules. These tests help assure that your site code is working as designed.', 'access arguments' => array('administer unit tests'), ); - $items['admin/settings/simpletest'] = array( + $items['admin/settings/simpletest'] = array( 'title' => 'Simpletest settings', 'description' => 'Configure unit testing framework.', 'page callback' => 'drupal_get_form', @@ -40,7 +40,7 @@ function simpletest_menu() { * Implementation of hook_perm(). */ function simpletest_perm() { - return array('administer unit tests'); + return array('administer unit tests'); } /** @@ -50,7 +50,7 @@ function simpletest_perm() { function simpletest_load() { static $loaded; if ($loaded) { - return true; + return true; } global $user; if ($user->uid != 1) { @@ -58,21 +58,21 @@ function simpletest_load() { } $loaded = true; if (!defined('SIMPLE_TEST')) { - define('SIMPLE_TEST', drupal_get_path('module', 'simpletest') .'/simpletest'); + define('SIMPLE_TEST', drupal_get_path('module', 'simpletest') .'/simpletest'); } if (!is_dir(SIMPLE_TEST)) { return simpletest_trigger_error('not available'); } - + // We currently use only the web tester that DrupalTestCase is built upon require_once(SIMPLE_TEST .'/unit_tester.php'); require_once(SIMPLE_TEST .'/reporter.php'); require_once('drupal_reporter.php'); - + if (version_compare(SimpleTest::getVersion(), '1.0.1beta2') < 0) { return simpletest_trigger_error('stale version'); } - + $path = drupal_get_path('module', 'simpletest') .'/'; require_once($path .'drupal_test_case.php'); require_once($path .'drupal_unit_tests.php'); @@ -86,7 +86,7 @@ function simpletest_entrypoint() { if (!simpletest_load()) { // @TODO - Find a better way for this return. It is currently needed to show error, // and returning true leads to page not found - return ' '; + return ' '; } drupal_add_js(drupal_get_path('module', 'simpletest') .'/simpletest.js', 'module'); $output = drupal_get_form('simpletest_overview_form'); @@ -119,7 +119,7 @@ function simpletest_overview_form_submit switch ($form_state['values']['running_options']) { case 'all_tests': $output = simpletest_run_tests(); - break; + break; case 'selected_tests': $tests_list = array(); foreach ($form_state['values'] as $item => $value) { @@ -135,7 +135,7 @@ function simpletest_overview_form_submit default: simpletest_trigger_error('no tests selected'); } - + simpletest_running_output($output); return FALSE; } @@ -145,9 +145,9 @@ function simpletest_overview_form_submit */ function simpletest_overview_form() { $output = array(); - + $total_test = &simpletest_get_total_test(); - + $test_instances = $total_test->getTestInstances(); foreach ($test_instances as $group_test) { $group = array(); @@ -158,7 +158,7 @@ function simpletest_overview_form() { '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => 'Tests', - '#attributes' => array('class' => $group_class), + '#attributes' => array('class' => $group_class), ); foreach ($tests as $test) { $test_info = $test->get_info(); @@ -176,10 +176,10 @@ function simpletest_overview_form() { '#attributes' => array('class' => 'select_all'), ); } - + $submit['running_options'] = array( '#type' => 'radios', - '#default_value' => 'selected_tests', + '#default_value' => 'selected_tests', '#options' => array( 'all_tests' => t('Run all tests (WARNING, this may take a long time)'), 'selected_tests' => t('Run selected tests'), @@ -189,7 +189,7 @@ function simpletest_overview_form() { '#type' => 'submit', '#value' => t('Begin'), ); - + $output[] = $submit + array( '#type' => 'fieldset', '#collapsible' => FALSE, @@ -206,29 +206,50 @@ function simpletest_overview_form() { * @param boolean $html_reporter true if you want results in simple html, FALSE for full drupal page */ function simpletest_run_tests($testlist = NULL, $reporter = 'drupal') { - global $test_running; + global $test_running, $db_prefix, $simpletest_ua_handling; + static $db_prefix_original; if (!$test_running) { $test_running = TRUE; $test = simpletest_get_total_test($testlist); + if ($simpletest_ua_handling) { + $db_prefix_original = $db_prefix; + $db_prefix = 'simpletest'. mt_rand(1000, 1000000); + include_once './includes/install.inc'; + drupal_install_system(); + $module_list = drupal_verify_profile('default', 'en'); + drupal_install_modules($module_list); + default_profile_tasks(); + menu_rebuild(); + actions_synchronize(); + _drupal_flush_css_js(); + variable_set('install_profile', 'default'); + variable_set('install_task', 'profile-finished'); + } switch ($reporter) { case 'text': $reporter = &new TextReporter(); - break; + break; case 'xml': $reporter = &new XMLReporter(); break; case 'html': - $reporter = &new HtmlReporter(); - break; + $reporter = &new HtmlReporter(); + break; case 'drupal': - $reporter = &new DrupalReporter(); - break; + $reporter = &new DrupalReporter(); + break; } cache_clear_all(); $results = $test->run($reporter); + $schema = drupal_get_schema(NULL, TRUE); + $ret = array(); + foreach ($schema as $name => $table) { + db_drop_table($ret, $name); + } + $db_prefix = $db_prefix_original; $test_running = FALSE; - + switch (get_class($reporter)) { case 'TextReporter': exit ($results ? 0 : 1); @@ -251,7 +272,7 @@ function &simpletest_get_total_test($cla static $total_test; if (!$total_test) { if (!simpletest_load()) { - return FALSE; + return FALSE; } $total_test = &new DrupalUnitTests(); } @@ -297,7 +318,7 @@ function simpletest_settings() { '#title' => t('Use devel query log on test result pages'), '#default_value' => variable_get('simpletest_devel', false), ); - + return system_settings_form($form); }