error_test.module in Drupal 7
File
modules/simpletest/tests/error_test.module
View source
<?php
function error_test_menu() {
$items['error-test/generate-warnings'] = array(
'title' => 'Generate warnings',
'page callback' => 'error_test_generate_warnings',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['error-test/generate-warnings-with-report'] = array(
'title' => 'Generate warnings with Simpletest reporting',
'page callback' => 'error_test_generate_warnings',
'page arguments' => array(
TRUE,
),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['error-test/trigger-exception'] = array(
'title' => 'Trigger an exception',
'page callback' => 'error_test_trigger_exception',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['error-test/trigger-pdo-exception'] = array(
'title' => 'Trigger a PDO exception',
'page callback' => 'error_test_trigger_pdo_exception',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function error_test_generate_warnings($collect_errors = FALSE) {
define('SIMPLETEST_COLLECT_ERRORS', $collect_errors);
$notice = new \stdClass();
$notice == 1 ? 1 : 0;
$a = '';
foreach ($a as $b) {
}
trigger_error("Drupal is awesome", E_USER_WARNING);
return "";
}
function error_test_trigger_exception() {
define('SIMPLETEST_COLLECT_ERRORS', FALSE);
throw new Exception("Drupal is awesome");
}
function error_test_trigger_pdo_exception() {
define('SIMPLETEST_COLLECT_ERRORS', FALSE);
db_query('SELECT * FROM bananas_are_awesome');
}