class PMExpenseTestCase in Drupal PM (Project Management) 8
Same name and namespace in other branches
- 7.3 pmexpense/pmexpense.test \PMExpenseTestCase
- 7 pmexpense/pmexpense.test \PMExpenseTestCase
- 7.2 pmexpense/pmexpense.test \PMExpenseTestCase
Define a test case for PM Expense.
Hierarchy
- class \PMExpenseTestCase extends \DrupalWebTestCase
Expanded class hierarchy of PMExpenseTestCase
File
- pmexpense/
pmexpense.test, line 10 - Test definitions for PM Expense.
View source
class PMExpenseTestCase extends DrupalWebTestCase {
/**
* Defines metadata for test case.
*/
public static function getInfo() {
return array(
'name' => t('PM Expense Functionality'),
'description' => t('Test the functionality of the PM Expense module'),
'group' => 'Project Management',
);
}
/**
* Defines modules to be enabled for each test run.
*/
public function setUp() {
parent::setUp('pm', 'pmexpense');
}
/**
* Test of access controls on Expense lists.
*/
public function testpmExpenseAccess() {
// Create user with permission to access Expense list.
$user_access = $this
->drupalCreateUser(array(
'Project Management expense: access',
));
$this
->drupalLogin($user_access);
// Test access to the Expense list.
$this
->drupalGet('pm/expenses');
$this
->assertText('Expenses', t('Make sure the correct page has been displayed by checking that the title is "Expenses".'));
}
/**
* Tests creation of an Expense.
*/
public function testpmexpenseCreate() {
// Test access to the PM Expense list for anonymous users.
$this
->drupalGet('pm/expenses');
$this
->assertResponse(403, t('Make sure access is denied to Project Management Expense list for anonymous user'));
// Create user with no additional permissions, and login.
$user_basic = $this
->drupalCreateUser();
$this
->drupalLogin($user_basic);
// Test access to the PM Expense list for this basic user.
$this
->drupalGet('pm/expenses');
$this
->assertResponse(403, t('Make sure access is denied to Project Management Expense list for basic user'));
// Create user with permissions to add content.
$user_content = $this
->drupalCreateUser(array(
'create pmexpense content',
));
$this
->drupalLogin($user_content);
// Create an expense node.
$expense = array(
'title' => $this
->randomName(32),
);
$this
->drupalPost('node/add/pmexpense', $expense, t('Save'));
// Test that the expense node is created.
$this
->assertText(t('Expense @title has been created.', array(
'@title' => $expense['title'],
)));
}
/**
* Tests module uninstall path.
*/
public function testpmexpenseUninstall() {
$module = array(
'pmexpense',
);
module_disable($module);
$result = drupal_uninstall_modules($module);
$this
->AssertTrue($result, t('Module successfully uninstalled.'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PMExpenseTestCase:: |
public static | function | Defines metadata for test case. | |
PMExpenseTestCase:: |
public | function | Defines modules to be enabled for each test run. | |
PMExpenseTestCase:: |
public | function | Test of access controls on Expense lists. | |
PMExpenseTestCase:: |
public | function | Tests creation of an Expense. | |
PMExpenseTestCase:: |
public | function | Tests module uninstall path. |