116 lines
2.6 KiB
PHP
116 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Lib\Axepta;
|
|
|
|
use App\Lib\Axepta\AxeptaConfig;
|
|
use DomainException;
|
|
use Tests\TestCase;
|
|
|
|
class AxeptaConfigTest extends TestCase
|
|
{
|
|
public function testCanInstanciateAnAxeptaConfig(): void
|
|
{
|
|
// GIVEN
|
|
$endpoint = 'https://api.axepta.com';
|
|
$merchantId = 'M_123456';
|
|
$apiKey = 'secret_key_123';
|
|
$hmac = 'hmac_value_456';
|
|
|
|
// WHEN
|
|
$config = new AxeptaConfig(
|
|
$endpoint,
|
|
$merchantId,
|
|
$apiKey,
|
|
$hmac
|
|
);
|
|
|
|
// THEN
|
|
$this->assertInstanceOf(AxeptaConfig::class, $config);
|
|
}
|
|
|
|
public function testCannotInstanciateWithEmptyEndpoint(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$endpoint = '';
|
|
$merchantId = 'M_123';
|
|
$apiKey = 'key';
|
|
$hmac = 'hmac';
|
|
|
|
// WHEN
|
|
new AxeptaConfig(
|
|
$endpoint,
|
|
$merchantId,
|
|
$apiKey,
|
|
$hmac
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
|
|
public function testCannotInstanciateWithEmptyMerchantId(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$endpoint = 'https://api.axepta.com';
|
|
$merchantId = '';
|
|
$apiKey = 'key';
|
|
$hmac = 'hmac';
|
|
|
|
// WHEN
|
|
new AxeptaConfig(
|
|
$endpoint,
|
|
$merchantId,
|
|
$apiKey,
|
|
$hmac
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
|
|
public function testCannotInstanciateWithEmptyApiKey(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$endpoint = 'https://api.axepta.com';
|
|
$merchantId = 'M_123';
|
|
$apiKey = '';
|
|
$hmac = 'hmac';
|
|
|
|
// WHEN
|
|
new AxeptaConfig(
|
|
$endpoint,
|
|
$merchantId,
|
|
$apiKey,
|
|
$hmac
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
|
|
public function testCannotInstanciateWithEmptyHmac(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$endpoint = 'https://api.axepta.com';
|
|
$merchantId = 'M_123';
|
|
$apiKey = 'key';
|
|
$hmac = '';
|
|
|
|
// WHEN
|
|
new AxeptaConfig(
|
|
$endpoint,
|
|
$merchantId,
|
|
$apiKey,
|
|
$hmac
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
}
|