87 lines
1.9 KiB
PHP
87 lines
1.9 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 testCanInstanciateAnAxeptaOrder(): 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 testCannotInstanciateAnAxeptaOrderWithEmptyReference(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$reference = '';
|
|
$amount = 200;
|
|
$email = 'valid-email@example.org';
|
|
|
|
// WHEN
|
|
new AxeptaOrder(
|
|
$reference,
|
|
$amount,
|
|
$email,
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
|
|
public function testCannotInstanciateAnAxeptaOrderWithNonPositiveAmount(): 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 testCannotInstanciateAnAxeptaOrderWithInvalidEmail(): void
|
|
{
|
|
$this->assertThrows(function () {
|
|
// GIVEN
|
|
$reference = 'IRDtm95jvhCN';
|
|
$amount = 200;
|
|
$email = 'invalid-email';
|
|
|
|
// WHEN
|
|
new AxeptaOrder(
|
|
$reference,
|
|
$amount,
|
|
$email,
|
|
);
|
|
|
|
// THEN
|
|
}, DomainException::class);
|
|
}
|
|
}
|