TestRoleConfiguration.test in Configuration Management 7.2
File
tests/handlers/TestRoleConfiguration.test
View source
<?php
class TestRoleConfiguration extends ConfigurationHandlerBaseTestCase {
public function setUp($modules = array()) {
global $base_url;
if (empty($modules)) {
parent::setUp(array(
'configuration',
'role_export',
));
}
else {
parent::setUp($modules);
}
}
public static function getInfo() {
return array(
'name' => t('Handler: RoleConfiguration'),
'description' => t('Test the configuration API for role configurations'),
'group' => t('Configuration'),
);
}
protected function configToImport() {
return array(
'role.developer',
);
}
protected function configToExport() {
return array(
'role.my_custom_role',
);
}
protected function configToModify() {
return array(
'role.developer',
);
}
protected function isModified($config) {
$modified = FALSE;
foreach (role_export_roles() as $role) {
if ($role->machine_name == 'developer') {
$modified = $role->name == 'Modified';
break;
}
}
return $modified;
}
protected function savedInActiveStore() {
return 'developer' == role_export_role_name_exists('developer');
}
protected function createConfigToExport() {
$data = (object) array(
'name' => 'My Custom Role',
'weight' => '3',
);
user_role_save($data);
}
protected function modifyConfiguration() {
$role = user_role_load_by_name('Developer');
$role->name = 'Modified';
$role->machine_name = 'developer';
user_role_save($role);
}
}