Passed
Pull Request — master (#17)
by Stanislav
10:22
created

FirstDataFacadeCaptureTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 29
dl 0
loc 50
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExecuteCaptureOmsCommandMustUpdateStatusAfterSuccessRequest() 0 36 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEcoTest\Zed\FirstData\Business;
9
10
use Generated\Shared\Transfer\FirstDataOmsCommandRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...sCommandRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\TotalsTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\TotalsTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use SprykerEcoTest\Zed\FirstData\FirstDataBusinessTester;
14
15
/**
16
 * Auto-generated group annotations
17
 *
18
 * @group SprykerEcoTest
19
 * @group Zed
20
 * @group FirstData
21
 * @group Business
22
 * @group Facade
23
 * @group FirstDataFacadeCaptureTest
24
 */
25
class FirstDataFacadeCaptureTest extends AbstractFirstDataFacadeTest
26
{
27
    public const TRANSACTION_TYPE = 'POSTAUTH';
28
    protected const TEST_APPROVED_STATUS = 'TEST_APPROVED_STATUS';
29
    protected const OMS_STATUS_CAPTURED = 'captured';
30
31
    /**
32
     * @var \SprykerEcoTest\Zed\FirstData\FirstDataBusinessTester
33
     */
34
    protected $tester;
35
36
    /**
37
     * @return void
38
     */
39
    public function testExecuteCaptureOmsCommandMustUpdateStatusAfterSuccessRequest(): void
40
    {
41
        //Arrange
42
        $salesOrderEntity = $this->tester->createTestSalesOrderEntity();
43
        $salesOrderItemEntity = $this->tester->createTestSalesOrderItemEntity($salesOrderEntity);
44
        $paymentFirstDataEntity = $this->tester->createTestPaymentFirstDataEntity($salesOrderEntity);
45
        $paymentFirstDataItemEntity = $this->tester->createTestPaymentFirstDataItemEntity(
46
            $paymentFirstDataEntity,
47
            $salesOrderItemEntity,
48
            static::TEST_APPROVED_STATUS
49
        );
50
51
        $clientResponse = $this->tester->getClientResponse();
52
        $clientResponse['orderId'] = $salesOrderEntity->getIdSalesOrder();
53
        $clientResponse['transactionType'] = static::TRANSACTION_TYPE;
54
        $clientResponse['ipgTransactionId'] = FirstDataBusinessTester::ID_TRANSACTION;
55
        $totals = (new TotalsTransfer())->setGrandTotal($clientResponse['approvedAmount']['total']);
56
57
        $orderTransfer = (new OrderTransfer())
58
            ->fromArray($salesOrderEntity->toArray(), true)
59
            ->setTotals($totals);
60
61
        $firstDataOmsCommandRequestTransfer = (new FirstDataOmsCommandRequestTransfer())
62
            ->setSalesOrderItemIds([$salesOrderItemEntity->getIdSalesOrderItem()])
63
            ->setOrder($orderTransfer);
64
65
        //Act
66
        $this->tester
67
            ->getFirstDataFacade($this->getFirstDataBusinessFactoryMock($clientResponse))
68
            ->executeCaptureOmsCommand($firstDataOmsCommandRequestTransfer);
69
70
        $paymentFirstDataItemEntityAfterRefund = $this->tester
71
            ->findTestPaymentFirstDataItemEntityById($paymentFirstDataItemEntity->getIdPaymentFirstDataItem());
72
73
        //Assert
74
        $this->assertSame(static::OMS_STATUS_CAPTURED, $paymentFirstDataItemEntityAfterRefund->getStatus());
75
    }
76
}
77