regcode.test in Registration codes 7.2
Tests suite for the Registration codes module.
File
tests/regcode.testView source
<?php
/**
* @file
* Tests suite for the Registration codes module.
*/
/**
* Tests operations of the regcode module.
*/
class RegcodeTestCase extends DrupalWebTestCase {
/**
* Admin user.
*
* @var object
*/
protected $adminUser;
/**
* Authenticated but unprivileged user.
*
* @var object
*/
protected $unprivUser;
/**
* Implements DrupalWebTestCase::getInfo().
*/
public static function getInfo() {
return array(
'name' => 'Regcode settings',
'description' => 'Tests operation of the Regcode settings page.',
'group' => 'Registration codes',
);
}
/**
* Overrides DrupalWebTestCase::setUp().
*/
protected function setUp() {
parent::setUp('regcode');
// Create our test users.
$this->adminUser = $this
->drupalCreateUser(array(
'administer site configuration',
'access administration pages',
'administer registration codes',
));
$this->unprivUser = $this
->drupalCreateUser();
}
/**
* Tests module permissions / access to configuration page.
*/
public function testUserAccess() {
// Test as anonymous user.
$this
->drupalGet('admin/config/people/regcode/settings');
$this
->assertResponse(403);
$this
->assertText(t('Access denied'));
$this
->assertText(t('You are not authorized to access this page.'));
// Test as authenticated but unprivileged user.
$this
->drupalLogin($this->unprivUser);
$this
->drupalGet('admin/config/people/regcode/settings');
$this
->assertResponse(403);
$this
->drupalLogout();
// As admin user.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/people/regcode/settings');
$this
->assertResponse(200);
$this
->assertText(t('Configure the registration code module.'));
$this
->drupalLogout();
}
}
Classes
Name | Description |
---|---|
RegcodeTestCase | Tests operations of the regcode module. |