2026-06-23 16:27:23 +02:00
|
|
|
<?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
|
2026-06-23 16:27:23 +02:00
|
|
|
{
|
|
|
|
|
// GIVEN
|
2026-09-25 16:25:31 +02:00
|
|
|
$endpoint = 'https://api.axepta.com';
|
2026-06-23 16:27:23 +02:00
|
|
|
$merchantId = 'M_123456';
|
2026-09-25 16:25:31 +02:00
|
|
|
$apiKey = 'secret_key_123';
|
|
|
|
|
$hmac = 'hmac_value_456';
|
2026-06-23 16:27:23 +02:00
|
|
|
|
|
|
|
|
// 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
|
2026-06-23 16:27:23 +02:00
|
|
|
{
|
|
|
|
|
$this->assertThrows(function () {
|
|
|
|
|
// GIVEN
|
2026-09-25 16:25:31 +02:00
|
|
|
$endpoint = '';
|
2026-06-23 16:27:23 +02:00
|
|
|
$merchantId = 'M_123';
|
2026-09-25 16:25:31 +02:00
|
|
|
$apiKey = 'key';
|
|
|
|
|
$hmac = 'hmac';
|
2026-06-23 16:27:23 +02:00
|
|
|
|
|
|
|
|
// 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
|
2026-06-23 16:27:23 +02:00
|
|
|
{
|
|
|
|
|
$this->assertThrows(function () {
|
|
|
|
|
// GIVEN
|
2026-09-25 16:25:31 +02:00
|
|
|
$endpoint = 'https://api.axepta.com';
|
2026-06-23 16:27:23 +02:00
|
|
|
$merchantId = '';
|
2026-09-25 16:25:31 +02:00
|
|
|
$apiKey = 'key';
|
|
|
|
|
$hmac = 'hmac';
|
2026-06-23 16:27:23 +02:00
|
|
|
|
|
|
|
|
// 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
|
2026-06-23 16:27:23 +02:00
|
|
|
{
|
|
|
|
|
$this->assertThrows(function () {
|
|
|
|
|
// GIVEN
|
2026-09-25 16:25:31 +02:00
|
|
|
$endpoint = 'https://api.axepta.com';
|
2026-06-23 16:27:23 +02:00
|
|
|
$merchantId = 'M_123';
|
2026-09-25 16:25:31 +02:00
|
|
|
$apiKey = '';
|
|
|
|
|
$hmac = 'hmac';
|
2026-06-23 16:27:23 +02:00
|
|
|
|
|
|
|
|
// 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
|
2026-06-23 16:27:23 +02:00
|
|
|
{
|
|
|
|
|
$this->assertThrows(function () {
|
|
|
|
|
// GIVEN
|
2026-09-25 16:25:31 +02:00
|
|
|
$endpoint = 'https://api.axepta.com';
|
2026-06-23 16:27:23 +02:00
|
|
|
$merchantId = 'M_123';
|
2026-09-25 16:25:31 +02:00
|
|
|
$apiKey = 'key';
|
|
|
|
|
$hmac = '';
|
2026-06-23 16:27:23 +02:00
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
new AxeptaConfig(
|
|
|
|
|
$endpoint,
|
|
|
|
|
$merchantId,
|
|
|
|
|
$apiKey,
|
|
|
|
|
$hmac
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
}, DomainException::class);
|
|
|
|
|
}
|
|
|
|
|
}
|