ldc-legaulois/tests/Unit/Lib/Axepta/AxeptaConfigTest.php

117 lines
2.7 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\Lib\Axepta;
use App\Lib\Axepta\AxeptaConfig;
use DomainException;
use Tests\TestCase;
class AxeptaConfigTest extends TestCase
{
2026-09-25 16:25:31 +02:00
public function test_can_instanciate_an_axepta_config(): void
{
// GIVEN
2026-09-25 16:25:31 +02:00
$endpoint = 'https://api.axepta.com';
$merchantId = 'M_123456';
2026-09-25 16:25:31 +02:00
$apiKey = 'secret_key_123';
$hmac = 'hmac_value_456';
// WHEN
$config = new AxeptaConfig(
$endpoint,
$merchantId,
$apiKey,
$hmac
);
// THEN
$this->assertInstanceOf(AxeptaConfig::class, $config);
}
2026-09-25 16:25:31 +02:00
public function test_cannot_instanciate_with_empty_endpoint(): void
{
$this->assertThrows(function () {
// GIVEN
2026-09-25 16:25:31 +02:00
$endpoint = '';
$merchantId = 'M_123';
2026-09-25 16:25:31 +02:00
$apiKey = 'key';
$hmac = 'hmac';
// WHEN
new AxeptaConfig(
$endpoint,
$merchantId,
$apiKey,
$hmac
);
// THEN
}, DomainException::class);
}
2026-09-25 16:25:31 +02:00
public function test_cannot_instanciate_with_empty_merchant_id(): void
{
$this->assertThrows(function () {
// GIVEN
2026-09-25 16:25:31 +02:00
$endpoint = 'https://api.axepta.com';
$merchantId = '';
2026-09-25 16:25:31 +02:00
$apiKey = 'key';
$hmac = 'hmac';
// WHEN
new AxeptaConfig(
$endpoint,
$merchantId,
$apiKey,
$hmac
);
// THEN
}, DomainException::class);
}
2026-09-25 16:25:31 +02:00
public function test_cannot_instanciate_with_empty_api_key(): void
{
$this->assertThrows(function () {
// GIVEN
2026-09-25 16:25:31 +02:00
$endpoint = 'https://api.axepta.com';
$merchantId = 'M_123';
2026-09-25 16:25:31 +02:00
$apiKey = '';
$hmac = 'hmac';
// WHEN
new AxeptaConfig(
$endpoint,
$merchantId,
$apiKey,
$hmac
);
// THEN
}, DomainException::class);
}
2026-09-25 16:25:31 +02:00
public function test_cannot_instanciate_with_empty_hmac(): void
{
$this->assertThrows(function () {
// GIVEN
2026-09-25 16:25:31 +02:00
$endpoint = 'https://api.axepta.com';
$merchantId = 'M_123';
2026-09-25 16:25:31 +02:00
$apiKey = 'key';
$hmac = '';
// WHEN
new AxeptaConfig(
$endpoint,
$merchantId,
$apiKey,
$hmac
);
// THEN
}, DomainException::class);
}
}