Skip to content

Commit

Permalink
Fixed Unit Test AddPaymentCommandTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Aug 2, 2022
1 parent d5c59c7 commit 2a6f89c
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -37,14 +37,14 @@ public function testAmountIsNegative(): void
{
$this->expectException(NegativePaymentAmountException::class);
$this->expectExceptionMessage('The amount should be greater than 0.');
new AddPaymentCommand(1, date('Y-m-d'), 'Check', '-1', 2);
new AddPaymentCommand(1, date('Y-m-d'), 'Check', '-1', 2, 3);
}

public function testPaymentMethodIsEmpty(): void
{
$this->expectException(OrderConstraintException::class);
$this->expectExceptionMessage('The selected payment method is invalid.');
new AddPaymentCommand(1, date('Y-m-d'), '', '0', 2);
new AddPaymentCommand(1, date('Y-m-d'), '', '0', 2, 3);
}

/**
Expand All @@ -56,7 +56,7 @@ public function testPaymentMethodWithInvalidCharacters(string $invalidChar): voi
{
$this->expectException(OrderConstraintException::class);
$this->expectExceptionMessage('The selected payment method is invalid.');
new AddPaymentCommand(1, date('Y-m-d'), $invalidChar . 'Check', '0', 2);
new AddPaymentCommand(1, date('Y-m-d'), $invalidChar . 'Check', '0', 2, 3);
}

public function getInvalidChars(): iterable
Expand All @@ -68,40 +68,43 @@ public function getInvalidChars(): iterable

public function testConstruct(): void
{
$instance = new AddPaymentCommand(1, date('Y-m-d'), 'Check', '0', 2);
$instance = new AddPaymentCommand(1, date('Y-m-d'), 'Check', '0', 2, 3);

$this->assertEquals(1, $instance->getOrderId()->getValue());
$this->assertEquals(date('Y-m-d'), $instance->getPaymentDate()->format('Y-m-d'));
$this->assertEquals('Check', $instance->getPaymentMethod());
$this->assertEquals('0', $instance->getPaymentAmount()->__toString());
$this->assertEquals(2, $instance->getPaymentCurrencyId()->getValue());
$this->assertEquals(3, $instance->getEmployeeId()->getValue());
$this->assertNull($instance->getOrderInvoiceId());
$this->assertNull($instance->getPaymentTransactionId());
}

public function testConstructWithOrderInvoiceId(): void
{
$instance = new AddPaymentCommand(1, date('Y-m-d'), 'Check', '0', 2, 3);
$instance = new AddPaymentCommand(1, date('Y-m-d'), 'Check', '0', 2, 3, 4);

$this->assertEquals(1, $instance->getOrderId()->getValue());
$this->assertEquals(date('Y-m-d'), $instance->getPaymentDate()->format('Y-m-d'));
$this->assertEquals('Check', $instance->getPaymentMethod());
$this->assertEquals('0', $instance->getPaymentAmount()->__toString());
$this->assertEquals(2, $instance->getPaymentCurrencyId()->getValue());
$this->assertEquals(3, $instance->getOrderInvoiceId());
$this->assertEquals(3, $instance->getEmployeeId()->getValue());
$this->assertEquals(4, $instance->getOrderInvoiceId());
$this->assertNull($instance->getPaymentTransactionId());
}

public function testConstructWithTransactionId(): void
{
$instance = new AddPaymentCommand(1, date('Y-m-d'), 'Check', '0', 2, 3, 'TransactionId');
$instance = new AddPaymentCommand(1, date('Y-m-d'), 'Check', '0', 2, 3, 4, 'TransactionId');

$this->assertEquals(1, $instance->getOrderId()->getValue());
$this->assertEquals(date('Y-m-d'), $instance->getPaymentDate()->format('Y-m-d'));
$this->assertEquals('Check', $instance->getPaymentMethod());
$this->assertEquals('0', $instance->getPaymentAmount()->__toString());
$this->assertEquals(2, $instance->getPaymentCurrencyId()->getValue());
$this->assertEquals(3, $instance->getOrderInvoiceId());
$this->assertEquals(3, $instance->getEmployeeId()->getValue());
$this->assertEquals(4, $instance->getOrderInvoiceId());
$this->assertEquals('TransactionId', $instance->getPaymentTransactionId());
}
}

0 comments on commit 2a6f89c

Please sign in to comment.