function LogsHttpRegisterEventTestCase::testRegisterEvent in Logs HTTP 7
Test registration of an event.
File
- tests/
LogsHttpRegisterEventTestCase.test, line 28 - Contains LogsHttpRegisterEventTestCase.
Class
- LogsHttpRegisterEventTestCase
- @file Contains LogsHttpRegisterEventTestCase.
Code
function testRegisterEvent() {
// Test severity.
watchdog('logs_http', 'Notice 1');
$events = logs_http_get_registered_events();
$this
->assertFalse($events, 'No notice events registered, as severity level was to high.');
// Set severity.
variable_set('logs_http_severity_level', WATCHDOG_NOTICE);
// Test single event.
drupal_static_reset('logs_http_events');
watchdog('logs_http', 'Notice 1');
$events = logs_http_get_registered_events();
$this
->assertEqual(count($events), 1, 'Notice events registered.');
// Test multiple events.
drupal_static_reset('logs_http_events');
// A duplcaited event
watchdog('logs_http', 'Notice 1');
watchdog('logs_http', 'Notice 1');
watchdog('logs_http', 'Notice 2');
$events = logs_http_get_registered_events();
$this
->assertEqual(count($events), 2, 'Multiple events registered');
// Get the elements (as they are keyed by an md5 hash).
$event1 = array_shift($events);
$event2 = array_shift($events);
$this
->assertEqual($event1['message'], 'Notice 1', 'Correct first event registered.');
$this
->assertEqual($event2['message'], 'Notice 2', 'Correct second event registered.');
}