function EncryptEncryptDecryptTest::testBasicEncryptDecrypt in Encrypt 7
Same name and namespace in other branches
- 7.3 encrypt.test \EncryptEncryptDecryptTest::testBasicEncryptDecrypt()
Test encryption and decryption with the "Basic" method.
Pretty much the same as the "None" tests. See that method for more detailed comments.
File
- ./
encrypt.test, line 54 - Tests for encrypt.module
Class
- EncryptEncryptDecryptTest
- Test basic encryption and decryption.
Code
function testBasicEncryptDecrypt() {
$random = $this
->randomName(10);
$encrypted = encrypt($random, array(), 'default');
// Test that the original value does not equal the encrypted value (i.e. that the data is actually being encrypted).
$this
->assertTrue(strpos($encrypted, 'a:') === 0, t('Basic: The encrypted value is a serialized array.'));
$encryptedArray = unserialize($encrypted);
$this
->assertNotEqual($random, $encryptedArray['text'], t('Basic: A value, encrypted, does not equal itself.'));
$decrypted = decrypt($encrypted, array(), 'default');
$this
->assertEqual($random, $decrypted, t('Basic: A value, decrypted, equals itself.'));
}