'Encryption Method Checking', 'description' => 'Ensure that the Encrypt functionality is working correctly.', 'group' => 'Encrypt', ); } /** * Set Up */ public function setUp() { // Enable any modules required for the test parent::setUp('encrypt'); } /** * Test to check encryption methods */ public function testCheckEncryptionMethodsKeys() { $test_string = 'Test String'; $options = array(); // Get methods encrypt_initialize(); $methods = encrypt_get_methods('full'); // Get key names $key_names = array(NULL, ENCRYPT_DEFAULT_KEY, ENCRYPT_DEFAULT_KEY_FILE, ENCRYPT_DEFAULT_KEY_DB); // Go through methods and keys foreach ($key_names as $key_name) { foreach ($methods as $name => $method) { // Test that original string is the same as encrypting // then decrypting $processed = decrypt(encrypt($test_string, $options, $name, $key_name)); $this->assertEqual($test_string, $processed, t('Ensure encryption works for method: %method and key_name: %key', array('%method' => $method['title'], '%key' => $key_name))); } } } }