87 lines
2 KiB
PHP
87 lines
2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Lib\Axepta;
|
|
|
|
use App\Lib\Axepta\Objects\AxeptaOrder;
|
|
use DomainException;
|
|
use Tests\TestCase;
|
|
|
|
class AxeptaOrderTest extends TestCase
|
|
{
|
|
public function test_can_instanciate_an_axepta_order(): void
|
|
{
|
|
// GIVEN
|
|
$reference = 'IRDtm95jvhCN';
|
|
$amount = 200;
|
|
$email = 'valid-email@example.org';
|
|
|
|
// WHEN
|
|
$order = new AxeptaOrder(
|
|
$reference,
|
|
$amount,
|
|
$email,
|
|
);
|
|
|
|
// THEN
|
|
$this->assertInstanceOf(AxeptaOrder::class, $order);
|
|
}
|
|
|
|
public function test_cannot_instanciate_an_axepta_order_with_empty_reference(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$reference = '';
|
|
$amount = 200;
|
|
$email = 'valid-email@example.org';
|
|
|
|
// WHEN
|
|
new AxeptaOrder(
|
|
$reference,
|
|
$amount,
|
|
$email,
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
|
|
public function test_cannot_instanciate_an_axepta_order_with_non_positive_amount(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$reference = 'IRDtm95jvhCN';
|
|
$amount = 0;
|
|
$email = 'valid-email@example.org';
|
|
|
|
// WHEN
|
|
new AxeptaOrder(
|
|
$reference,
|
|
$amount,
|
|
$email,
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
|
|
public function test_cannot_instanciate_an_axepta_order_with_invalid_email(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$reference = 'IRDtm95jvhCN';
|
|
$amount = 200;
|
|
$email = 'invalid-email';
|
|
|
|
// WHEN
|
|
new AxeptaOrder(
|
|
$reference,
|
|
$amount,
|
|
$email,
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
}
|