From 56599bd32c5d56ea4f2437b95cebc731a271153f Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Mon, 16 May 2022 10:44:44 +0200 Subject: [PATCH 1/3] feat: drop support of php 7, add language level features of php8, update guzzle6 to 7 --- .github/workflows/code_checks.yaml | 4 +- Api.php | 42 ++++++++----------- Constants.php | 42 +++++++++---------- Exception/SaferpayHttpException.php | 18 ++++---- Model/CardAlias.php | 2 +- SaferpayGatewayFactory.php | 2 +- Tests/Functional/AbstractSaferpayTest.php | 38 ++++++++--------- Tests/Functional/CardAliasTest.php | 4 +- .../Api/AssertInsertAliasActionTest.php | 4 +- .../Api/AssertPaymentPageActionTest.php | 4 +- ...thorizeReferencedTransactionActionTest.php | 4 +- .../Api/AuthorizeTransactionActionTest.php | 4 +- Tests/Unit/Action/Api/BaseApiActionTest.php | 17 +++----- .../Api/CaptureTransactionActionTest.php | 4 +- .../Unit/Action/Api/DeleteAliasActionTest.php | 4 +- .../Action/Api/InitPaymentPageActionTest.php | 4 +- .../Action/Api/InitTransactionActionTest.php | 4 +- .../Unit/Action/Api/InsertAliasActionTest.php | 4 +- .../Api/RefundTransactionActionTest.php | 4 +- Tests/Unit/Action/CancelActionTest.php | 2 - .../Unit/Action/ConvertPaymentActionTest.php | 3 +- .../Unit/Action/InsertCardAliasActionTest.php | 3 +- Tests/Unit/ApiTest.php | 37 +++++++--------- composer.json | 6 +-- 24 files changed, 121 insertions(+), 139 deletions(-) diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index dda570a..2d2e795 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['7.3', '7.4', '8.0', '8.1'] + php: ['8.0', '8.1'] fail-fast: false name: PHPUnit (PHP ${{ matrix.php }}) steps: @@ -59,7 +59,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.0 coverage: xdebug - name: Get Composer cache directory diff --git a/Api.php b/Api.php index 7a86cbd..7a1655b 100644 --- a/Api.php +++ b/Api.php @@ -10,32 +10,26 @@ class Api { - const SPEC_VERSION = '1.10'; - const PAYMENT_PAGE_INIT_PATH = '/Payment/v1/PaymentPage/Initialize'; - const PAYMENT_PAGE_ASSERT_PATH = '/Payment/v1/PaymentPage/Assert'; - const TRANSACTION_INIT_PATH = '/Payment/v1/Transaction/Initialize'; - const TRANSACTION_AUTHORIZE_PATH = '/Payment/v1/Transaction/Authorize'; - const TRANSACTION_AUTHORIZE_REFERENCED_PATH = '/Payment/v1/Transaction/AuthorizeReferenced'; - const TRANSACTION_CAPTURE_PATH = '/Payment/v1/Transaction/Capture'; - const TRANSACTION_REFUND_PATH = '/Payment/v1/Transaction/Refund'; - const ALIAS_INSERT_PATH = '/Payment/v1/Alias/Insert'; - const ALIAS_ASSERT_INSERT_PATH = '/Payment/v1/Alias/AssertInsert'; - const ALIAS_DELETE_PATH = '/Payment/v1/Alias/Delete'; - - /** - * @var HttpClientInterface - */ - protected $client; - - /** - * @var MessageFactory - */ - protected $messageFactory; + public const SPEC_VERSION = '1.10'; + public const PAYMENT_PAGE_INIT_PATH = '/Payment/v1/PaymentPage/Initialize'; + public const PAYMENT_PAGE_ASSERT_PATH = '/Payment/v1/PaymentPage/Assert'; + public const TRANSACTION_INIT_PATH = '/Payment/v1/Transaction/Initialize'; + public const TRANSACTION_AUTHORIZE_PATH = '/Payment/v1/Transaction/Authorize'; + public const TRANSACTION_AUTHORIZE_REFERENCED_PATH = '/Payment/v1/Transaction/AuthorizeReferenced'; + public const TRANSACTION_CAPTURE_PATH = '/Payment/v1/Transaction/Capture'; + public const TRANSACTION_REFUND_PATH = '/Payment/v1/Transaction/Refund'; + public const ALIAS_INSERT_PATH = '/Payment/v1/Alias/Insert'; + public const ALIAS_ASSERT_INSERT_PATH = '/Payment/v1/Alias/AssertInsert'; + public const ALIAS_DELETE_PATH = '/Payment/v1/Alias/Delete'; + + protected HttpClientInterface $client; + + protected MessageFactory $messageFactory; /** * @var array */ - protected $options = array( + protected array|ArrayObject $options = [ 'username' => null, 'password' => null, 'customerId' => null, @@ -43,7 +37,7 @@ class Api 'sandbox' => null, 'interface' => null, 'optionalParameters' => null, - ); + ]; public function __construct(array $options, HttpClientInterface $client, MessageFactory $messageFactory) { @@ -72,7 +66,7 @@ protected function doRequest(string $path, array $fields): array 'RequestHeader' => [ 'SpecVersion' => self::SPEC_VERSION, 'CustomerId' => $this->options['customerId'], - 'RequestId' => uniqid(), + 'RequestId' => uniqid('', true), 'RetryIndicator' => 0, ], ], $fields); diff --git a/Constants.php b/Constants.php index d3f9dec..244a154 100644 --- a/Constants.php +++ b/Constants.php @@ -4,31 +4,31 @@ interface Constants { - const INTERFACE_PAYMENT_PAGE = 'PAYMENT_PAGE'; - const INTERFACE_TRANSACTION = 'TRANSACTION'; + public const INTERFACE_PAYMENT_PAGE = 'PAYMENT_PAGE'; + public const INTERFACE_TRANSACTION = 'TRANSACTION'; - const STATUS_PENDING = 'PENDING'; - const STATUS_AUTHORIZED = 'AUTHORIZED'; - const STATUS_CAPTURED = 'CAPTURED'; - const STATUS_CANCELED = 'CANCELED'; - const STATUS_ABORTED = 'ABORTED'; - const STATUS_FAILED = 'FAILED'; + public const STATUS_PENDING = 'PENDING'; + public const STATUS_AUTHORIZED = 'AUTHORIZED'; + public const STATUS_CAPTURED = 'CAPTURED'; + public const STATUS_CANCELED = 'CANCELED'; + public const STATUS_ABORTED = 'ABORTED'; + public const STATUS_FAILED = 'FAILED'; - const TYPE_PURCHASE = 'PURCHASE'; - const TYPE_PAYMENT = 'PAYMENT'; - const TYPE_REFUND = 'REFUND'; + public const TYPE_PURCHASE = 'PURCHASE'; + public const TYPE_PAYMENT = 'PAYMENT'; + public const TYPE_REFUND = 'REFUND'; - const ALIAS_TYPE_CARD = 'CARD'; - const ALIAS_TYPE_BANK_ACCOUNT = 'BANK_ACCOUNT'; - const ALIAS_TYPE_POSTFINANCE = 'POSTFINANCE'; - const ALIAS_TYPE_TWINT = 'TWINT'; + public const ALIAS_TYPE_CARD = 'CARD'; + public const ALIAS_TYPE_BANK_ACCOUNT = 'BANK_ACCOUNT'; + public const ALIAS_TYPE_POSTFINANCE = 'POSTFINANCE'; + public const ALIAS_TYPE_TWINT = 'TWINT'; - const ALIAS_ID_GENERATOR_MANUAL = 'MANUAL'; - const ALIAS_ID_GENERATOR_RANDOM = 'RANDOM'; - const ALIAS_ID_GENERATOR_RANDOM_UNIQUE = 'RANDOM_UNIQUE'; + public const ALIAS_ID_GENERATOR_MANUAL = 'MANUAL'; + public const ALIAS_ID_GENERATOR_RANDOM = 'RANDOM'; + public const ALIAS_ID_GENERATOR_RANDOM_UNIQUE = 'RANDOM_UNIQUE'; - const LS_IF_ALLOWED_BY_SCHEME = 'IF_ALLOWED_BY_SCHEME'; - const LS_WITH_LIABILITY_SHIFT = 'WITH_LIABILITY_SHIFT'; + public const LS_IF_ALLOWED_BY_SCHEME = 'IF_ALLOWED_BY_SCHEME'; + public const LS_WITH_LIABILITY_SHIFT = 'WITH_LIABILITY_SHIFT'; - const ERROR_NAME_TRANSACTION_ALREADY_CAPTURED = 'TRANSACTION_ALREADY_CAPTURED'; + public const ERROR_NAME_TRANSACTION_ALREADY_CAPTURED = 'TRANSACTION_ALREADY_CAPTURED'; } diff --git a/Exception/SaferpayHttpException.php b/Exception/SaferpayHttpException.php index b0de336..250c9f0 100644 --- a/Exception/SaferpayHttpException.php +++ b/Exception/SaferpayHttpException.php @@ -9,18 +9,16 @@ final class SaferpayHttpException extends HttpException { // https://saferpay.github.io/jsonapi/index.html#errorhandling - const BEHAVIOR_ABORT = 'ABORT'; - const BEHAVIOR_RETRY = 'RETRY'; - const BEHAVIOR_RETRY_LATER = 'RETRY_LATER'; - const BEHAVIOR_OTHER_MEANS = 'OTHER_MEANS'; + public const BEHAVIOR_ABORT = 'ABORT'; + public const BEHAVIOR_RETRY = 'RETRY'; + public const BEHAVIOR_RETRY_LATER = 'RETRY_LATER'; + public const BEHAVIOR_OTHER_MEANS = 'OTHER_MEANS'; - /** @var array|null */ - protected $data; + protected ?array $data = null; + protected ?string $info = null; - /** @var string|null */ - protected $info; - - public static function factory(RequestInterface $request, ResponseInterface $response) { + public static function factory(RequestInterface $request, ResponseInterface $response): SaferpayHttpException + { /** @var SaferpayHttpException $e */ $e = parent::factory($request, $response); $contents = $response->getBody()->getContents(); diff --git a/Model/CardAlias.php b/Model/CardAlias.php index d5f1ae8..7e38d4e 100644 --- a/Model/CardAlias.php +++ b/Model/CardAlias.php @@ -9,7 +9,7 @@ class CardAlias extends CreditCard implements CardAliasInterface /** * @var array */ - protected $details; + protected array $details; public function __construct() diff --git a/SaferpayGatewayFactory.php b/SaferpayGatewayFactory.php index babca62..8ffca81 100644 --- a/SaferpayGatewayFactory.php +++ b/SaferpayGatewayFactory.php @@ -71,7 +71,7 @@ protected function populateConfig(ArrayObject $config): void $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['username', 'password', 'customerId', 'terminalId']; - $config['payum.api'] = function (ArrayObject $config) { + $config['payum.api'] = static function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']); diff --git a/Tests/Functional/AbstractSaferpayTest.php b/Tests/Functional/AbstractSaferpayTest.php index 027f5f7..c3629d2 100644 --- a/Tests/Functional/AbstractSaferpayTest.php +++ b/Tests/Functional/AbstractSaferpayTest.php @@ -43,19 +43,19 @@ abstract class AbstractSaferpayTest extends TestCase protected const CARD_FAILED = '9030100152000009'; //'9010100152000003'; /** @var Payum */ - protected $payum; + protected Payum $payum; /** @var GatewayInterface */ - protected $gateway; + protected GatewayInterface $gateway; /** @var StorageInterface */ - protected $storage; + protected StorageInterface $storage; /** @var StorageInterface */ - protected $cardAliasStorage; + protected StorageInterface $cardAliasStorage; /** @var Client */ - protected $client; + protected Client $client; public function setUp(): void { @@ -155,7 +155,7 @@ protected function createPayment(array $details = []): Payment { /** @var Payment $payment */ $payment = $this->storage->create(); - $payment->setNumber(uniqid()); + $payment->setNumber(uniqid('', true)); $payment->setCurrencyCode(self::CURRENCY); $payment->setTotalAmount(self::AMOUNT); $payment->setDescription(self::DESCRIPTION); @@ -167,20 +167,20 @@ protected function createPayment(array $details = []): Payment protected function getThroughCheckout(string $url, array $formData, string $action = 'submit'): string { $this->client->request('GET', $url); - if (false !== strpos($url, '/vt2/api/PaymentPage')) { + if (str_contains($url, '/vt2/api/PaymentPage')) { $this->client->followRedirect(); $this->client->submitForm('MasterCard'); $this->client->followRedirect(); } if ( - false !== strpos($this->client->getCrawler()->getUri(), '/VT2/mpp/PaymentDataEntry/Index') - || false !== strpos($this->client->getCrawler()->getUri(), '/vt2/Api/Post') - || false !== strpos($this->client->getCrawler()->getUri(), '/vt2/api/register/card') + str_contains($this->client->getCrawler()->getUri(), '/VT2/mpp/PaymentDataEntry/Index') + || str_contains($this->client->getCrawler()->getUri(), '/vt2/Api/Post') + || str_contains($this->client->getCrawler()->getUri(), '/vt2/api/register/card') ) { if ($action === 'abort') { $location = $this->client->getCrawler()->filter('button.btn-abort')->attr('formaction'); - if (0 === strpos($location, self::HOST)) { + if (str_starts_with($location, self::HOST)) { return $location; } $this->clickButton('button.btn-abort'); @@ -191,22 +191,22 @@ protected function getThroughCheckout(string $url, array $formData, string $acti $response = $this->client->getResponse(); if ($response->getStatusCode() === 302) { $location = $response->getHeader('Location'); - if (0 === strpos($location, self::HOST)) { + if (str_starts_with($location, self::HOST)) { return $location; } $this->client->followRedirect(); } } - if (false !== strpos($this->client->getCrawler()->getUri(), '/VT2/mpp/PaymentDataEntry/Index')) { + if (str_contains($this->client->getCrawler()->getUri(), '/VT2/mpp/PaymentDataEntry/Index')) { self::assertSame(200, $this->client->getResponse()->getStatusCode()); $this->client->submitForm( $action === 'submit' ? 'Buy' : 'Cancel'); self::assertSame(302, $this->client->getResponse()->getStatusCode()); $this->client->followRedirect(); } if ( - false !== strpos($this->client->getCrawler()->getUri(), '/VT2/mpp/ThreeDS/Index') - || false !== strpos($this->client->getCrawler()->getUri(), '/VT2/api/ThreeDs') + str_contains($this->client->getCrawler()->getUri(), '/VT2/mpp/ThreeDS/Index') + || str_contains($this->client->getCrawler()->getUri(), '/VT2/api/ThreeDs') ) { self::assertSame(200, $this->client->getResponse()->getStatusCode()); $this->submitForm('[type="submit"]'); @@ -222,18 +222,18 @@ protected function getThroughCheckout(string $url, array $formData, string $acti $response = $this->client->getResponse(); self::assertSame(302, $response->getStatusCode()); $location = $response->getHeader('Location'); - if (0 === strpos($location, self::HOST)) { + if (str_starts_with($location, self::HOST)) { return $location; } $this->client->followRedirect(); } - if (false !== strpos($this->client->getCrawler()->getUri(), '/VT2/mpp/Error/System')) { + if (str_contains($this->client->getCrawler()->getUri(), '/VT2/mpp/Error/System')) { $this->client->submitForm('Cancel'); $response = $this->client->getResponse(); self::assertSame(302, $response->getStatusCode()); $location = $response->getHeader('Location'); - if (0 === strpos($location, self::HOST)) { + if (str_starts_with($location, self::HOST)) { return $location; } $this->client->followRedirect(); @@ -280,7 +280,7 @@ protected function createInsertedCardAlias(array $options): CardAliasInterface $reply = $this->insertCardAlias($token, $cardAlias); # submit form - $iframeRedirect = $this->getThroughCheckout($reply->getUrl(), $this->composeFormData(self::CARD_SUCCESS, $cvc = false)); + $iframeRedirect = $this->getThroughCheckout($reply->getUrl(), $this->composeFormData(self::CARD_SUCCESS, cvc: false)); parse_str(parse_url($iframeRedirect, PHP_URL_QUERY), $_GET); $this->insertCardAlias($token, $cardAlias); diff --git a/Tests/Functional/CardAliasTest.php b/Tests/Functional/CardAliasTest.php index 6b88bff..7f2f42a 100644 --- a/Tests/Functional/CardAliasTest.php +++ b/Tests/Functional/CardAliasTest.php @@ -30,10 +30,10 @@ public function insertAlias(): void #assert redirected self::assertInstanceOf(HttpRedirect::class, $reply); - self::assertStringStartsWith('https://test.saferpay.com/', $iframeUrl = $reply->getUrl()); + self::assertStringStartsWith('https://test.saferpay.com/', $reply->getUrl()); # submit form - $iframeRedirect = $this->getThroughCheckout($reply->getUrl(), $formData = $this->composeFormData(self::CARD_SUCCESS, $cvc = false)); + $iframeRedirect = $this->getThroughCheckout($reply->getUrl(), $formData = $this->composeFormData(self::CARD_SUCCESS, false)); self::assertStringStartsWith(self::HOST, $iframeRedirect); self::assertStringContainsString('payum_token='.$token->getHash(), $iframeRedirect); diff --git a/Tests/Unit/Action/Api/AssertInsertAliasActionTest.php b/Tests/Unit/Action/Api/AssertInsertAliasActionTest.php index 77d49f6..0b7a873 100644 --- a/Tests/Unit/Action/Api/AssertInsertAliasActionTest.php +++ b/Tests/Unit/Action/Api/AssertInsertAliasActionTest.php @@ -7,6 +7,6 @@ class AssertInsertAliasActionTest extends BaseApiActionTest { - protected $actionClass = AssertInsertAliasAction::class; - protected $requestClass = AssertInsertAlias::class; + protected string $actionClass = AssertInsertAliasAction::class; + protected string $requestClass = AssertInsertAlias::class; } diff --git a/Tests/Unit/Action/Api/AssertPaymentPageActionTest.php b/Tests/Unit/Action/Api/AssertPaymentPageActionTest.php index 808e1e0..a3e2869 100644 --- a/Tests/Unit/Action/Api/AssertPaymentPageActionTest.php +++ b/Tests/Unit/Action/Api/AssertPaymentPageActionTest.php @@ -7,6 +7,6 @@ class AssertPaymentPageActionTest extends BaseApiActionTest { - protected $actionClass = AssertPaymentPageAction::class; - protected $requestClass = AssertPaymentPage::class; + protected string $actionClass = AssertPaymentPageAction::class; + protected string $requestClass = AssertPaymentPage::class; } diff --git a/Tests/Unit/Action/Api/AuthorizeReferencedTransactionActionTest.php b/Tests/Unit/Action/Api/AuthorizeReferencedTransactionActionTest.php index e2359ed..e2024a7 100644 --- a/Tests/Unit/Action/Api/AuthorizeReferencedTransactionActionTest.php +++ b/Tests/Unit/Action/Api/AuthorizeReferencedTransactionActionTest.php @@ -9,8 +9,8 @@ class AuthorizeReferencedTransactionActionTest extends BaseApiActionTest { - protected $actionClass = AuthorizeReferencedTransactionAction::class; - protected $requestClass = AuthorizeReferencedTransaction::class; + protected string $actionClass = AuthorizeReferencedTransactionAction::class; + protected string $requestClass = AuthorizeReferencedTransaction::class; /** diff --git a/Tests/Unit/Action/Api/AuthorizeTransactionActionTest.php b/Tests/Unit/Action/Api/AuthorizeTransactionActionTest.php index f76656f..fc08732 100644 --- a/Tests/Unit/Action/Api/AuthorizeTransactionActionTest.php +++ b/Tests/Unit/Action/Api/AuthorizeTransactionActionTest.php @@ -9,8 +9,8 @@ class AuthorizeTransactionActionTest extends BaseApiActionTest { - protected $actionClass = AuthorizeTransactionAction::class; - protected $requestClass = AuthorizeTransaction::class; + protected string $actionClass = AuthorizeTransactionAction::class; + protected string $requestClass = AuthorizeTransaction::class; /** * @test diff --git a/Tests/Unit/Action/Api/BaseApiActionTest.php b/Tests/Unit/Action/Api/BaseApiActionTest.php index b8d2813..603c420 100644 --- a/Tests/Unit/Action/Api/BaseApiActionTest.php +++ b/Tests/Unit/Action/Api/BaseApiActionTest.php @@ -12,10 +12,10 @@ abstract class BaseApiActionTest extends TestCase { - protected $actionClass; - protected $requestClass; + protected string $actionClass; + protected string $requestClass; - protected $model = [ + protected array $model = [ 'Payment' => [ 'Amount' => [ 'Value' => 123, @@ -98,17 +98,12 @@ public function throwIfNotSupportedRequestGivenAsArgumentForExecute(): void $action->execute(new \stdClass()); } - /** - * @return MockObject|Api - */ - protected function createApiMock() + protected function createApiMock(): Api|MockObject { return $this->getMockBuilder(Api::class)->disableOriginalConstructor()->getMock(); } - /** - * @return MockObject|GatewayInterface - */ - protected function createGatewayMock() + + protected function createGatewayMock(): GatewayInterface|MockObject { return $this->createMock(GatewayInterface::class); } diff --git a/Tests/Unit/Action/Api/CaptureTransactionActionTest.php b/Tests/Unit/Action/Api/CaptureTransactionActionTest.php index 1918041..45b99fd 100644 --- a/Tests/Unit/Action/Api/CaptureTransactionActionTest.php +++ b/Tests/Unit/Action/Api/CaptureTransactionActionTest.php @@ -9,8 +9,8 @@ class CaptureTransactionActionTest extends BaseApiActionTest { - protected $actionClass = CaptureTransactionAction::class; - protected $requestClass = CaptureTransaction::class; + protected string $actionClass = CaptureTransactionAction::class; + protected string $requestClass = CaptureTransaction::class; /** * @test diff --git a/Tests/Unit/Action/Api/DeleteAliasActionTest.php b/Tests/Unit/Action/Api/DeleteAliasActionTest.php index 523a9d7..65cc149 100644 --- a/Tests/Unit/Action/Api/DeleteAliasActionTest.php +++ b/Tests/Unit/Action/Api/DeleteAliasActionTest.php @@ -7,6 +7,6 @@ class DeleteAliasActionTest extends BaseApiActionTest { - protected $actionClass = DeleteAliasAction::class; - protected $requestClass = DeleteAlias::class; + protected string $actionClass = DeleteAliasAction::class; + protected string $requestClass = DeleteAlias::class; } diff --git a/Tests/Unit/Action/Api/InitPaymentPageActionTest.php b/Tests/Unit/Action/Api/InitPaymentPageActionTest.php index 2026207..68ee2bd 100644 --- a/Tests/Unit/Action/Api/InitPaymentPageActionTest.php +++ b/Tests/Unit/Action/Api/InitPaymentPageActionTest.php @@ -7,6 +7,6 @@ class InitPaymentPageActionTest extends BaseApiActionTest { - protected $actionClass = InitPaymentPageAction::class; - protected $requestClass = InitPaymentPage::class; + protected string $actionClass = InitPaymentPageAction::class; + protected string $requestClass = InitPaymentPage::class; } diff --git a/Tests/Unit/Action/Api/InitTransactionActionTest.php b/Tests/Unit/Action/Api/InitTransactionActionTest.php index 6dd6ab7..3aed284 100644 --- a/Tests/Unit/Action/Api/InitTransactionActionTest.php +++ b/Tests/Unit/Action/Api/InitTransactionActionTest.php @@ -7,8 +7,8 @@ class InitTransactionActionTest extends BaseApiActionTest { - protected $actionClass = InitTransactionAction::class; - protected $requestClass = InitTransaction::class; + protected string $actionClass = InitTransactionAction::class; + protected string $requestClass = InitTransaction::class; /** * @test diff --git a/Tests/Unit/Action/Api/InsertAliasActionTest.php b/Tests/Unit/Action/Api/InsertAliasActionTest.php index b12f74e..1873eae 100644 --- a/Tests/Unit/Action/Api/InsertAliasActionTest.php +++ b/Tests/Unit/Action/Api/InsertAliasActionTest.php @@ -7,6 +7,6 @@ class InsertAliasActionTest extends BaseApiActionTest { - protected $actionClass = InsertAliasAction::class; - protected $requestClass = InsertAlias::class; + protected string $actionClass = InsertAliasAction::class; + protected string $requestClass = InsertAlias::class; } diff --git a/Tests/Unit/Action/Api/RefundTransactionActionTest.php b/Tests/Unit/Action/Api/RefundTransactionActionTest.php index 084c4b4..48f2809 100644 --- a/Tests/Unit/Action/Api/RefundTransactionActionTest.php +++ b/Tests/Unit/Action/Api/RefundTransactionActionTest.php @@ -7,7 +7,7 @@ class RefundTransactionActionTest extends BaseApiActionTest { - protected $actionClass = RefundTransactionAction::class; - protected $requestClass = RefundTransaction::class; + protected string $actionClass = RefundTransactionAction::class; + protected string $requestClass = RefundTransaction::class; } diff --git a/Tests/Unit/Action/CancelActionTest.php b/Tests/Unit/Action/CancelActionTest.php index c11bdb6..9049d31 100644 --- a/Tests/Unit/Action/CancelActionTest.php +++ b/Tests/Unit/Action/CancelActionTest.php @@ -4,7 +4,6 @@ use Karser\PayumSaferpay\Action\CancelAction; use Payum\Core\Action\ActionInterface; -use Payum\Core\GatewayAwareInterface; use Payum\Core\Request\Cancel; use Payum\Core\Tests\GenericActionTest; @@ -13,7 +12,6 @@ class CancelActionTest extends GenericActionTest protected $requestClass = Cancel::class; protected $actionClass = CancelAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/ConvertPaymentActionTest.php b/Tests/Unit/Action/ConvertPaymentActionTest.php index a986673..7cc8452 100644 --- a/Tests/Unit/Action/ConvertPaymentActionTest.php +++ b/Tests/Unit/Action/ConvertPaymentActionTest.php @@ -10,6 +10,7 @@ use Payum\Core\Request\Generic; use Payum\Core\Tests\GenericActionTest; use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; +use Payum\Core\Security\TokenInterface; class ConvertPaymentActionTest extends GenericActionTest { @@ -39,7 +40,7 @@ public function provideSupportedRequests(): \Iterator { yield [new $this->requestClass(new Payment(), 'array')]; yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'array')]; - yield [new $this->requestClass(new Payment(), 'array', $this->createMock('Payum\Core\Security\TokenInterface'))]; + yield [new $this->requestClass(new Payment(), 'array', $this->createMock(TokenInterface::class))]; } diff --git a/Tests/Unit/Action/InsertCardAliasActionTest.php b/Tests/Unit/Action/InsertCardAliasActionTest.php index 70b7e16..5d933b5 100644 --- a/Tests/Unit/Action/InsertCardAliasActionTest.php +++ b/Tests/Unit/Action/InsertCardAliasActionTest.php @@ -44,7 +44,8 @@ public function couldBeConstructedWithoutAnyArguments(): void public function provideSupportedRequests(): \Iterator { - function getRequest($details) { + function getRequest($details): InsertCardAlias + { $alias = new CardAlias(); $alias->setDetails($details); $request = new InsertCardAlias(new Token()); diff --git a/Tests/Unit/ApiTest.php b/Tests/Unit/ApiTest.php index 467eb7e..377ecd0 100644 --- a/Tests/Unit/ApiTest.php +++ b/Tests/Unit/ApiTest.php @@ -1,4 +1,5 @@ -options, $this->createSuccessHttpClientStub(), $this->createHttpMessageFactory()); $result = $api->initTransaction(['Payment' => [], 'ReturnUrls' => []]); - $this->assertArraySubset([ + self::assertArraySubset([ 'RequestHeader' => [ 'SpecVersion' => '1.10', 'CustomerId' => 'test', @@ -114,7 +115,7 @@ public function shouldComposeInitTransactionRequest(): void ] ]); - $this->assertArraySubset([ + self::assertArraySubset([ 'Payment' => [ 'Amount' => [ 'value' => 123, @@ -146,7 +147,7 @@ public function shouldComposeAuthorizeTransactionRequest(): void 'Alias' => ['Id' => 'aliasId'], ]); - $this->assertArraySubset([ + self::assertArraySubset([ 'Token' => 'this-is-token', 'Condition' => 'WITH_LIABILITY_SHIFT', 'RegisterAlias' => [ @@ -166,7 +167,7 @@ public function shouldComposeCaptureTransactionRequest(): void $api = new Api($this->options, $this->createSuccessHttpClientStub(), $this->createHttpMessageFactory()); $result = $api->captureTransaction('transaction-id'); - $this->assertArraySubset([ + self::assertArraySubset([ 'TransactionReference' => [ 'TransactionId' => 'transaction-id', ], @@ -186,7 +187,7 @@ public function shouldComposeRefundTransactionRequest(): void ], ], 'transaction-id'); - $this->assertArraySubset([ + self::assertArraySubset([ 'Refund' => [ 'Amount' => [ 'value' => 123, @@ -212,7 +213,7 @@ public function shouldComposeAuthorizeReferencedTransactionRequest(): void ], ], 'transaction-id'); - $this->assertArraySubset([ + self::assertArraySubset([ 'Payment' => [ 'Amount' => [ 'value' => 123, @@ -248,7 +249,7 @@ public function shouldComposeInitPaymentPageRequest(): void ] ]); - $this->assertArraySubset([ + self::assertArraySubset([ 'Payment' => [ 'Amount' => [ 'value' => 123, @@ -276,7 +277,7 @@ public function shouldComposeAssertPaymentPageRequest(): void $api = new Api($this->options, $this->createSuccessHttpClientStub(), $this->createHttpMessageFactory()); $result = $api->assertPaymentPage('token'); - $this->assertArraySubset([ + self::assertArraySubset([ 'Token' => 'token', ], $result); } @@ -294,7 +295,7 @@ public function shouldComposeInsertAliasRequest(): void 'IdGenerator' => 'RANDOM', ], 'CARD'); - $this->assertArraySubset([ + self::assertArraySubset([ 'RegisterAlias' => [ 'IdGenerator' => 'RANDOM', ], @@ -315,7 +316,7 @@ public function shouldComposeAssertInsertAliasRequest(): void $api = new Api($this->options, $this->createSuccessHttpClientStub(), $this->createHttpMessageFactory()); $result = $api->assertInsertAlias('token'); - $this->assertArraySubset([ + self::assertArraySubset([ 'Token' => 'token', ], $result); } @@ -328,7 +329,7 @@ public function shouldComposeDeleteAliasRequest(): void $api = new Api($this->options, $this->createSuccessHttpClientStub(), $this->createHttpMessageFactory()); $result = $api->deleteAlias('alias-id'); - $this->assertArraySubset([ + self::assertArraySubset([ 'AliasId' => 'alias-id', ], $result); } @@ -368,10 +369,7 @@ public function throwIfResponseStatusNotOk(): void } } - /** - * @return MockObject|HttpClientInterface - */ - protected function createSuccessHttpClientStub() + protected function createSuccessHttpClientStub(): MockObject|HttpClientInterface { $clientMock = $this->createHttpClientMock(); $clientMock @@ -383,10 +381,7 @@ protected function createSuccessHttpClientStub() return $clientMock; } - /** - * @return MockObject|HttpClientInterface - */ - protected function createHttpClientMock() + protected function createHttpClientMock(): MockObject|HttpClientInterface { return $this->getMockBuilder(HttpClientInterface::class)->getMock(); } diff --git a/composer.json b/composer.json index 455dfaf..b05584c 100644 --- a/composer.json +++ b/composer.json @@ -20,12 +20,12 @@ } ], "require": { - "php": "^7.3 || ^8.0", - "payum/core": "^1.6" + "php": "^8.0", + "payum/core": "^1.7" }, "require-dev": { "fabpot/goutte": "^4.0", - "php-http/guzzle6-adapter": "^2.0", + "php-http/guzzle7-adapter": "^1.0", "phpunit/phpunit": "^9.5", "dms/phpunit-arraysubset-asserts": "^0.4.0" }, From 882e418be4e06ce83b832e2f2d45d3651f0126d9 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 2 Sep 2022 10:17:18 +0200 Subject: [PATCH 2/3] feat: drop support of php 7, add language level features of php8, update guzzle6 to 7 --- Action/CaptureReferencedAction.php | 2 +- Action/InsertCardAliasAction.php | 2 +- Api.php | 17 ++++---- Model/CardAlias.php | 6 +-- README.md | 40 +++++++++---------- SaferpayGatewayFactory.php | 2 +- Tests/Functional/AbstractSaferpayTest.php | 19 --------- Tests/Unit/Action/AuthorizeActionTest.php | 1 - .../Action/CaptureReferencedActionTest.php | 1 - .../Unit/Action/ConvertPaymentActionTest.php | 1 - .../Unit/Action/InsertCardAliasActionTest.php | 1 - Tests/Unit/Action/NotifyActionTest.php | 1 - Tests/Unit/Action/RefundActionTest.php | 1 - Tests/Unit/Action/StatusActionTest.php | 1 - Tests/Unit/Action/SyncActionTest.php | 1 - Tests/Unit/ApiTest.php | 10 +++-- composer.json | 2 +- phpunit.xml.dist | 6 ++- 18 files changed, 45 insertions(+), 69 deletions(-) diff --git a/Action/CaptureReferencedAction.php b/Action/CaptureReferencedAction.php index 0c2f5ab..1b9ef42 100644 --- a/Action/CaptureReferencedAction.php +++ b/Action/CaptureReferencedAction.php @@ -27,7 +27,7 @@ public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); - /** @var $payment PaymentInterface */ + /** @var PaymentInterface $payment */ $payment = $request->getModel(); $this->gateway->execute($status = new GetHumanStatus($payment)); diff --git a/Action/InsertCardAliasAction.php b/Action/InsertCardAliasAction.php index 72b3a46..a8d2d5b 100644 --- a/Action/InsertCardAliasAction.php +++ b/Action/InsertCardAliasAction.php @@ -26,7 +26,7 @@ public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); - /** @var $cardAlias CardAliasInterface */ + /** @var CardAliasInterface $cardAlias */ $cardAlias = $request->getModel(); $details = ArrayObject::ensureArrayObject($cardAlias->getDetails()); diff --git a/Api.php b/Api.php index 7a1655b..82b4c01 100644 --- a/Api.php +++ b/Api.php @@ -26,9 +26,6 @@ class Api protected MessageFactory $messageFactory; - /** - * @var array - */ protected array|ArrayObject $options = [ 'username' => null, 'password' => null, @@ -41,20 +38,24 @@ class Api public function __construct(array $options, HttpClientInterface $client, MessageFactory $messageFactory) { - $options = ArrayObject::ensureArrayObject($options); - $options->defaults($this->options); - $options->validateNotEmpty([ + $optionsObj = ArrayObject::ensureArrayObject($options); + $optionsObj->defaults($this->options); + $optionsObj->validateNotEmpty([ 'username', 'password', 'customerId', 'terminalId', ]); if (!is_bool($options['sandbox'])) { throw new InvalidArgumentException('The boolean sandbox option must be set.'); } - $this->options = $options; + $this->options = $optionsObj; $this->client = $client; $this->messageFactory = $messageFactory; } + /** + * @param array $fields + * @return array + */ protected function doRequest(string $path, array $fields): array { $headers = [ @@ -89,7 +90,7 @@ protected function doRequest(string $path, array $fields): array ); } - private function parseResponse($content) + private function parseResponse(string $content): array { return json_decode($content, true); } diff --git a/Model/CardAlias.php b/Model/CardAlias.php index 7e38d4e..01c7fa2 100644 --- a/Model/CardAlias.php +++ b/Model/CardAlias.php @@ -6,12 +6,8 @@ class CardAlias extends CreditCard implements CardAliasInterface { - /** - * @var array - */ protected array $details; - public function __construct() { parent::__construct(); @@ -24,7 +20,7 @@ public function getDetails(): array } /** - * @param array $details + * @param array|\Traversable $details */ public function setDetails($details): void { diff --git a/README.md b/README.md index ad346ed..8d610b0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Here is how Transaction interface looks like: ## Requirements -- PHP 7.3+ +- PHP 8.0+ - [Payum](https://github.com/Payum/Payum) - Optionally [PayumBundle](https://github.com/Payum/PayumBundle) and Symfony 3 or 4+ @@ -343,27 +343,27 @@ payum: ``` #### Payment Page interface -| Key | Description | -| --------------------------------------| ------------| -| `config_set` | This parameter let you define your payment page config (PPConfig) by name. If this parameters is not set, your default PPConfig will be applied if available. When the PPConfig can't be found (e.g. wrong name), the Saferpay basic style will be applied to the payment page. | -| `payment_methods` | Used to restrict the means of payment which are available to the payer for this transaction. If only one payment method id is set, the payment selection step will be skipped. | -| `wallets` | Used to control if wallets should be enabled on the payment selection page and to go directly to the given wallet (if exactly one wallet is filled and PaymentMethods is not set). | -| `notification_merchant_email` | Email addresses to which a confirmation email will be sent to the merchants after successful authorizations. | -| `notification_payer_email` | Email address to which a confirmation email will be sent to the payer after successful authorizations. | -| `styling_css_url` | Deprecated | -| `styling_content_security_enabled` | When enabled, then ContentSecurity/SAQ-A is requested, which leads to the CSS being loaded from the saferpay server. | -| `styling_theme` | This parameter let you customize the appearance of the displayed payment pages. Per default a lightweight responsive styling will be applied.If you don't want any styling use 'NONE'. | -| `payer_note` | Text which will be printed on payer's debit note. Supported by SIX Acquiring. No guarantee that it will show up on the payer's debit note, because his bank has to support it too. Please note that maximum allowed characters are rarely supported. It's usually around 10-12. | +| Key | Description | +|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `config_set` | This parameter let you define your payment page config (PPConfig) by name. If this parameters is not set, your default PPConfig will be applied if available. When the PPConfig can't be found (e.g. wrong name), the Saferpay basic style will be applied to the payment page. | +| `payment_methods` | Used to restrict the means of payment which are available to the payer for this transaction. If only one payment method id is set, the payment selection step will be skipped. | +| `wallets` | Used to control if wallets should be enabled on the payment selection page and to go directly to the given wallet (if exactly one wallet is filled and PaymentMethods is not set). | +| `notification_merchant_email` | Email addresses to which a confirmation email will be sent to the merchants after successful authorizations. | +| `notification_payer_email` | Email address to which a confirmation email will be sent to the payer after successful authorizations. | +| `styling_css_url` | Deprecated | +| `styling_content_security_enabled` | When enabled, then ContentSecurity/SAQ-A is requested, which leads to the CSS being loaded from the saferpay server. | +| `styling_theme` | This parameter let you customize the appearance of the displayed payment pages. Per default a lightweight responsive styling will be applied.If you don't want any styling use 'NONE'. | +| `payer_note` | Text which will be printed on payer's debit note. Supported by SIX Acquiring. No guarantee that it will show up on the payer's debit note, because his bank has to support it too. Please note that maximum allowed characters are rarely supported. It's usually around 10-12. | #### Transaction interface -| Key | Description | -| --------------------------------------| ------------| -| `config_set` | This parameter let you define your payment page config (PPConfig) by name. If this parameters is not set, your default PPConfig will be applied if available. When the PPConfig can't be found (e.g. wrong name), the Saferpay basic style will be applied to the payment page. | -| `payment_methods` | Used to restrict the means of payment which are available to the payer for this transaction. If only one payment method id is set, the payment selection step will be skipped. | -| `styling_css_url` | Deprecated | -| `styling_content_security_enabled` | When enabled, then ContentSecurity/SAQ-A is requested, which leads to the CSS being loaded from the saferpay server. | -| `styling_theme` | This parameter let you customize the appearance of the displayed payment pages. Per default a lightweight responsive styling will be applied. If you don't want any styling use 'NONE'. | -| `payer_note` | Text which will be printed on payer's debit note. Supported by SIX Acquiring. No guarantee that it will show up on the payer's debit note, because his bank has to support it too. Please note that maximum allowed characters are rarely supported. It's usually around 10-12. | +| Key | Description | +|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `config_set` | This parameter let you define your payment page config (PPConfig) by name. If this parameters is not set, your default PPConfig will be applied if available. When the PPConfig can't be found (e.g. wrong name), the Saferpay basic style will be applied to the payment page. | +| `payment_methods` | Used to restrict the means of payment which are available to the payer for this transaction. If only one payment method id is set, the payment selection step will be skipped. | +| `styling_css_url` | Deprecated | +| `styling_content_security_enabled` | When enabled, then ContentSecurity/SAQ-A is requested, which leads to the CSS being loaded from the saferpay server. | +| `styling_theme` | This parameter let you customize the appearance of the displayed payment pages. Per default a lightweight responsive styling will be applied. If you don't want any styling use 'NONE'. | +| `payer_note` | Text which will be printed on payer's debit note. Supported by SIX Acquiring. No guarantee that it will show up on the payer's debit note, because his bank has to support it too. Please note that maximum allowed characters are rarely supported. It's usually around 10-12. | ## Testing ``` diff --git a/SaferpayGatewayFactory.php b/SaferpayGatewayFactory.php index 8ffca81..3f830ee 100644 --- a/SaferpayGatewayFactory.php +++ b/SaferpayGatewayFactory.php @@ -64,7 +64,7 @@ protected function populateConfig(ArrayObject $config): void $prependActions[] = 'payum.action.insert_card_alias'; $config['payum.prepend_actions'] = $prependActions; - if (false == $config['payum.api']) { + if (!$config['payum.api']) { $config['payum.default_options'] = [ 'sandbox' => true, ]; diff --git a/Tests/Functional/AbstractSaferpayTest.php b/Tests/Functional/AbstractSaferpayTest.php index c3629d2..f7d9905 100644 --- a/Tests/Functional/AbstractSaferpayTest.php +++ b/Tests/Functional/AbstractSaferpayTest.php @@ -23,7 +23,6 @@ use Payum\Core\Storage\FilesystemStorage; use Payum\Core\Storage\StorageInterface; use PHPUnit\Framework\TestCase; -use Symfony\Component\BrowserKit\Exception\BadMethodCallException; use Symfony\Component\BrowserKit\Response; use Symfony\Component\DomCrawler\Crawler; @@ -42,19 +41,10 @@ abstract class AbstractSaferpayTest extends TestCase protected const CARD_SUCCESS = '9030101152000007'; protected const CARD_FAILED = '9030100152000009'; //'9010100152000003'; - /** @var Payum */ protected Payum $payum; - - /** @var GatewayInterface */ protected GatewayInterface $gateway; - - /** @var StorageInterface */ protected StorageInterface $storage; - - /** @var StorageInterface */ protected StorageInterface $cardAliasStorage; - - /** @var Client */ protected Client $client; public function setUp(): void @@ -91,9 +81,6 @@ public function setUp(): void protected function submitForm(string $buttonSel, array $fieldValues = [], string $method = 'POST', array $serverParameters = []): Crawler { $crawler = $this->client->getCrawler(); - if (null === $crawler) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } $buttonNode = $crawler->filter($buttonSel)->first(); $form = $buttonNode->form($fieldValues, $method); @@ -104,9 +91,6 @@ protected function submitForm(string $buttonSel, array $fieldValues = [], string protected function clickLink(string $linkSelector): Crawler { $crawler = $this->client->getCrawler(); - if (null === $crawler) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } return $this->client->click($crawler->filter($linkSelector)->link()); } @@ -114,9 +98,6 @@ protected function clickLink(string $linkSelector): Crawler protected function clickButton(string $buttonSelector): Crawler { $crawler = $this->client->getCrawler(); - if (null === $crawler) { - throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__)); - } $buttonNode = $crawler->filter($buttonSelector)->first(); $form = $buttonNode->form([], 'POST'); diff --git a/Tests/Unit/Action/AuthorizeActionTest.php b/Tests/Unit/Action/AuthorizeActionTest.php index aa91a7d..d1cb9a1 100644 --- a/Tests/Unit/Action/AuthorizeActionTest.php +++ b/Tests/Unit/Action/AuthorizeActionTest.php @@ -13,7 +13,6 @@ class AuthorizeActionTest extends GenericActionTest protected $requestClass = Authorize::class; protected $actionClass = AuthorizeAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/CaptureReferencedActionTest.php b/Tests/Unit/Action/CaptureReferencedActionTest.php index 4aab56d..9cf6a61 100644 --- a/Tests/Unit/Action/CaptureReferencedActionTest.php +++ b/Tests/Unit/Action/CaptureReferencedActionTest.php @@ -14,7 +14,6 @@ class CaptureReferencedActionTest extends GenericActionTest protected $requestClass = CaptureReferenced::class; protected $actionClass = CaptureReferencedAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/ConvertPaymentActionTest.php b/Tests/Unit/Action/ConvertPaymentActionTest.php index 7cc8452..4d72409 100644 --- a/Tests/Unit/Action/ConvertPaymentActionTest.php +++ b/Tests/Unit/Action/ConvertPaymentActionTest.php @@ -18,7 +18,6 @@ class ConvertPaymentActionTest extends GenericActionTest protected $requestClass = Convert::class; protected $actionClass = ConvertPaymentAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/InsertCardAliasActionTest.php b/Tests/Unit/Action/InsertCardAliasActionTest.php index 5d933b5..0d7f7c0 100644 --- a/Tests/Unit/Action/InsertCardAliasActionTest.php +++ b/Tests/Unit/Action/InsertCardAliasActionTest.php @@ -15,7 +15,6 @@ class InsertCardAliasActionTest extends GenericActionTest protected $requestClass = InsertCardAlias::class; protected $actionClass = InsertCardAliasAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/NotifyActionTest.php b/Tests/Unit/Action/NotifyActionTest.php index 15c466b..4df5fc2 100644 --- a/Tests/Unit/Action/NotifyActionTest.php +++ b/Tests/Unit/Action/NotifyActionTest.php @@ -13,7 +13,6 @@ class NotifyActionTest extends GenericActionTest protected $requestClass = Notify::class; protected $actionClass = NotifyAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/RefundActionTest.php b/Tests/Unit/Action/RefundActionTest.php index c94508a..8cad693 100644 --- a/Tests/Unit/Action/RefundActionTest.php +++ b/Tests/Unit/Action/RefundActionTest.php @@ -13,7 +13,6 @@ class RefundActionTest extends GenericActionTest protected $requestClass = Refund::class; protected $actionClass = RefundAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/StatusActionTest.php b/Tests/Unit/Action/StatusActionTest.php index 50cb734..7d8d993 100644 --- a/Tests/Unit/Action/StatusActionTest.php +++ b/Tests/Unit/Action/StatusActionTest.php @@ -12,7 +12,6 @@ class StatusActionTest extends GenericActionTest protected $requestClass = GetHumanStatus::class; protected $actionClass = StatusAction::class; - /** * @test */ diff --git a/Tests/Unit/Action/SyncActionTest.php b/Tests/Unit/Action/SyncActionTest.php index bd3ec9a..87f52d9 100644 --- a/Tests/Unit/Action/SyncActionTest.php +++ b/Tests/Unit/Action/SyncActionTest.php @@ -13,7 +13,6 @@ class SyncActionTest extends GenericActionTest protected $requestClass = Sync::class; protected $actionClass = SyncAction::class; - /** * @test */ diff --git a/Tests/Unit/ApiTest.php b/Tests/Unit/ApiTest.php index 377ecd0..6a1e90b 100644 --- a/Tests/Unit/ApiTest.php +++ b/Tests/Unit/ApiTest.php @@ -22,13 +22,13 @@ class ApiTest extends TestCase public function setUp(): void { - $this->options = array( + $this->options = [ 'username' => 'test', 'password' => 'test', 'customerId' => 'test', 'terminalId' => 'test', 'sandbox' => true, - ); + ]; } /** @@ -369,7 +369,8 @@ public function throwIfResponseStatusNotOk(): void } } - protected function createSuccessHttpClientStub(): MockObject|HttpClientInterface + /** @return MockObject&HttpClientInterface */ + protected function createSuccessHttpClientStub() { $clientMock = $this->createHttpClientMock(); $clientMock @@ -381,7 +382,8 @@ protected function createSuccessHttpClientStub(): MockObject|HttpClientInterface return $clientMock; } - protected function createHttpClientMock(): MockObject|HttpClientInterface + /** @return MockObject&HttpClientInterface */ + protected function createHttpClientMock() { return $this->getMockBuilder(HttpClientInterface::class)->getMock(); } diff --git a/composer.json b/composer.json index b05584c..21038a8 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ ], "require": { "php": "^8.0", - "payum/core": "^1.7" + "payum/core": "^1.7.3" }, "require-dev": { "fabpot/goutte": "^4.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7a79e42..41502e6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,9 @@ - + . From e1bc70e76bdfc7e1b0d3b88d8cabb2d1b9546c45 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 1 Dec 2023 21:37:00 +0100 Subject: [PATCH 3/3] feat: drop support of php 7, add language level features of php8, update guzzle6 to 7 --- Tests/Unit/ApiTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Unit/ApiTest.php b/Tests/Unit/ApiTest.php index 60c0a78..1f581d1 100644 --- a/Tests/Unit/ApiTest.php +++ b/Tests/Unit/ApiTest.php @@ -28,8 +28,8 @@ public function setUp(): void 'customerId' => 'test', 'terminalId' => 'test', 'sandbox' => true, - 'instantCapturing' => true, - ); + 'instantCapturing' => true + ]; } /**