Skip to content

Commit

Permalink
add test for Encrypter (laravel#51089)
Browse files Browse the repository at this point in the history
  • Loading branch information
saMahmoudzadeh authored Apr 16, 2024
1 parent b90eebc commit ed718c7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/Encryption/EncrypterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,24 @@

class EncrypterTest extends TestCase
{
public function testEncryption()
public function testEncryption(): void
{
$e = new Encrypter(str_repeat('a', 16));
$encrypted = $e->encrypt('foo');
$this->assertNotSame('foo', $encrypted);
$this->assertSame('foo', $e->decrypt($encrypted));

$encrypted = $e->encrypt('');
$this->assertSame('', $e->decrypt($encrypted));

$longString = str_repeat('a', 1000);
$encrypted = $e->encrypt($longString);
$this->assertSame($longString, $e->decrypt($encrypted));

$data = ['foo' => 'bar', 'baz' => 'qux'];
$encryptedArray = $e->encrypt($data);
$this->assertNotSame($data, $encryptedArray);
$this->assertSame($data, $e->decrypt($encryptedArray));
}

public function testRawStringEncryption()
Expand Down

0 comments on commit ed718c7

Please sign in to comment.