You are here

function EncryptKeyHandling::testKeyFileCreation in Encrypt 7

Make sure that the encryption key file is successfully created and used.

This test will not pass if you are using a VirtualDocumentRoot due to https://issues.apache.org/bugzilla/show_bug.cgi?id=26052.

File

./encrypt.test, line 130
Tests for encrypt.module

Class

EncryptKeyHandling
Test key handling.

Code

function testKeyFileCreation() {

  // First create an admin user.
  $adminUser = $this
    ->drupalCreateUser(array(
    'administer encrypt',
  ));
  $this
    ->drupalLogin($adminUser);

  // So the tests don't balk at us.
  include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/install.inc';

  // Then, let's set our key path on the encrypt admin page.
  $key_path = $_SERVER['DOCUMENT_ROOT'] . '/' . variable_get('file_public_path', conf_path() . '/files');
  $values = array(
    'encrypt_default_method' => 'default',
    'encrypt_secure_key_path' => $key_path,
  );
  $this
    ->drupalPost('admin/config/system/encrypt', $values, 'Save configuration');

  // Check to see if the key file was created.
  $this
    ->assertTrue(file_exists($key_path . '/encrypt_key.key'), t('The key file was created.'));
}