30 lines
726 B
PHP
30 lines
726 B
PHP
<?php
|
|
|
|
namespace Tests\Service;
|
|
|
|
use App\Service\Crypt\AESCryptService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AESCryptServiceTest extends TestCase
|
|
{
|
|
private AESCryptService $service;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$secret = $_ENV['AES_SECRET_KEY'];
|
|
$cipher = $_ENV['AES_CIPHER_METHOD'];
|
|
|
|
$this->service = new AESCryptService($secret, $cipher);
|
|
}
|
|
|
|
public function testEncryptDecrypt(): void
|
|
{
|
|
$plaintext = 'Hello, world!';
|
|
$encrypted = $this->service->encrypt($plaintext);
|
|
$decrypted = $this->service->decrypt($encrypted);
|
|
|
|
$this->assertNotEquals($plaintext, $encrypted);
|
|
$this->assertEquals($plaintext, $decrypted);
|
|
}
|
|
}
|