diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-15 06:20:20 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-15 06:20:20 +0000 |
commit | 8b86d0da84570d3f6d461a502b94bedc2f91889e (patch) | |
tree | 701433b527d673f2c0bdf88236e7239a39c2826a /modules | |
parent | 838b4c65100df5ebda24a4b10f6405d2b38a888e (diff) | |
download | brdo-8b86d0da84570d3f6d461a502b94bedc2f91889e.tar.gz brdo-8b86d0da84570d3f6d461a502b94bedc2f91889e.tar.bz2 |
#296574 by boombatower and chx: Provide debug function for debugging during tests and elsewhere.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 7 | ||||
-rw-r--r-- | modules/simpletest/simpletest.module | 11 | ||||
-rw-r--r-- | modules/simpletest/simpletest.pages.inc | 8 | ||||
-rw-r--r-- | modules/simpletest/simpletest.test | 8 | ||||
-rw-r--r-- | modules/simpletest/tests/common.test | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/error.test | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/error_test.module | 2 |
7 files changed, 30 insertions, 10 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 5bb6c51a9..ad27ac258 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -42,6 +42,7 @@ abstract class DrupalTestCase { '#pass' => 0, '#fail' => 0, '#exception' => 0, + '#debug' => 0, ); /** @@ -376,6 +377,12 @@ abstract class DrupalTestCase { * FALSE. */ protected function error($message = '', $group = 'Other', array $caller = NULL) { + if ($group == 'User notice') { + // Since 'User notice' is set by trigger_error() which is used for debug + // set the message to a status of 'debug'. + return $this->assert('debug', $message, 'Debug', $caller); + } + return $this->assert('exception', $message, $group, $caller); } diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index a431e7c51..18f0b0390 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -95,11 +95,16 @@ function simpletest_js_alter(&$javascript) { } function _simpletest_format_summary_line($summary) { - return t('@pass, @fail, and @exception', array( + $args = array( '@pass' => format_plural(isset($summary['#pass']) ? $summary['#pass'] : 0, '1 pass', '@count passes'), '@fail' => format_plural(isset($summary['#fail']) ? $summary['#fail'] : 0, '1 fail', '@count fails'), '@exception' => format_plural(isset($summary['#exception']) ? $summary['#exception'] : 0, '1 exception', '@count exceptions'), - )); + ); + if (!$summary['#debug']) { + return t('@pass, @fail, and @exception', $args); + } + $args['@debug'] = format_plural(isset($summary['#debug']) ? $summary['#debug'] : 0, '1 debug message', '@count debug messages'); + return t('@pass, @fail, @exception, and @debug', $args); } /** @@ -155,7 +160,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) { // First iteration: initialize working values. $test_list = $test_list_init; $context['sandbox']['max'] = count($test_list); - $test_results = array('#pass' => 0, '#fail' => 0, '#exception' => 0); + $test_results = array('#pass' => 0, '#fail' => 0, '#exception' => 0, '#debug' => 0); } else { // Nth iteration: get the current values where we last stored them. diff --git a/modules/simpletest/simpletest.pages.inc b/modules/simpletest/simpletest.pages.inc index 2a3e21c6a..3b0952f16 100644 --- a/modules/simpletest/simpletest.pages.inc +++ b/modules/simpletest/simpletest.pages.inc @@ -226,6 +226,7 @@ function simpletest_result_form(&$form_state, $test_id) { '#pass' => 0, '#fail' => 0, '#exception' => 0, + '#debug' => 0, ); // Cycle through each test group. @@ -264,14 +265,14 @@ function simpletest_result_form(&$form_state, $test_id) { $form['result']['summary']['#' . $assertion->status]++; } $form['result']['results'][$group]['table'] = array( - '#theme' => 'table', - '#header' => $header, + '#theme' => 'table', + '#header' => $header, '#rows' => $rows, ); // Set summary information. $group_summary['#ok'] = $group_summary['#fail'] + $group_summary['#exception'] == 0; - $form['result']['results'][$group]['#collapsed'] = $group_summary['#ok']; + $form['result']['results'][$group]['#collapsed'] = $group_summary['#ok'] && !$group_summary['#debug']; // Store test group (class) as for use in filter. $filter[$group_summary['#ok'] ? 'pass' : 'fail'][] = $group; @@ -404,6 +405,7 @@ function simpletest_result_status_image($status) { 'pass' => theme('image', 'misc/watchdog-ok.png'), 'fail' => theme('image', 'misc/watchdog-error.png'), 'exception' => theme('image', 'misc/watchdog-warning.png'), + 'debug' => theme('image', 'misc/watchdog-warning.png'), ); } if (isset($map[$status])) { diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test index 96cea0a9c..17ae53bf3 100644 --- a/modules/simpletest/simpletest.test +++ b/modules/simpletest/simpletest.test @@ -121,6 +121,8 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase { // Generates a warning inside a PHP function. array_key_exists(NULL, NULL); + + debug('Foo', 'Debug'); } /** @@ -151,6 +153,10 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase { // the function name 'array_key_exists'. $this->assertAssertion('array_key_exists', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'); + $this->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'); + + $this->assertEqual('6 passes, 2 fails, 2 exceptions, and 1 debug message', $this->childTestResults['summary'], 'Stub test summary is correct'); + $this->test_ids[] = $test_id = $this->getTestIdFromResults(); $this->assertTrue($test_id, t('Found test ID in results.')); } @@ -202,7 +208,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase { if ($this->parse()) { if ($fieldset = $this->getResultFieldSet()) { // Code assumes this is the only test in group. - $results['summary'] = $this->asText($fieldset->div); + $results['summary'] = $this->asText($fieldset->div[1]); $results['name'] = $this->asText($fieldset->legend); $results['assertions'] = array(); diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index bbea196b2..f4837b8d0 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -1054,7 +1054,7 @@ class DrupalErrorCollectionUnitTest extends DrupalWebTestCase { if (count($this->collectedErrors) == 3) { $this->assertError($this->collectedErrors[0], 'Notice', 'error_test_generate_warnings()', 'error_test.module', 'Undefined variable: bananas'); $this->assertError($this->collectedErrors[1], 'Warning', 'error_test_generate_warnings()', 'error_test.module', 'Division by zero'); - $this->assertError($this->collectedErrors[2], 'User notice', 'error_test_generate_warnings()', 'error_test.module', 'Drupal is awesome'); + $this->assertError($this->collectedErrors[2], 'User warning', 'error_test_generate_warnings()', 'error_test.module', 'Drupal is awesome'); } else { // Give back the errors to the log report. diff --git a/modules/simpletest/tests/error.test b/modules/simpletest/tests/error.test index 2be62f327..28d6e0830 100644 --- a/modules/simpletest/tests/error.test +++ b/modules/simpletest/tests/error.test @@ -36,7 +36,7 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase { '%file' => realpath('modules/simpletest/tests/error_test.module'), ); $error_user_notice = array( - '%type' => 'User notice', + '%type' => 'User warning', '%message' => 'Drupal is awesome', '%function' => 'error_test_generate_warnings()', '%line' => 48, diff --git a/modules/simpletest/tests/error_test.module b/modules/simpletest/tests/error_test.module index 7ee5cca05..c9a859dbe 100644 --- a/modules/simpletest/tests/error_test.module +++ b/modules/simpletest/tests/error_test.module @@ -45,7 +45,7 @@ function error_test_generate_warnings($collect_errors = FALSE) { // This will generate a warning. $awesomely_big = 1/0; // This will generate a user error. - trigger_error("Drupal is awesome", E_USER_NOTICE); + trigger_error("Drupal is awesome", E_USER_WARNING); return ""; } |