protected function CommerceBaseTestCase::permissionBuilder in Commerce Core 7
Helper function to get different combinations of permission sets.
Parameters
$set: Can be a single string (from the following) or can be an array containing multiple values that should be merged: 'site admin': Admin permissions for Drupal core modules 'store admin': All commerce "administer X" permissions
1 call to CommerceBaseTestCase::permissionBuilder()
- CommerceBaseTestCase::createUserWithPermissionHelper in tests/
commerce_base.test - Wrapper to easily create users from arrays returned by permissionBuilder().
File
- tests/
commerce_base.test, line 109 - Defines abstract base test class for the Commerce module tests.
Class
- CommerceBaseTestCase
- Abstract class for Commerce testing. All Commerce tests should extend this class.
Code
protected function permissionBuilder($sets) {
if (is_string($sets)) {
$sets = array(
$sets,
);
}
$site_admin = array(
'administer content types',
'administer nodes',
'bypass node access',
'administer modules',
'administer site configuration',
'administer themes',
'administer actions',
'access administration pages',
'access site in maintenance mode',
'access site reports',
'block IP addresses',
'administer permissions',
'administer users',
'administer rules',
'administer fields',
);
$store_admin = array(
'access administration pages',
'administer checkout',
'access checkout',
'configure store',
'administer commerce_customer_profile entities',
'administer customer profile types',
'administer line items',
'administer line item types',
'administer commerce_order entities',
'configure order settings',
'view any commerce_order entity',
'create commerce_order entities',
'edit any commerce_order entity',
'administer commerce_product entities',
'administer product types',
'administer product pricing',
'administer payment methods',
'administer payments',
'administer taxes',
'administer rules',
'administer fields',
);
$store_customer = array(
'access content',
'access checkout',
'view own commerce_order entities',
);
$final_permissions = array();
foreach ($sets as $set) {
switch ($set) {
case 'site admin':
$final_permissions = array_unique(array_merge($final_permissions, $site_admin));
break;
case 'store admin':
$final_permissions = array_unique(array_merge($final_permissions, $store_admin));
break;
case 'store customer':
$final_permissions = array_unique(array_merge($final_permissions, $store_customer));
break;
}
}
return $final_permissions;
}