Skip to content

Commit

Permalink
Merge pull request #236 from mewebstudio/working-on-test-coverage
Browse files Browse the repository at this point in the history
Working on test coverage
  • Loading branch information
nuryagdym authored Oct 2, 2024
2 parents edec873 + 9a3f831 commit e9a15fa
Show file tree
Hide file tree
Showing 26 changed files with 261 additions and 318 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ indent_size = 4
ij_php_align_assignments = true
ij_php_align_class_constants = true
ij_php_align_key_value_pairs = true
ij_php_align_phpdoc_param_names = true
ij_php_align_phpdoc_comments = true
ij_php_space_after_type_cast = true
ij_php_concat_spaces = false
ij_php_phpdoc_param_spaces_between_tag_and_type = 1

[*.md]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $
$requestData['report'] = [
'batchNumber' => $order['batch_num'],
];
} elseif (isset($order['start_date']) && isset($order['end_date'])) {
} elseif (isset($order['start_date'], $order['end_date'])) {
$requestData['report'] = [
'startDateTime' => $this->formatRequestDateTime($order['start_date']),
'endDateTime' => $this->formatRequestDateTime($order['end_date']),
Expand Down
5 changes: 4 additions & 1 deletion src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $po
'Total' => isset($order['amount']) ? (float) $this->formatAmount($order['amount']) : null,
];

if (isset($order['amount']) && isset($order['pre_auth_amount']) && $order['pre_auth_amount'] < $order['amount']) {
if (isset($order['amount'], $order['pre_auth_amount']) && $order['pre_auth_amount'] < $order['amount']) {
// when amount < pre_auth_amount then we need to send PREAMT value
$requestData['Extra']['PREAMT'] = $order['pre_auth_amount'];
}
Expand Down Expand Up @@ -271,9 +271,12 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
* @phpstan-param PosInterface::MODEL_3D_* $paymentModel
* @phpstan-param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType
*
* @param AbstractPosAccount $posAccount
* @param array<string, string|int|float|null> $order
* @param string $paymentModel
* @param string $txType
* @param string $gatewayURL
* @param CreditCardInterface|null $creditCard
*
* @return array{gateway: string, method: 'POST', inputs: array<string, string>}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ class PayFlexCPV4PosRequestDataMapper extends AbstractRequestDataMapper
PosInterface::LANG_EN => 'en-US',
];

/**
* {@inheritdoc}
*/
protected array $recurringOrderFrequencyMapping = [
'DAY' => 'Day',
'MONTH' => 'Month',
'YEAR' => 'Year',
];

/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
if ($creditCard instanceof CreditCardInterface) {
$inputs['CardHolderName'] = (string) $creditCard->getHolderName();
$inputs['CardNo'] = $creditCard->getNumber();
$inputs['ExpireDate'] = $creditCard->getExpireMonth(self::CREDIT_CARD_EXP_DATE_FORMAT);
$inputs['ExpireDate'] = $creditCard->getExpirationDate(self::CREDIT_CARD_EXP_DATE_FORMAT);
$inputs['Cvv'] = $creditCard->getCvv();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,13 @@ protected function prepareRefundOrder(array $order): array
*
* @inheritDoc
*/
protected function prepareHistoryOrder(array $order): array
protected function prepareHistoryOrder(array $data): array
{
return [
'start_date' => $order['start_date'],
'end_date' => $order['end_date'],
'page' => $order['page'] ?? 1,
'page_size' => $order['page_size'] ?? 10,
'start_date' => $data['start_date'],
'end_date' => $data['end_date'],
'page' => $data['page'] ?? 1,
'page_size' => $data['page_size'] ?? 10,
];
}

Expand Down
7 changes: 2 additions & 5 deletions src/Factory/RequestDataMapperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class RequestDataMapperFactory
/**
* @param class-string $gatewayClass
* @param EventDispatcherInterface $eventDispatcher
* @param array<PosInterface::CURRENCY_*, string> $currencies
* @param CryptInterface $crypt
* @param array<PosInterface::CURRENCY_*, string> $currencies
*
* @return RequestDataMapperInterface
*/
Expand All @@ -65,15 +65,12 @@ public static function createGatewayRequestMapper(string $gatewayClass, EventDis
PosNet::class => PosNetRequestDataMapper::class,
PosNetV1Pos::class => PosNetV1PosRequestDataMapper::class,
PayFlexCPV4Pos::class => PayFlexCPV4PosRequestDataMapper::class,
PayFlexV4Pos::class => PayFlexV4PosRequestDataMapper::class,
];
if (isset($classMappings[$gatewayClass])) {
return new $classMappings[$gatewayClass]($eventDispatcher, $crypt, $currencies);
}

if (PayFlexV4Pos::class === $gatewayClass) {
return new PayFlexV4PosRequestDataMapper($eventDispatcher, $crypt, $currencies);
}

throw new DomainException('unsupported gateway');
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/EstPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testCreate3DHash(): void
$expected = 'S7UxUAohxaxzl35WxHyDfuQx0sg=';

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand All @@ -73,7 +73,7 @@ public function testCreate3DHashFor3DPay(): void
$expected = 'S7UxUAohxaxzl35WxHyDfuQx0sg=';

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/EstV3PosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testCreate3DHashFor3DPay(): void
];

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function testCreate3DHashFor3DSecure(): void
Expand All @@ -95,7 +95,7 @@ public function testCreate3DHashFor3DSecure(): void

$expected = '4aUsG5hqlIFLc9s8PKc5rWb2OLhmxDDewNgKa2XrwoYCIxlyVq8Fjl4IVaZzoqL983CfTseicmnTA0PjZr74xg==';
$actual = $this->crypt->create3DHash($this->account, $inputs);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function threeDHashCheckDataProvider(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Crypt/GarantiPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testCreate3DHash(): void
public function testCreateHash(array $requestData, string $expected): void
{
$actual = $this->crypt->createHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function threeDHashCheckDataProvider(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Crypt/PosNetV1PosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testHashFromParamsWhenNotFound(): void
public function testCreateHash(array $requestData, string $expected): void
{
$actual = $this->crypt->createHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}


Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/ToslaPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testCreate3DHash(): void
$expected = 'BwZ05tt0aNgIgtrrqmlTwSIaeetpQyyGLH6xTsQbHae7ANCIVKmLHPxYWk5XP3Li5fr4La1bZS9/43OihP0dig==';

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function testCreateHash(): void
Expand All @@ -57,7 +57,7 @@ public function testCreateHash(): void
$expected = 'BwZ05tt0aNgIgtrrqmlTwSIaeetpQyyGLH6xTsQbHae7ANCIVKmLHPxYWk5XP3Li5fr4La1bZS9/43OihP0dig==';

$actual = $this->crypt->createHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down
Loading

0 comments on commit e9a15fa

Please sign in to comment.