LogsHttpRegisterEventTestCase.test in Logs HTTP 7
Contains LogsHttpRegisterEventTestCase.
File
tests/LogsHttpRegisterEventTestCase.testView source
<?php
/**
* @file
* Contains LogsHttpRegisterEventTestCase.
*/
class LogsHttpRegisterEventTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Register event',
'description' => 'Test registration of an event.',
'group' => 'Logs HTTP',
);
}
function setUp() {
parent::setUp('logs_http');
// Add a dummy URL.
variable_set('logs_http_url', 'http://example.com');
}
/**
* Test registration of an event.
*/
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.');
}
}
Classes
Name | Description |
---|---|
LogsHttpRegisterEventTestCase | @file Contains LogsHttpRegisterEventTestCase. |