forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncrypterTest.php
More file actions
executable file
·42 lines (33 loc) · 1.14 KB
/
EncrypterTest.php
File metadata and controls
executable file
·42 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use Illuminate\Encryption\Encrypter;
class EncrypterTest extends PHPUnit_Framework_TestCase {
public function testEncryption()
{
$e = $this->getEncrypter();
$this->assertFalse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' == $e->encrypt('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
$encrypted = $e->encrypt('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
$this->assertTrue('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' == $e->decrypt($encrypted));
}
public function testEncryptionWithCustomCipher()
{
$e = $this->getEncrypter();
$e->setCipher(MCRYPT_RIJNDAEL_256);
$this->assertFalse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' == $e->encrypt('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
$encrypted = $e->encrypt('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
$this->assertTrue('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' == $e->decrypt($encrypted));
}
/**
* @expectedException Illuminate\Encryption\DecryptException
*/
public function testExceptionThrownWhenPayloadIsInvalid()
{
$e = $this->getEncrypter();
$payload = $e->encrypt('foo');
$payload = str_shuffle($payload);
$e->decrypt($payload);
}
protected function getEncrypter()
{
return new Encrypter(str_repeat('a', 32));
}
}