raven.test in Raven: Sentry Integration 7.3
Same filename and directory in other branches
Tests for Raven.module.
File
raven.testView source
<?php
/**
* @file
* Tests for Raven.module.
*/
/**
* Tests logging messages to the database.
*/
class RavenTestCase extends DrupalWebTestCase {
/**
* A user with some relevant administrative permissions.
*
* @var object
*/
protected $adminUser;
/**
* A user without any permissions.
*
* @var object
*/
protected $anyUser;
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Raven',
'description' => 'Tests for Raven Sentry module.',
'group' => 'Raven',
);
}
/**
* Enable modules and create users with specific permissions.
*/
public function setUp() {
$modules = array(
'libraries',
'xautoload',
'raven',
'raven_test',
);
if (file_exists(DRUPAL_ROOT . '/../vendor/autoload.php') || file_exists(DRUPAL_ROOT . '/vendor/autoload.php')) {
$modules[] = 'composer_autoloader';
}
parent::setUp($modules);
$this
->ensureAutoloader();
$this->adminUser = $this
->drupalCreateUser(array(
'administer site configuration',
'access administration pages',
'access site reports',
));
$this->anyUser = $this
->drupalCreateUser(array());
}
/**
* Ensures that the Composer autoloader is set up properly.
*/
protected function ensureAutoloader() {
// Test to see if one of the classes that the autoloader should know
// about has been defined.
if (!class_exists('Raven_Client')) {
// This most likely means that we are running on DrupalCI, so set
// up for that.
variable_set('composer_autoloader', DRUPAL_ROOT . '/vendor/autoload.php');
}
}
/**
* Tests Raven module functionality.
*/
public function testRaven() {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/reports/status');
$this
->drupalGet('admin/config/development/logging');
$edit['raven_enabled'] = TRUE;
$edit['raven_watchdog_levels[4]'] = 4;
$edit['raven_watchdog_levels[6]'] = 6;
$edit['raven_fatal_error_handler'] = TRUE;
$this
->drupalPost(NULL, $edit, 'Save configuration');
$this
->drupalLogout();
$this
->drupalLogin($this->anyUser);
$this
->assertNoText('Sentry PHP library cannot be loaded. Check status report for more details.');
$this
->assertIdentical($this
->drupalGetHeader('X-Logged'), 'Logged');
$this
->assertFalse($this
->drupalGetHeader('X-Not-Logged'));
$this
->assertIdentical(realpath($this
->drupalGetHeader('X-Watchdog-File')), realpath(drupal_get_filename('module', 'raven_test')));
$this
->assertIdentical(realpath($this
->drupalGetHeader('X-Watchdog-Exception-File')), realpath(drupal_get_filename('module', 'raven_test')));
$this
->assertIdentical($this
->drupalGetHeader('X-Watchdog-Exception-Function'), 'raven_test_throw_exception');
$cookies = drupal_json_decode($this
->drupalGetHeader('X-Watchdog-Cookies'));
$this
->assertIdentical($cookies['ravenCookie'], '********');
$memory_limit = mt_rand(8000000, 9999999);
$this
->assertEqual($memory_limit, $this
->drupalGet('', array(
'query' => array(
'memory_limit' => $memory_limit,
),
)));
}
}
Classes
Name | Description |
---|---|
RavenTestCase | Tests logging messages to the database. |