Files
breadcrumb-the-shire/tests/Service/Auth/AuthCryptoGatewayTest.php

35 lines
884 B
PHP
Raw Normal View History

<?php
namespace MintyPHP\Tests\Service\Auth;
use MintyPHP\Service\Auth\AuthCryptoGateway;
use PHPUnit\Framework\TestCase;
2026-03-19 19:36:17 +01:00
final class AuthCryptoGatewayTest extends TestCase
{
private AuthCryptoGateway $gateway;
protected function setUp(): void
{
if (!defined('APP_CRYPTO_KEY')) {
define('APP_CRYPTO_KEY', str_repeat('ab', 32));
}
$this->gateway = new AuthCryptoGateway();
}
public function testIsConfiguredReturnsTrueWhenKeyIsSet(): void
{
2026-03-19 19:36:17 +01:00
self::assertTrue($this->gateway->isConfigured());
}
2026-03-19 19:36:17 +01:00
public function testEncryptDecryptDelegatesToCrypto(): void
{
2026-03-19 19:36:17 +01:00
$plaintext = 'auth-secret';
$encrypted = $this->gateway->encryptString($plaintext);
2026-03-19 19:36:17 +01:00
self::assertNotSame($plaintext, $encrypted);
self::assertSame($plaintext, $this->gateway->decryptString($encrypted));
}
}