33 lines
957 B
PHP
33 lines
957 B
PHP
<?php
|
|
|
|
namespace MintyPHP\Tests\Service\Settings;
|
|
|
|
use MintyPHP\Service\Settings\SettingsCryptoGateway;
|
|
use MintyPHP\Service\Settings\SettingsCryptoGatewayInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class SettingsCryptoGatewayTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
if (!defined('APP_CRYPTO_KEY')) {
|
|
define('APP_CRYPTO_KEY', str_repeat('ab', 32));
|
|
}
|
|
}
|
|
|
|
public function testImplementsSettingsCryptoGatewayInterface(): void
|
|
{
|
|
self::assertInstanceOf(SettingsCryptoGatewayInterface::class, new SettingsCryptoGateway());
|
|
}
|
|
|
|
public function testEncryptDecryptDelegatesToCrypto(): void
|
|
{
|
|
$gateway = new SettingsCryptoGateway();
|
|
$plaintext = 'settings-secret';
|
|
$encrypted = $gateway->encryptString($plaintext);
|
|
|
|
self::assertNotSame($plaintext, $encrypted);
|
|
self::assertSame($plaintext, $gateway->decryptString($encrypted));
|
|
}
|
|
}
|