function EncryptPortability::testDecryptingRandomValue in Encrypt 7.3
Same name and namespace in other branches
- 7.2 encrypt.test \EncryptPortability::testDecryptingRandomValue()
Test off-the-cuff decrypting of a value using decrypt() with some text and paramters.
File
- ./
encrypt.test, line 128 - Tests for encrypt.module
Class
- EncryptPortability
- Various tests that ensure our encrypted data is portable (i.e. encryptable/decryptable in different environments).
Code
function testDecryptingRandomValue() {
// Generate some text and encrypt it.
$text = $this
->randomName(10);
$encrypted = encrypt($text, array(), 'default', 'drupal_private_key');
$encrypted_array = unserialize($encrypted);
// First, just check to see that the value was actually encrypted.
$this
->assertNotEqual($text, $encrypted_array['text'], t('The value was actually encrypted.'));
// Attempt to decrypt it without using the encryption array.
$decrypted = decrypt($encrypted_array['text'], array(), 'default', 'drupal_private_key');
$this
->assertEqual($text, $decrypted, t('The value was successfully decrypted.'));
}