diff --git a/rector.php b/rector.php index 2d0901f8..69367546 100644 --- a/rector.php +++ b/rector.php @@ -20,19 +20,17 @@ LevelSetList::UP_TO_PHP_74, ]) ->withSkip([ - \Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class, \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, \Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, \Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class, - \Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class, \Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class, + \Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class, \Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class, \Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class, \Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class, \Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector::class, - \Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector::class, \Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector::class, ]) ->withPreparedSets( diff --git a/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php index 236e81d3..feaeb4a7 100644 --- a/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php @@ -228,9 +228,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $requestData += $this->getRequestAccountData($posAccount); - - return $requestData; + return $requestData + $this->getRequestAccountData($posAccount); } /** diff --git a/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php index 7a323570..58a7ecfa 100644 --- a/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php @@ -216,9 +216,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $requestData += $this->getRequestAccountData($posAccount); - - return $requestData; + return $requestData + $this->getRequestAccountData($posAccount); } /** diff --git a/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php index 1c6045b4..4dfbf8b6 100644 --- a/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php @@ -217,9 +217,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $requestData += $this->getRequestAccountData($posAccount); - - return $requestData; + return $requestData + $this->getRequestAccountData($posAccount); } /** diff --git a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php index 0a8a7a35..04c5d053 100644 --- a/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php @@ -217,9 +217,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $requestData += $this->getRequestAccountData($posAccount); - - return $requestData; + return $requestData + $this->getRequestAccountData($posAccount); } /** diff --git a/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php index 79f021ac..a5f02756 100644 --- a/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php @@ -189,11 +189,9 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $ */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $requestData += $this->getRequestAccountData($posAccount) + [ + return $requestData + ($this->getRequestAccountData($posAccount) + [ 'MbrId' => self::MBR_ID, - ]; - - return $requestData; + ]); } /** diff --git a/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php index db40b297..b143ea88 100644 --- a/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php @@ -316,12 +316,10 @@ public function create3DResolveMerchantRequestData(AbstractPosAccount $posAccoun */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $requestData += [ + return $requestData + [ 'mid' => $posAccount->getClientId(), 'tid' => $posAccount->getTerminalId(), ]; - - return $requestData; } /** diff --git a/src/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapper.php index 631d4e65..eaebf462 100644 --- a/src/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapper.php @@ -271,7 +271,7 @@ public function mapOrderHistoryResponse(array $rawResponseData): array } if (!$isRecurringOrder) { - \usort($transactions, static function (array $tx1, array $tx2) { + \usort($transactions, static function (array $tx1, array $tx2): int { if (null !== $tx1['transaction_time'] && null === $tx2['transaction_time']) { return 1; } diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index e686b9b9..7ee83353 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -562,7 +562,7 @@ public function customQuery(array $requestData, string $apiUrl = null): PosInter } $data = $this->serializer->encode($updatedRequestData, $txType); - $apiUrl = $apiUrl ?? $this->getQueryAPIUrl($txType); + $apiUrl ??= $this->getQueryAPIUrl($txType); $this->response = $this->send( $data, $txType, @@ -669,7 +669,8 @@ protected function check3DFormInputs(string $paymentModel, string $txType, Credi throw new \LogicException('Bu banka altyapısı sağlanan ödeme modelini ya da işlem tipini desteklenmiyor.'); } - if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel) && null === $card) { + if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel) + && !$card instanceof \Mews\Pos\Entity\Card\CreditCardInterface) { throw new \InvalidArgumentException('Bu ödeme modeli için kart bilgileri zorunlu!'); } } diff --git a/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php index be0153f8..8eacf1aa 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php @@ -34,8 +34,6 @@ class PayForPosRequestDataMapperTest extends TestCase /** @var CryptInterface & MockObject */ private CryptInterface $crypt; - private array $order; - /** @var EventDispatcherInterface & MockObject */ private EventDispatcherInterface $dispatcher; private PayForPosRequestValueFormatter $valueFormatter; @@ -54,16 +52,6 @@ protected function setUp(): void '12345678' ); - $this->order = [ - 'id' => '2020110828BC', - 'amount' => 100.01, - 'installment' => '0', - 'currency' => PosInterface::CURRENCY_TRY, - 'success_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php', - 'lang' => PosInterface::LANG_TR, - ]; - $this->crypt = $this->createMock(CryptInterface::class); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); $this->valueFormatter = new PayForPosRequestValueFormatter(); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php index 596c87b9..c7fe9f26 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php @@ -136,6 +136,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php index 3d700bf8..f3c91f31 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php @@ -152,6 +152,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php index 5f1154b4..7aa7ef6e 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php @@ -153,6 +153,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php index 09f63d43..2abf62e7 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php @@ -95,6 +95,7 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + unset($actualData['all']); \ksort($expectedData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 0f205a5c..0a6635f9 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -318,6 +318,7 @@ function () use ($expectedData) { $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php index dd3fa517..7ddf8094 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php @@ -133,6 +133,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php index 3a5e7c8b..585bd121 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php @@ -152,6 +152,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php index cb7470f3..6cb1bc94 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php @@ -135,6 +135,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php index c6aaa1b0..f41dac71 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php @@ -146,6 +146,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php index c4045a81..518b013a 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php @@ -174,6 +174,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); diff --git a/tests/Unit/Gateways/AkbankPosTest.php b/tests/Unit/Gateways/AkbankPosTest.php index bdf4deff..5aded0cd 100644 --- a/tests/Unit/Gateways/AkbankPosTest.php +++ b/tests/Unit/Gateways/AkbankPosTest.php @@ -1036,7 +1036,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -1046,7 +1046,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/EstPosTest.php b/tests/Unit/Gateways/EstPosTest.php index 15f065ae..016b8d0b 100644 --- a/tests/Unit/Gateways/EstPosTest.php +++ b/tests/Unit/Gateways/EstPosTest.php @@ -880,7 +880,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -890,7 +890,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/GarantiPosTest.php b/tests/Unit/Gateways/GarantiPosTest.php index e0561fdb..51515745 100644 --- a/tests/Unit/Gateways/GarantiPosTest.php +++ b/tests/Unit/Gateways/GarantiPosTest.php @@ -802,7 +802,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -812,7 +812,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/InterPosTest.php b/tests/Unit/Gateways/InterPosTest.php index d3c1d45d..7ec8891c 100644 --- a/tests/Unit/Gateways/InterPosTest.php +++ b/tests/Unit/Gateways/InterPosTest.php @@ -742,7 +742,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -752,7 +752,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/KuveytPosTest.php b/tests/Unit/Gateways/KuveytPosTest.php index 83ff14d8..bf3cea93 100644 --- a/tests/Unit/Gateways/KuveytPosTest.php +++ b/tests/Unit/Gateways/KuveytPosTest.php @@ -308,7 +308,7 @@ public function testMake3DPayment( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($create3DPaymentRequestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($create3DPaymentRequestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -318,7 +318,7 @@ public function testMake3DPayment( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); @@ -665,7 +665,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -675,7 +675,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/PayFlexCPV4PosTest.php b/tests/Unit/Gateways/PayFlexCPV4PosTest.php index 7a56a492..107b118e 100644 --- a/tests/Unit/Gateways/PayFlexCPV4PosTest.php +++ b/tests/Unit/Gateways/PayFlexCPV4PosTest.php @@ -700,7 +700,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -710,7 +710,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/PayFlexV4PosTest.php b/tests/Unit/Gateways/PayFlexV4PosTest.php index dbf7760a..4800eec1 100644 --- a/tests/Unit/Gateways/PayFlexV4PosTest.php +++ b/tests/Unit/Gateways/PayFlexV4PosTest.php @@ -763,7 +763,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -773,7 +773,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/PayForTest.php b/tests/Unit/Gateways/PayForTest.php index ceb6ef44..599b5614 100644 --- a/tests/Unit/Gateways/PayForTest.php +++ b/tests/Unit/Gateways/PayForTest.php @@ -851,7 +851,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -860,7 +860,7 @@ private function configureClientResponse( && $order === $dispatchedEvent->getOrder() && $paymentModel === $dispatchedEvent->getPaymentModel(); }))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/PosNetTest.php b/tests/Unit/Gateways/PosNetTest.php index aecc61fe..cfe5938d 100644 --- a/tests/Unit/Gateways/PosNetTest.php +++ b/tests/Unit/Gateways/PosNetTest.php @@ -259,7 +259,7 @@ public function testMake3DPayment( $this->serializerMock->expects($matcher) ->method('encode') - ->with($this->callback(function ($requestData) use ($matcher, &$updatedRequestDataPreparedEvent1, &$updatedRequestDataPreparedEvent2) { + ->with($this->callback(function ($requestData) use ($matcher, &$updatedRequestDataPreparedEvent1, &$updatedRequestDataPreparedEvent2): bool { if ($matcher->getInvocationCount() === 1) { return $updatedRequestDataPreparedEvent1->getRequestData() === $requestData; } @@ -269,13 +269,12 @@ public function testMake3DPayment( } return true; - }), $this->callback(function ($txT) use ($txType) { - return $txT === $txType; - })) - ->willReturnCallback(function () use ($matcher) { + }), $this->callback(fn($txT): bool => $txT === $txType)) + ->willReturnCallback(function () use ($matcher): ?string { if ($matcher->getInvocationCount() === 1) { return 'resolveMerchantRequestData-body'; } + if ($matcher->getInvocationCount() === 2) { return 'payment-request-body'; } @@ -340,7 +339,7 @@ public function testMake3DPayment( $matcher2, &$updatedRequestDataPreparedEvent1, &$updatedRequestDataPreparedEvent2 - ) { + ): bool { if ($matcher2->getInvocationCount() === 1) { $updatedRequestDataPreparedEvent1 = $dispatchedEvent; @@ -371,6 +370,7 @@ public function testMake3DPayment( return $updatedRequestDataPreparedEvent1; } + if ($matcher2->getInvocationCount() === 2) { $updatedRequestData = $updatedRequestDataPreparedEvent2->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; @@ -873,7 +873,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -883,7 +883,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/PosNetV1PosTest.php b/tests/Unit/Gateways/PosNetV1PosTest.php index 9e036b8c..6cba861f 100644 --- a/tests/Unit/Gateways/PosNetV1PosTest.php +++ b/tests/Unit/Gateways/PosNetV1PosTest.php @@ -734,7 +734,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -744,7 +744,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/ToslaPosTest.php b/tests/Unit/Gateways/ToslaPosTest.php index 3346dc74..7b437245 100644 --- a/tests/Unit/Gateways/ToslaPosTest.php +++ b/tests/Unit/Gateways/ToslaPosTest.php @@ -1139,7 +1139,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -1149,7 +1149,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData); diff --git a/tests/Unit/Gateways/VakifKatilimTest.php b/tests/Unit/Gateways/VakifKatilimTest.php index bd5434a1..5983ff4a 100644 --- a/tests/Unit/Gateways/VakifKatilimTest.php +++ b/tests/Unit/Gateways/VakifKatilimTest.php @@ -979,7 +979,7 @@ private function configureClientResponse( ->method('dispatch') ->with($this->logicalAnd( $this->isInstanceOf(RequestDataPreparedEvent::class), - $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) { + $this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool { $updatedRequestDataPreparedEvent = $dispatchedEvent; return get_class($this->pos) === $dispatchedEvent->getGatewayClass() @@ -989,7 +989,7 @@ private function configureClientResponse( && $paymentModel === $dispatchedEvent->getPaymentModel(); } ))) - ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) { + ->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent { $updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData(); $updatedRequestData['test-update-request-data-with-event'] = true; $updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);