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