public function EncryptConfigTest::testConfigManage in Encrypt 7.2
Same name and namespace in other branches
- 7.3 encrypt.test \EncryptConfigTest::testConfigManage()
Test configuration management.
Ensure that a configuration can be added, loaded, edited, made the default, and deleted.
File
- ./
encrypt.test, line 274 - Tests for the project Encrypt.
Class
- EncryptConfigTest
- Test configurations.
Code
public function testConfigManage() {
// Create the test configuration.
$fields = array();
$fields['label'] = t('Test');
$fields['name'] = strtolower($fields['label']);
$fields['description'] = t('This is the original description.');
$fields['enabled'] = FALSE;
$fields['encrypt_encryption_method'] = 'mcrypt_aes_cbc';
$fields['encrypt_key_provider'] = 'drupal_variable';
$this
->drupalPost('admin/config/system/encrypt/add', $fields, t('Save configuration'));
$this
->assertText(t('The configuration @label has been added.', array(
'@label' => $fields['label'],
)));
// Load the test configuration.
$config = encrypt_get_config($fields['name'], TRUE);
$this
->assertTrue($config['label'] == $fields['label'], format_string('The configuration @label was loaded.', array(
'@label' => $fields['label'],
)));
// Edit the test configuration.
$edit_fields = $fields;
unset($edit_fields['name']);
$edit_fields['description'] = t('This is the edited description.');
$this
->drupalPost('admin/config/system/encrypt/edit/' . $fields['name'], $edit_fields, t('Save configuration'));
$this
->assertText(t('The configuration @label has been updated.', array(
'@label' => $fields['label'],
)));
// Make the test configuration the default.
$this
->drupalGet('admin/config/system/encrypt/default/' . $fields['name']);
$this
->assertText(t('The configuration @label has been made the default.', array(
'@label' => $fields['label'],
)));
$default_config = encrypt_get_default_config(TRUE);
$this
->assertTrue($default_config['name'] == $fields['name'], 'The test configuration is the default.');
$test_config = encrypt_get_config($fields['name'], TRUE);
$this
->assertTrue($test_config['enabled'], 'The test configuration is enabled.');
// Ensure that the default configuration cannot be deleted.
$this
->drupalGet('admin/config/system/encrypt/delete/' . $default_config['name']);
$this
->assertText(t('The default configuration cannot be deleted.'));
// Make the test configuration not the default, then delete it.
$this
->drupalGet('admin/config/system/encrypt/default/default');
$this
->drupalGet('admin/config/system/encrypt/delete/' . $fields['name']);
$this
->drupalPost(NULL, array(), t('Delete'));
$this
->assertText(t('The configuration @label has been deleted.', array(
'@label' => $fields['label'],
)));
}