diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-17 10:49:40 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-17 10:49:40 +0000 |
commit | 13b38eadd5b66fb20877aa5c99d1b1c76aa4db30 (patch) | |
tree | 5b4b1b32731c1903df1eb86692db212eb1e9abdc | |
parent | d4a7074294d9e2a3c58d61b9fd0a078430446ace (diff) | |
download | brdo-13b38eadd5b66fb20877aa5c99d1b1c76aa4db30.tar.gz brdo-13b38eadd5b66fb20877aa5c99d1b1c76aa4db30.tar.bz2 |
- Patch #407294 by Litrik: provide hooks to allow other modules to listen to SimpleTest results. Java-lamp, here I come!
-rw-r--r-- | modules/simpletest/simpletest.api.php | 57 | ||||
-rw-r--r-- | modules/simpletest/simpletest.module | 6 |
2 files changed, 63 insertions, 0 deletions
diff --git a/modules/simpletest/simpletest.api.php b/modules/simpletest/simpletest.api.php new file mode 100644 index 000000000..a1cc808de --- /dev/null +++ b/modules/simpletest/simpletest.api.php @@ -0,0 +1,57 @@ +<?php +// $Id$ + +/** + * @file + * Hooks provided by the SimpleTest module. + */ + +/** + * @addtogroup hooks + * @{ + */ + +/** + * A test group has started. + * + * This hook is called just once at the beginning of a test group. + * + * @return + * None. + * + */ +function hook_test_group_started() { +} + +/** + * A test group has finished. + * + * This hook is called just once at the end of a test group. + * + * @return + * None. + * + */ +function hook_test_group_finished() { +} + +/** + * An individual test has finished. + * + * This hook is called when an individual test has finished. + * + * @param + * $results The results of the test as gathered by DrupalWebTestCase. + * + * @return + * None. + * + * @see DrupalWebTestCase->results + */ +function hook_test_finished($results) { +} + + +/** + * @} End of "addtogroup hooks". + */ diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index caceeda66..d4aa9f6cf 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -127,6 +127,9 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') { 'init_message' => t('Processing test @num of @max - %test.', array('%test' => $info['name'], '@num' => '1', '@max' => count($test_list))), ); batch_set($batch); + + module_invoke_all('test_group_started'); + // Normally, the forms portion of the batch API takes care of calling // batch_process(), but in the process it saves the whole $form into the // database (which is huge for the test selection form). @@ -164,6 +167,8 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) { $size = count($test_list); $info = $test->getInfo(); + module_invoke_all('test_finished', $test->results); + // Gather results and compose the report. $test_results[$test_class] = $test->results; foreach ($test_results[$test_class] as $key => $value) { @@ -195,6 +200,7 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) { else { drupal_set_message(t('The tests did not successfully finish.'), 'error'); } + module_invoke_all('test_group_finished'); } /** |