error_test.module

You are here

Functions

Namesort descending Description
error_test_generate_warnings Menu callback; generate warnings to test the error handler.
error_test_menu Implements hook_menu().
error_test_trigger_exception Menu callback; trigger an exception to test the exception handler.
error_test_trigger_pdo_exception Menu callback; trigger an exception to test the exception handler.

File

modules/simpletest/tests/error_test.module
View source
  1. <?php
  2. /**
  3. * Implements hook_menu().
  4. */
  5. function error_test_menu() {
  6. $items['error-test/generate-warnings'] = array(
  7. 'title' => 'Generate warnings',
  8. 'page callback' => 'error_test_generate_warnings',
  9. 'access callback' => TRUE,
  10. 'type' => MENU_CALLBACK,
  11. );
  12. $items['error-test/generate-warnings-with-report'] = array(
  13. 'title' => 'Generate warnings with Simpletest reporting',
  14. 'page callback' => 'error_test_generate_warnings',
  15. 'page arguments' => array(TRUE),
  16. 'access callback' => TRUE,
  17. 'type' => MENU_CALLBACK,
  18. );
  19. $items['error-test/trigger-exception'] = array(
  20. 'title' => 'Trigger an exception',
  21. 'page callback' => 'error_test_trigger_exception',
  22. 'access callback' => TRUE,
  23. 'type' => MENU_CALLBACK,
  24. );
  25. $items['error-test/trigger-pdo-exception'] = array(
  26. 'title' => 'Trigger a PDO exception',
  27. 'page callback' => 'error_test_trigger_pdo_exception',
  28. 'access callback' => TRUE,
  29. 'type' => MENU_CALLBACK,
  30. );
  31. return $items;
  32. }
  33. /**
  34. * Menu callback; generate warnings to test the error handler.
  35. */
  36. function error_test_generate_warnings($collect_errors = FALSE) {
  37. // Tell Drupal error reporter to send errors to Simpletest or not.
  38. define('SIMPLETEST_COLLECT_ERRORS', $collect_errors);
  39. // This will generate a notice.
  40. $monkey_love = $bananas;
  41. // This will generate a warning.
  42. $awesomely_big = 1/0;
  43. // This will generate a user error.
  44. trigger_error("Drupal is awesome", E_USER_WARNING);
  45. return "";
  46. }
  47. /**
  48. * Menu callback; trigger an exception to test the exception handler.
  49. */
  50. function error_test_trigger_exception() {
  51. define('SIMPLETEST_COLLECT_ERRORS', FALSE);
  52. throw new Exception("Drupal is awesome");
  53. }
  54. /**
  55. * Menu callback; trigger an exception to test the exception handler.
  56. */
  57. function error_test_trigger_pdo_exception() {
  58. define('SIMPLETEST_COLLECT_ERRORS', FALSE);
  59. db_query('SELECT * FROM bananas_are_awesome');
  60. }