diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
index 251f26a..c9157a8 100644
--- a/.github/workflows/phpunit.yml
+++ b/.github/workflows/phpunit.yml
@@ -11,12 +11,10 @@ jobs:
strategy:
matrix:
php-version:
- - "8.1"
+ - "8.2"
deps:
- "normal"
- include:
- - deps: "low"
- php-version: "8.1"
+ - "low"
steps:
- name: "Checkout"
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
index d3ebdf6..f744fb4 100644
--- a/.github/workflows/static-analysis.yml
+++ b/.github/workflows/static-analysis.yml
@@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
php-version:
- - "8.1"
+ - "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
diff --git a/.gitignore b/.gitignore
index c4e8084..adbc2ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
composer.lock
/.idea
/.env*
+/.phpunit.cache
diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index c07384c..6c02218 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -20,7 +20,7 @@
'strict_param' => false,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
- 'phpdoc_align' => [],
+ 'phpdoc_align' => ['align' => 'left'],
'phpdoc_summary' => false,
'void_return' => false,
'phpdoc_var_without_name' => false,
diff --git a/composer.json b/composer.json
index 9083f00..6e34446 100644
--- a/composer.json
+++ b/composer.json
@@ -9,24 +9,24 @@
],
"license": "MIT",
"require": {
- "php": "^8.1",
+ "php": "^8.2",
"ext-json": "*",
- "guzzlehttp/guzzle": "^6.5.8 || ^7.0",
- "payum/core": "^1.7.3",
+ "guzzlehttp/guzzle": "^7.0",
+ "payum/core": "^1.7.5",
+ "php-http/guzzle7-adapter": "^1.0",
"php-http/message": "<1.16.0",
- "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/http-kernel": "^6.0|^7.0",
"webmozart/assert": "^1.11"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "^v3.13",
- "matthiasnoback/symfony-config-test": "^4.3",
- "php-http/guzzle6-adapter": "^1.1.1",
- "phpro/grumphp": "^1.15",
- "phpstan/phpstan": "^1.10.6",
- "phpstan/phpstan-webmozart-assert": "^1.2.4",
- "phpunit/phpunit": "^9.6.5",
+ "friendsofphp/php-cs-fixer": "^v3.64",
+ "matthiasnoback/symfony-config-test": "^5.2",
+ "phpro/grumphp": "^1.16",
+ "phpstan/phpstan": "^1.12",
+ "phpstan/phpstan-webmozart-assert": "^1.2",
+ "phpunit/phpunit": "^11.0.1",
"roave/security-advisories": "dev-latest",
- "symfony/phpunit-bridge": "^6.2.7"
+ "symfony/phpunit-bridge": "^7.1"
},
"autoload": {
"psr-4": {
diff --git a/core/Action/Request/SyncPayment.php b/core/Action/Request/SyncPayment.php
index ec23359..c709601 100644
--- a/core/Action/Request/SyncPayment.php
+++ b/core/Action/Request/SyncPayment.php
@@ -7,9 +7,9 @@
use Payum\Core\Model\ModelAggregateInterface;
use Payum\Core\Model\PaymentInterface;
-class SyncPayment implements ModelAggregateInterface
+readonly class SyncPayment implements ModelAggregateInterface
{
- public function __construct(private readonly PaymentInterface $model)
+ public function __construct(private PaymentInterface $model)
{
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 2fd591f..ea3bd6a 100755
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,23 +1,17 @@
-
+
-
./tests
-
-
-
-
diff --git a/src/Authorization/AuthType/OAuth.php b/src/Authorization/AuthType/OAuth.php
index 6e09e41..a732e4f 100644
--- a/src/Authorization/AuthType/OAuth.php
+++ b/src/Authorization/AuthType/OAuth.php
@@ -4,9 +4,9 @@
namespace Answear\Payum\PayU\Authorization\AuthType;
-class OAuth implements AuthType
+readonly class OAuth implements AuthType
{
- public function __construct(private readonly string $accessToken)
+ public function __construct(private string $accessToken)
{
}
diff --git a/src/ValueObject/Auth/OAuthResultClientCredentials.php b/src/ValueObject/Auth/OAuthResultClientCredentials.php
index ba0b560..da98ee7 100644
--- a/src/ValueObject/Auth/OAuthResultClientCredentials.php
+++ b/src/ValueObject/Auth/OAuthResultClientCredentials.php
@@ -8,14 +8,14 @@
use Psr\Http\Message\ResponseInterface;
use Webmozart\Assert\Assert;
-class OAuthResultClientCredentials
+readonly class OAuthResultClientCredentials
{
public function __construct(
- public readonly string $accessToken,
- public readonly string $tokenType,
- public readonly int $expiresIn,
- public readonly OAuthGrantType $grantType,
- public readonly \DateTimeImmutable $expireDate
+ public string $accessToken,
+ public string $tokenType,
+ public int $expiresIn,
+ public OAuthGrantType $grantType,
+ public \DateTimeImmutable $expireDate,
) {
}
diff --git a/src/ValueObject/Buyer.php b/src/ValueObject/Buyer.php
index 2280b97..424f0ca 100644
--- a/src/ValueObject/Buyer.php
+++ b/src/ValueObject/Buyer.php
@@ -4,18 +4,18 @@
namespace Answear\Payum\PayU\ValueObject;
-class Buyer
+readonly class Buyer
{
public function __construct(
- public readonly string $email,
- public readonly string $firstName,
- public readonly string $lastName,
- public readonly ?string $phone = null,
- public readonly ?string $customerId = null,
- public readonly ?string $extCustomerId = null,
- public readonly ?string $nin = null,
- public readonly ?string $language = null,
- public readonly ?Delivery $delivery = null,
+ public string $email,
+ public string $firstName,
+ public string $lastName,
+ public ?string $phone = null,
+ public ?string $customerId = null,
+ public ?string $extCustomerId = null,
+ public ?string $nin = null,
+ public ?string $language = null,
+ public ?Delivery $delivery = null,
) {
}
diff --git a/src/ValueObject/Configuration.php b/src/ValueObject/Configuration.php
index 78463ae..b9eb05b 100644
--- a/src/ValueObject/Configuration.php
+++ b/src/ValueObject/Configuration.php
@@ -4,14 +4,14 @@
namespace Answear\Payum\PayU\ValueObject;
-class Configuration
+readonly class Configuration
{
public function __construct(
- public readonly string $publicShopId,
- public readonly string $posId,
- public readonly string $signatureKey,
- public readonly string $oauthClientId,
- public readonly string $oauthClientSecret,
+ public string $publicShopId,
+ public string $posId,
+ public string $signatureKey,
+ public string $oauthClientId,
+ public string $oauthClientSecret,
) {
}
}
diff --git a/src/ValueObject/Delivery.php b/src/ValueObject/Delivery.php
index 0380f5f..2697eee 100644
--- a/src/ValueObject/Delivery.php
+++ b/src/ValueObject/Delivery.php
@@ -4,19 +4,19 @@
namespace Answear\Payum\PayU\ValueObject;
-class Delivery
+readonly class Delivery
{
public function __construct(
- public readonly string $street,
- public readonly string $postalCode,
- public readonly string $city,
- public readonly ?string $countryCode = null,
- public readonly ?string $name = null,
- public readonly ?string $recipientName = null,
- public readonly ?string $recipientEmail = null,
- public readonly ?string $recipientPhone = null,
- public readonly ?string $postalBox = null,
- public readonly ?string $state = null,
+ public string $street,
+ public string $postalCode,
+ public string $city,
+ public ?string $countryCode = null,
+ public ?string $name = null,
+ public ?string $recipientName = null,
+ public ?string $recipientEmail = null,
+ public ?string $recipientPhone = null,
+ public ?string $postalBox = null,
+ public ?string $state = null,
) {
}
diff --git a/src/ValueObject/PayMethod.php b/src/ValueObject/PayMethod.php
index 0b8c17b..a70e30b 100644
--- a/src/ValueObject/PayMethod.php
+++ b/src/ValueObject/PayMethod.php
@@ -6,11 +6,11 @@
use Answear\Payum\PayU\Enum\PayMethodType;
-class PayMethod
+readonly class PayMethod
{
public function __construct(
- public readonly ?PayMethodType $type,
- public readonly ?string $value = null
+ public ?PayMethodType $type,
+ public ?string $value = null,
) {
if (null === $this->type && null === $this->value) {
throw new \InvalidArgumentException('Type or value are required.');
diff --git a/src/ValueObject/Product.php b/src/ValueObject/Product.php
index 94a0a4e..8aa601c 100644
--- a/src/ValueObject/Product.php
+++ b/src/ValueObject/Product.php
@@ -7,14 +7,14 @@
use Answear\Payum\PayU\Util\BooleanTransformer;
use Webmozart\Assert\Assert;
-class Product
+readonly class Product
{
public function __construct(
- public readonly string $name,
- public readonly int $unitPrice,
- public readonly int $quantity,
- public readonly ?bool $virtual = null,
- public readonly ?\DateTimeImmutable $listingDate = null,
+ public string $name,
+ public int $unitPrice,
+ public int $quantity,
+ public ?bool $virtual = null,
+ public ?\DateTimeImmutable $listingDate = null,
) {
}
diff --git a/src/ValueObject/Request/Order/PayMethod.php b/src/ValueObject/Request/Order/PayMethod.php
index e509f74..19f805c 100644
--- a/src/ValueObject/Request/Order/PayMethod.php
+++ b/src/ValueObject/Request/Order/PayMethod.php
@@ -6,13 +6,13 @@
use Answear\Payum\PayU\Enum\PayMethodType;
-class PayMethod
+readonly class PayMethod
{
public function __construct(
- public readonly PayMethodType $type,
- public readonly ?string $value = null,
- public readonly ?string $authorizationCode = null,
- public readonly ?array $specificData = null,
+ public PayMethodType $type,
+ public ?string $value = null,
+ public ?string $authorizationCode = null,
+ public ?array $specificData = null,
) {
if (PayMethodType::PaymentWall !== $this->type && empty($value)) {
throw new \InvalidArgumentException(sprintf('Value is required for type %s.', $this->type->value));
diff --git a/src/ValueObject/Request/Order/ThreeDsAuthentication.php b/src/ValueObject/Request/Order/ThreeDsAuthentication.php
index 5a8e2be..c5a63d2 100644
--- a/src/ValueObject/Request/Order/ThreeDsAuthentication.php
+++ b/src/ValueObject/Request/Order/ThreeDsAuthentication.php
@@ -6,10 +6,10 @@
use Answear\Payum\PayU\Enum\ChallengeRequestedType;
-class ThreeDsAuthentication
+readonly class ThreeDsAuthentication
{
public function __construct(
- public readonly ChallengeRequestedType $challengeRequested,
+ public ChallengeRequestedType $challengeRequested,
) {
}
diff --git a/src/ValueObject/Request/Refund/Refund.php b/src/ValueObject/Request/Refund/Refund.php
index 6644b40..d3a4dc4 100644
--- a/src/ValueObject/Request/Refund/Refund.php
+++ b/src/ValueObject/Request/Refund/Refund.php
@@ -4,13 +4,13 @@
namespace Answear\Payum\PayU\ValueObject\Request\Refund;
-class Refund
+readonly class Refund
{
public function __construct(
- public readonly string $description,
- public readonly ?int $amount,
- public readonly ?string $extCustomerId = null,
- public readonly ?string $extRefundId = null,
+ public string $description,
+ public ?int $amount,
+ public ?string $extCustomerId = null,
+ public ?string $extRefundId = null,
) {
}
diff --git a/src/ValueObject/Request/RefundRequest.php b/src/ValueObject/Request/RefundRequest.php
index 6d38174..07346bd 100644
--- a/src/ValueObject/Request/RefundRequest.php
+++ b/src/ValueObject/Request/RefundRequest.php
@@ -7,13 +7,13 @@
use Answear\Payum\PayU\Enum\AuthType;
use Answear\Payum\PayU\ValueObject\Request\Refund\Refund;
-class RefundRequest
+readonly class RefundRequest
{
public const METHOD = 'POST';
public const AUTH_TYPE = AuthType::Basic;
public function __construct(
- public readonly Refund $refund
+ public Refund $refund,
) {
}
diff --git a/src/ValueObject/Response/Notify/NotifyRefund.php b/src/ValueObject/Response/Notify/NotifyRefund.php
index 8e23a0b..72f2dec 100644
--- a/src/ValueObject/Response/Notify/NotifyRefund.php
+++ b/src/ValueObject/Response/Notify/NotifyRefund.php
@@ -7,18 +7,18 @@
use Answear\Payum\PayU\Enum\RefundStatus;
use Webmozart\Assert\Assert;
-class NotifyRefund
+readonly class NotifyRefund
{
public function __construct(
- public readonly string $refundId,
- public readonly ?string $extRefundId,
- public readonly int $amount,
- public readonly string $currencyCode,
- public readonly RefundStatus $status,
- public readonly \DateTimeImmutable $statusDateTime,
- public readonly string $reason,
- public readonly string $reasonDescription,
- public readonly \DateTimeImmutable $refundDate,
+ public string $refundId,
+ public ?string $extRefundId,
+ public int $amount,
+ public string $currencyCode,
+ public RefundStatus $status,
+ public \DateTimeImmutable $statusDateTime,
+ public string $reason,
+ public string $reasonDescription,
+ public \DateTimeImmutable $refundDate,
) {
}
diff --git a/src/ValueObject/Response/Order.php b/src/ValueObject/Response/Order.php
index 65b8b9f..36c49d3 100644
--- a/src/ValueObject/Response/Order.php
+++ b/src/ValueObject/Response/Order.php
@@ -10,26 +10,26 @@
use Answear\Payum\PayU\ValueObject\Product;
use Webmozart\Assert\Assert;
-class Order
+readonly class Order
{
public const DEFAULT_VALIDITY_TIME = 86400;
public function __construct(
- public readonly string $orderId,
- public readonly ?string $extOrderId,
- public readonly \DateTimeImmutable $orderCreateDate,
- public readonly string $notifyUrl,
- public readonly string $customerIp,
- public readonly string $merchantPosId,
- public readonly string $description,
- public readonly ?string $additionalDescription,
- public readonly string $currencyCode,
- public readonly int $totalAmount,
- public readonly array $products,
- public readonly OrderStatus $status,
- public readonly ?Buyer $buyer = null,
- public readonly ?PayMethod $payMethod = null,
- public readonly ?int $validityTime = self::DEFAULT_VALIDITY_TIME,
+ public string $orderId,
+ public ?string $extOrderId,
+ public \DateTimeImmutable $orderCreateDate,
+ public string $notifyUrl,
+ public string $customerIp,
+ public string $merchantPosId,
+ public string $description,
+ public ?string $additionalDescription,
+ public string $currencyCode,
+ public int $totalAmount,
+ public array $products,
+ public OrderStatus $status,
+ public ?Buyer $buyer = null,
+ public ?PayMethod $payMethod = null,
+ public ?int $validityTime = self::DEFAULT_VALIDITY_TIME,
) {
}
diff --git a/src/ValueObject/Response/OrderCanceledResponse.php b/src/ValueObject/Response/OrderCanceledResponse.php
index 690c8d7..f3d2ebc 100644
--- a/src/ValueObject/Response/OrderCanceledResponse.php
+++ b/src/ValueObject/Response/OrderCanceledResponse.php
@@ -4,12 +4,12 @@
namespace Answear\Payum\PayU\ValueObject\Response;
-class OrderCanceledResponse
+readonly class OrderCanceledResponse
{
public function __construct(
- public readonly ResponseStatus $status,
- public readonly string $orderId,
- public readonly ?string $extOrderId = null
+ public ResponseStatus $status,
+ public string $orderId,
+ public ?string $extOrderId = null,
) {
}
diff --git a/src/ValueObject/Response/OrderCreated/OrderCreatedStatus.php b/src/ValueObject/Response/OrderCreated/OrderCreatedStatus.php
index dfa7af6..8fea75a 100644
--- a/src/ValueObject/Response/OrderCreated/OrderCreatedStatus.php
+++ b/src/ValueObject/Response/OrderCreated/OrderCreatedStatus.php
@@ -4,12 +4,12 @@
namespace Answear\Payum\PayU\ValueObject\Response\OrderCreated;
-class OrderCreatedStatus
+readonly class OrderCreatedStatus
{
public function __construct(
- public readonly StatusCode $statusCode,
- public readonly ?string $statusDesc = null,
- public readonly ?string $codeLiteral = null,
+ public StatusCode $statusCode,
+ public ?string $statusDesc = null,
+ public ?string $codeLiteral = null,
) {
}
diff --git a/src/ValueObject/Response/OrderCreatedResponse.php b/src/ValueObject/Response/OrderCreatedResponse.php
index e861e74..8282a14 100644
--- a/src/ValueObject/Response/OrderCreatedResponse.php
+++ b/src/ValueObject/Response/OrderCreatedResponse.php
@@ -6,14 +6,14 @@
use Answear\Payum\PayU\ValueObject\Response\OrderCreated\OrderCreatedStatus;
-class OrderCreatedResponse
+readonly class OrderCreatedResponse
{
public function __construct(
- public readonly OrderCreatedStatus $status,
- public readonly ?string $redirectUri,
- public readonly string $orderId,
- public readonly ?string $extOrderId = null,
- public readonly ?array $payMethods = null,
+ public OrderCreatedStatus $status,
+ public ?string $redirectUri,
+ public string $orderId,
+ public ?string $extOrderId = null,
+ public ?array $payMethods = null,
) {
}
diff --git a/src/ValueObject/Response/OrderRetrieveResponse.php b/src/ValueObject/Response/OrderRetrieveResponse.php
index 8ecf24f..ee28313 100644
--- a/src/ValueObject/Response/OrderRetrieveResponse.php
+++ b/src/ValueObject/Response/OrderRetrieveResponse.php
@@ -6,16 +6,16 @@
use Webmozart\Assert\Assert;
-class OrderRetrieveResponse
+readonly class OrderRetrieveResponse
{
/**
* @param array $orders
* @param array $properties
*/
public function __construct(
- public readonly array $orders,
- public readonly ResponseStatus $status,
- public readonly array $properties,
+ public array $orders,
+ public ResponseStatus $status,
+ public array $properties,
) {
Assert::allIsInstanceOf($this->orders, Order::class);
Assert::allIsInstanceOf($this->properties, Property::class);
diff --git a/src/ValueObject/Response/OrderRetrieveTransactionResponse.php b/src/ValueObject/Response/OrderRetrieveTransactionResponse.php
index 305368c..d27e88a 100644
--- a/src/ValueObject/Response/OrderRetrieveTransactionResponse.php
+++ b/src/ValueObject/Response/OrderRetrieveTransactionResponse.php
@@ -6,16 +6,16 @@
use Webmozart\Assert\Assert;
-class OrderRetrieveTransactionResponse
+readonly class OrderRetrieveTransactionResponse
{
/**
* @param array $orders
* @param array $properties
*/
public function __construct(
- public readonly array $orders,
- public readonly ResponseStatus $status,
- public readonly array $properties,
+ public array $orders,
+ public ResponseStatus $status,
+ public array $properties,
) {
Assert::allIsInstanceOf($this->orders, Order::class);
Assert::allIsInstanceOf($this->properties, Property::class);
diff --git a/src/ValueObject/Response/OrderTransactions/ByCreditCard.php b/src/ValueObject/Response/OrderTransactions/ByCreditCard.php
index 346fa18..f5fc4e9 100644
--- a/src/ValueObject/Response/OrderTransactions/ByCreditCard.php
+++ b/src/ValueObject/Response/OrderTransactions/ByCreditCard.php
@@ -6,12 +6,12 @@
use Answear\Payum\PayU\ValueObject\PayMethod;
-class ByCreditCard implements OrderRetrieveTransactionsResponseInterface
+readonly class ByCreditCard implements OrderRetrieveTransactionsResponseInterface
{
public function __construct(
- public readonly PayMethod $payMethod,
- public readonly string $paymentFlow,
- public readonly ?array $card,
+ public PayMethod $payMethod,
+ public string $paymentFlow,
+ public ?array $card,
) {
}
diff --git a/src/ValueObject/Response/OrderTransactions/ByPBL.php b/src/ValueObject/Response/OrderTransactions/ByPBL.php
index 5ee28de..081ccff 100644
--- a/src/ValueObject/Response/OrderTransactions/ByPBL.php
+++ b/src/ValueObject/Response/OrderTransactions/ByPBL.php
@@ -6,11 +6,11 @@
use Answear\Payum\PayU\ValueObject\PayMethod;
-class ByPBL implements OrderRetrieveTransactionsResponseInterface
+readonly class ByPBL implements OrderRetrieveTransactionsResponseInterface
{
public function __construct(
- public readonly PayMethod $payMethod,
- public readonly ?array $bankAccount,
+ public PayMethod $payMethod,
+ public ?array $bankAccount,
) {
}
diff --git a/src/ValueObject/Response/PayByLink.php b/src/ValueObject/Response/PayByLink.php
index 65b1691..88af935 100644
--- a/src/ValueObject/Response/PayByLink.php
+++ b/src/ValueObject/Response/PayByLink.php
@@ -6,18 +6,18 @@
use Answear\Payum\PayU\Enum\PayByLinkStatus;
-class PayByLink
+readonly class PayByLink
{
private const AMOUNT_MIN = 0;
private const AMOUNT_MAX = 99999999;
public function __construct(
- public readonly string $value,
- public readonly string $name,
- public readonly string $brandImageUrl,
- public readonly PayByLinkStatus $status,
- public readonly ?int $minAmount = null,
- public readonly ?int $maxAmount = null,
+ public string $value,
+ public string $name,
+ public string $brandImageUrl,
+ public PayByLinkStatus $status,
+ public ?int $minAmount = null,
+ public ?int $maxAmount = null,
) {
}
diff --git a/src/ValueObject/Response/PayMethodsResponse.php b/src/ValueObject/Response/PayMethodsResponse.php
index 97d9bfe..2acde77 100644
--- a/src/ValueObject/Response/PayMethodsResponse.php
+++ b/src/ValueObject/Response/PayMethodsResponse.php
@@ -4,16 +4,16 @@
namespace Answear\Payum\PayU\ValueObject\Response;
-class PayMethodsResponse
+readonly class PayMethodsResponse
{
/**
* @param array $payByLinks
*/
public function __construct(
- public readonly array $cardTokens,
- public readonly array $pexTokens,
- public readonly array $payByLinks,
- public readonly ResponseStatus $status,
+ public array $cardTokens,
+ public array $pexTokens,
+ public array $payByLinks,
+ public ResponseStatus $status,
) {
}
diff --git a/src/ValueObject/Response/Property.php b/src/ValueObject/Response/Property.php
index f587964..5682a5c 100644
--- a/src/ValueObject/Response/Property.php
+++ b/src/ValueObject/Response/Property.php
@@ -4,11 +4,11 @@
namespace Answear\Payum\PayU\ValueObject\Response;
-class Property
+readonly class Property
{
public function __construct(
- public readonly string $name,
- public readonly string $value,
+ public string $name,
+ public string $value,
) {
}
}
diff --git a/src/ValueObject/Response/Refund.php b/src/ValueObject/Response/Refund.php
index dcd4bf1..c9085ff 100644
--- a/src/ValueObject/Response/Refund.php
+++ b/src/ValueObject/Response/Refund.php
@@ -7,18 +7,18 @@
use Answear\Payum\PayU\Enum\RefundStatus;
use Webmozart\Assert\Assert;
-class Refund
+readonly class Refund
{
public function __construct(
- public readonly string $refundId,
- public readonly string $extRefundId,
- public readonly int $amount,
- public readonly string $currencyCode,
- public readonly string $description,
- public readonly \DateTimeImmutable $creationDateTime,
- public readonly ?\DateTimeImmutable $statusDateTime,
- public readonly RefundStatus $status,
- public readonly ?RefundStatusError $statusError = null
+ public string $refundId,
+ public string $extRefundId,
+ public int $amount,
+ public string $currencyCode,
+ public string $description,
+ public \DateTimeImmutable $creationDateTime,
+ public ?\DateTimeImmutable $statusDateTime,
+ public RefundStatus $status,
+ public ?RefundStatusError $statusError = null,
) {
}
diff --git a/src/ValueObject/Response/RefundCreatedResponse.php b/src/ValueObject/Response/RefundCreatedResponse.php
index 57fdb0a..57188e0 100644
--- a/src/ValueObject/Response/RefundCreatedResponse.php
+++ b/src/ValueObject/Response/RefundCreatedResponse.php
@@ -4,12 +4,12 @@
namespace Answear\Payum\PayU\ValueObject\Response;
-class RefundCreatedResponse
+readonly class RefundCreatedResponse
{
public function __construct(
- public readonly string $orderId,
- public readonly Refund $refund,
- public readonly ResponseStatus $status,
+ public string $orderId,
+ public Refund $refund,
+ public ResponseStatus $status,
) {
}
diff --git a/src/ValueObject/Response/RefundStatusError.php b/src/ValueObject/Response/RefundStatusError.php
index ec9dd85..a236357 100644
--- a/src/ValueObject/Response/RefundStatusError.php
+++ b/src/ValueObject/Response/RefundStatusError.php
@@ -6,12 +6,12 @@
use Answear\Payum\PayU\Enum\RefundStatusErrorCode;
-class RefundStatusError
+readonly class RefundStatusError
{
public function __construct(
- public readonly RefundStatusErrorCode $code,
- public readonly string $rawCode,
- public readonly string $description,
+ public RefundStatusErrorCode $code,
+ public string $rawCode,
+ public string $description,
) {
}
diff --git a/src/ValueObject/Response/ResponseStatus.php b/src/ValueObject/Response/ResponseStatus.php
index 6c50c74..a4f90d8 100644
--- a/src/ValueObject/Response/ResponseStatus.php
+++ b/src/ValueObject/Response/ResponseStatus.php
@@ -7,15 +7,15 @@
use Answear\Payum\PayU\Enum\CodeLiteral;
use Answear\Payum\PayU\Enum\ResponseStatusCode;
-class ResponseStatus
+readonly class ResponseStatus
{
public function __construct(
- public readonly ResponseStatusCode $statusCode,
- public readonly ?string $statusDesc = null,
- public readonly ?string $severity = null,
- public readonly ?string $code = null,
- public readonly ?CodeLiteral $codeLiteral = null,
- public readonly ?string $rawCodeLiteral = null,
+ public ResponseStatusCode $statusCode,
+ public ?string $statusDesc = null,
+ public ?string $severity = null,
+ public ?string $code = null,
+ public ?CodeLiteral $codeLiteral = null,
+ public ?string $rawCodeLiteral = null,
) {
}
diff --git a/src/ValueObject/Response/RetrieveOrderResponse.php b/src/ValueObject/Response/RetrieveOrderResponse.php
index bd94657..7d125dc 100644
--- a/src/ValueObject/Response/RetrieveOrderResponse.php
+++ b/src/ValueObject/Response/RetrieveOrderResponse.php
@@ -4,12 +4,12 @@
namespace Answear\Payum\PayU\ValueObject\Response;
-class RetrieveOrderResponse
+readonly class RetrieveOrderResponse
{
public function __construct(
- public readonly string $orderId,
- public readonly Refund $refund,
- public readonly ResponseStatus $status,
+ public string $orderId,
+ public Refund $refund,
+ public ResponseStatus $status,
) {
}
diff --git a/src/ValueObject/Response/Shop/ShopBalance.php b/src/ValueObject/Response/Shop/ShopBalance.php
index 6bf76e3..b5c3532 100644
--- a/src/ValueObject/Response/Shop/ShopBalance.php
+++ b/src/ValueObject/Response/Shop/ShopBalance.php
@@ -4,12 +4,12 @@
namespace Answear\Payum\PayU\ValueObject\Response\Shop;
-class ShopBalance
+readonly class ShopBalance
{
public function __construct(
- public readonly string $currencyCode,
- public readonly int $total,
- public readonly int $available
+ public string $currencyCode,
+ public int $total,
+ public int $available,
) {
}
diff --git a/src/ValueObject/Response/ShopInfo.php b/src/ValueObject/Response/ShopInfo.php
index e7d4e2f..ab6dc20 100644
--- a/src/ValueObject/Response/ShopInfo.php
+++ b/src/ValueObject/Response/ShopInfo.php
@@ -6,13 +6,13 @@
use Answear\Payum\PayU\ValueObject\Response\Shop\ShopBalance;
-class ShopInfo
+readonly class ShopInfo
{
public function __construct(
- public readonly string $shopId,
- public readonly string $name,
- public readonly string $currencyCode,
- public readonly ShopBalance $balance
+ public string $shopId,
+ public string $name,
+ public string $currencyCode,
+ public ShopBalance $balance,
) {
}
diff --git a/tests/Acceptance/DependencyInjection/ConfigurationTest.php b/tests/Acceptance/DependencyInjection/ConfigurationTest.php
index fc559b2..172de60 100644
--- a/tests/Acceptance/DependencyInjection/ConfigurationTest.php
+++ b/tests/Acceptance/DependencyInjection/ConfigurationTest.php
@@ -9,6 +9,8 @@
use Answear\Payum\PayU\Enum\Environment;
use Answear\Payum\PayU\Service\ConfigProvider;
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@@ -22,11 +24,8 @@ protected function setUp(): void
parent::setUp();
}
- /**
- * @test
- *
- * @dataProvider provideValidConfig
- */
+ #[Test]
+ #[DataProvider('provideValidConfig')]
public function validTest(array $configs): void
{
$this->assertConfigurationIsValid($configs);
@@ -42,11 +41,8 @@ public function validTest(array $configs): void
self::assertSame($configs[0]['configs'], $configProviderDefinition->getArgument(1));
}
- /**
- * @test
- *
- * @dataProvider provideInvalidConfig
- */
+ #[Test]
+ #[DataProvider('provideInvalidConfig')]
public function invalid(array $config, ?string $expectedMessage = null): void
{
$this->assertConfigurationIsInvalid(
@@ -55,11 +51,8 @@ public function invalid(array $config, ?string $expectedMessage = null): void
);
}
- /**
- * @test
- *
- * @dataProvider provideMoreInvalidConfig
- */
+ #[Test]
+ #[DataProvider('provideMoreInvalidConfig')]
public function moreInvalidTest(array $configs, \Throwable $expectedException): void
{
$this->expectException(get_class($expectedException));
@@ -73,7 +66,7 @@ public function moreInvalidTest(array $configs, \Throwable $expectedException):
$extension->load($configs, $builder);
}
- public function provideInvalidConfig(): iterable
+ public static function provideInvalidConfig(): iterable
{
yield [
[
@@ -170,7 +163,7 @@ public function provideInvalidConfig(): iterable
];
}
- public function provideMoreInvalidConfig(): iterable
+ public static function provideMoreInvalidConfig(): iterable
{
yield [
[
@@ -192,7 +185,7 @@ public function provideMoreInvalidConfig(): iterable
];
}
- public function provideValidConfig(): iterable
+ public static function provideValidConfig(): iterable
{
yield [
[
diff --git a/tests/Integration/Action/CaptureActionTest.php b/tests/Integration/Action/CaptureActionTest.php
index 8ead342..c8dd647 100644
--- a/tests/Integration/Action/CaptureActionTest.php
+++ b/tests/Integration/Action/CaptureActionTest.php
@@ -28,14 +28,13 @@
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Security\GenericTokenFactory;
use Payum\Core\Security\TokenInterface;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class CaptureActionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function captureTest(): void
{
$captureAction = $this->getCaptureAction(
@@ -58,17 +57,15 @@ public function captureTest(): void
self::assertTrue($redirected);
}
- /**
- * @test
- */
+ #[Test]
public function captureTestWithThreeDSAuthentication(): void
{
$details = FileTestUtil::decodeJsonFromFile(__DIR__ . '/data/details.json');
$details[ModelFields::THREE_DS_AUTHENTICATION][ModelFields::CHALLENGE_REQUESTED] = ChallengeRequestedType::Mandate->value;
$captureAction = $this->getCaptureAction(
- expectedCreateRequest: FileTestUtil::decodeJsonFromFile(__DIR__ . '/data/expectedOrderRequestWithThreeDSAuthentication.json'),
- details: $details
+ details: $details,
+ expectedCreateRequest: FileTestUtil::decodeJsonFromFile(__DIR__ . '/data/expectedOrderRequestWithThreeDSAuthentication.json')
);
$captureToken = new Token();
@@ -87,9 +84,7 @@ public function captureTestWithThreeDSAuthentication(): void
self::assertTrue($redirected);
}
- /**
- * @test
- */
+ #[Test]
public function captureWithPayMethodTest(): void
{
$captureAction = $this->getCaptureAction(
@@ -119,9 +114,7 @@ public function captureWithPayMethodTest(): void
self::assertTrue($redirected);
}
- /**
- * @test
- */
+ #[Test]
public function captureWithFailResponseTest(): void
{
$captureAction = $this->getCaptureAction(
@@ -206,9 +199,7 @@ public function captureWithFailResponseTest(): void
self::assertTrue($withException);
}
- /**
- * @test
- */
+ #[Test]
public function captureWithOrderIdFailsTest(): void
{
$captureAction = $this->getCaptureAction(null, FileTestUtil::decodeJsonFromFile(__DIR__ . '/data/detailsWithOrderId.json'));
@@ -226,7 +217,7 @@ public function captureWithOrderIdFailsTest(): void
private function getCaptureAction(
?OrderCreatedResponse $response = null,
?array $details = null,
- ?array $expectedCreateRequest = null
+ ?array $expectedCreateRequest = null,
): CaptureAction {
$response = $response ?? new OrderCreatedResponse(
new OrderCreatedStatus(
@@ -243,7 +234,6 @@ private function getCaptureAction(
->with(
$this->callback(
static function (OrderRequest $createRequest) use ($expectedCreateRequest) {
-
if ($expectedCreateRequest) {
$jsonE = json_encode($createRequest->toArray('posId'));
self::assertSame($createRequest->toArray('posId'), $expectedCreateRequest);
diff --git a/tests/Integration/Action/ConvertActionTest.php b/tests/Integration/Action/ConvertActionTest.php
index 89e26d7..337a111 100644
--- a/tests/Integration/Action/ConvertActionTest.php
+++ b/tests/Integration/Action/ConvertActionTest.php
@@ -11,13 +11,12 @@
use Answear\Payum\PayU\Tests\Payment;
use Payum\Core\Model\CreditCard;
use Payum\Core\Request\Convert;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class ConvertActionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function convertWithLowInfoTest(): void
{
$convertAction = new ConvertPaymentAction(new UserIpService());
@@ -69,9 +68,7 @@ public function convertWithLowInfoTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function convertWithFullDataTest(): void
{
$convertAction = new ConvertPaymentAction(new UserIpService());
@@ -135,9 +132,7 @@ public function convertWithFullDataTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function convertButKeepCustomerIp(): void
{
$convertAction = new ConvertPaymentAction(new UserIpService());
@@ -170,7 +165,7 @@ public function convertButKeepCustomerIp(): void
$payment->setPaidFor($paidFor);
$payment->setDetails(
[
- ModelFields::CUSTOMER_IP => '111.222.333.444'
+ ModelFields::CUSTOMER_IP => '111.222.333.444',
]
);
$convert = new Convert($payment, 'array');
diff --git a/tests/Integration/Action/NotifyActionTest.php b/tests/Integration/Action/NotifyActionTest.php
index 249d86f..836fbaa 100644
--- a/tests/Integration/Action/NotifyActionTest.php
+++ b/tests/Integration/Action/NotifyActionTest.php
@@ -20,13 +20,12 @@
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Request\GetHttpRequest;
use Payum\Core\Request\Notify;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class NotifyActionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function orderNotifyTest(): void
{
$notifyAction = $this->getNotifyAction();
@@ -59,9 +58,7 @@ public function orderNotifyTest(): void
self::assertSame(['PAYMENT_ID' => '151471228'], $model['properties'] ?? []);
}
- /**
- * @test
- */
+ #[Test]
public function refundNotifyTest(): void
{
$notifyAction = $this->getNotifyAction(
diff --git a/tests/Integration/Action/RefundActionTest.php b/tests/Integration/Action/RefundActionTest.php
index 40a654e..0cbce12 100644
--- a/tests/Integration/Action/RefundActionTest.php
+++ b/tests/Integration/Action/RefundActionTest.php
@@ -11,13 +11,12 @@
use Answear\Payum\PayU\Tests\Payment;
use Answear\Payum\PayU\Tests\Util\FileTestUtil;
use Answear\Payum\PayU\ValueObject\Response\RefundCreatedResponse;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class RefundActionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function successTest(): void
{
$refundCreatedResponse = RefundCreatedResponse::fromResponse(FileTestUtil::decodeJsonFromFile(__DIR__ . '/data/refundCreatedResponse.json'));
@@ -53,9 +52,7 @@ public function successTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function errorTest(): void
{
$refundCreatedResponse = RefundCreatedResponse::fromResponse(
diff --git a/tests/Integration/Action/SyncPaymentActionTest.php b/tests/Integration/Action/SyncPaymentActionTest.php
index 8cbc79d..fbe9014 100644
--- a/tests/Integration/Action/SyncPaymentActionTest.php
+++ b/tests/Integration/Action/SyncPaymentActionTest.php
@@ -10,13 +10,12 @@
use Answear\Payum\PayU\Tests\Payment;
use Answear\Payum\PayU\Tests\Util\FileTestUtil;
use Answear\Payum\PayU\ValueObject\Response\OrderRetrieveResponse;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class SyncPaymentActionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function successTest(): void
{
$action = $this->getUpdatePaymentAction(
diff --git a/tests/Integration/Request/CancelOrderTest.php b/tests/Integration/Request/CancelOrderTest.php
index 7da8722..2a97bd0 100644
--- a/tests/Integration/Request/CancelOrderTest.php
+++ b/tests/Integration/Request/CancelOrderTest.php
@@ -12,13 +12,12 @@
use Answear\Payum\PayU\Tests\Util\FileTestUtil;
use Answear\Payum\PayU\ValueObject\Response\ResponseStatus;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class CancelOrderTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function createTest(): void
{
$this->mockGuzzleResponse(
@@ -39,9 +38,7 @@ public function createTest(): void
self::assertSame('extOrderId123', $response->extOrderId);
}
- /**
- * @test
- */
+ #[Test]
public function createUnauthorizedTest(): void
{
$this->mockGuzzleResponse(
@@ -53,9 +50,7 @@ public function createUnauthorizedTest(): void
$this->getOrderRequestService()->cancel('WZHF5FFDRJ140731GUEST000P01', null);
}
- /**
- * @test
- */
+ #[Test]
public function notFoundTest(): void
{
$this->mockGuzzleResponse(
@@ -69,9 +64,7 @@ public function notFoundTest(): void
$this->getOrderRequestService()->cancel('WZHF5FFDRJ140731GUEST000P01', null);
}
- /**
- * @test
- */
+ #[Test]
public function internalServerErrorTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/CreateOrderTest.php b/tests/Integration/Request/CreateOrderTest.php
index 4265f88..9f17063 100644
--- a/tests/Integration/Request/CreateOrderTest.php
+++ b/tests/Integration/Request/CreateOrderTest.php
@@ -15,13 +15,12 @@
use Answear\Payum\PayU\ValueObject\Response\OrderCreated\OrderCreatedStatus;
use Answear\Payum\PayU\ValueObject\Response\OrderCreated\StatusCode;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class CreateOrderTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function createTest(): void
{
$this->mockGuzzleResponse(
@@ -62,9 +61,7 @@ public function createTest(): void
self::assertSame('extOrderId123', $orderCreated->extOrderId);
}
- /**
- * @test
- */
+ #[Test]
public function createUnauthorizedTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/CreateRefundTest.php b/tests/Integration/Request/CreateRefundTest.php
index c6298f2..5fabcbb 100644
--- a/tests/Integration/Request/CreateRefundTest.php
+++ b/tests/Integration/Request/CreateRefundTest.php
@@ -14,13 +14,12 @@
use Answear\Payum\PayU\ValueObject\Response\Refund as ResponseRefund;
use Answear\Payum\PayU\ValueObject\Response\ResponseStatus;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class CreateRefundTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function createTest(): void
{
$this->mockGuzzleResponse(
@@ -55,9 +54,7 @@ public function createTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function errorTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/OrderRetrieveTest.php b/tests/Integration/Request/OrderRetrieveTest.php
index 15ca3a3..c02ffd7 100644
--- a/tests/Integration/Request/OrderRetrieveTest.php
+++ b/tests/Integration/Request/OrderRetrieveTest.php
@@ -17,13 +17,12 @@
use Answear\Payum\PayU\ValueObject\Response\Property;
use Answear\Payum\PayU\ValueObject\Response\ResponseStatus;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class OrderRetrieveTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function retrieveTest(): void
{
$this->mockGuzzleResponse(
@@ -83,9 +82,7 @@ public function retrieveTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function retrieveWithPayMethodTest(): void
{
$this->mockGuzzleResponse(
@@ -143,9 +140,7 @@ public function retrieveWithPayMethodTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function notFoundTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/OrderRetrieveTransactionsTest.php b/tests/Integration/Request/OrderRetrieveTransactionsTest.php
index 27fd627..e5c1d14 100644
--- a/tests/Integration/Request/OrderRetrieveTransactionsTest.php
+++ b/tests/Integration/Request/OrderRetrieveTransactionsTest.php
@@ -10,13 +10,12 @@
use Answear\Payum\PayU\ValueObject\Response\OrderTransactions\ByCreditCard;
use Answear\Payum\PayU\ValueObject\Response\OrderTransactions\ByPBL;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class OrderRetrieveTransactionsTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function retrieveByCardTest(): void
{
$this->mockGuzzleResponse(
@@ -56,9 +55,7 @@ public function retrieveByCardTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function retrieveByPBLTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/RetrievePayMethodsTest.php b/tests/Integration/Request/RetrievePayMethodsTest.php
index f90d969..4ba395f 100644
--- a/tests/Integration/Request/RetrievePayMethodsTest.php
+++ b/tests/Integration/Request/RetrievePayMethodsTest.php
@@ -12,13 +12,12 @@
use Answear\Payum\PayU\ValueObject\Response\PayByLink;
use Answear\Payum\PayU\ValueObject\Response\ResponseStatus;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class RetrievePayMethodsTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function retrieveTest(): void
{
$this->mockGuzzleResponse(
@@ -70,9 +69,7 @@ public function retrieveTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function exceptionIfNoSuccess(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/RetrieveRefundsTest.php b/tests/Integration/Request/RetrieveRefundsTest.php
index 181cd07..b59eb5a 100644
--- a/tests/Integration/Request/RetrieveRefundsTest.php
+++ b/tests/Integration/Request/RetrieveRefundsTest.php
@@ -13,13 +13,12 @@
use Answear\Payum\PayU\ValueObject\Response\Refund;
use Answear\Payum\PayU\ValueObject\Response\RefundStatusError;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Log\NullLogger;
class RetrieveRefundsTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function retrieveRefundListTest(): void
{
$this->mockGuzzleResponse(
@@ -58,9 +57,7 @@ public function retrieveRefundListTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function retrieveSingleRefundTest(): void
{
$this->mockGuzzleResponse(
@@ -91,9 +88,7 @@ public function retrieveSingleRefundTest(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function retrieveSingleRefundNotFoundTest(): void
{
$this->mockGuzzleResponse(
@@ -125,9 +120,7 @@ public function retrieveSingleRefundNotFoundTest(): void
self::assertTrue($throwException, 'Expect exception.');
}
- /**
- * @test
- */
+ #[Test]
public function retrieveEmptyRefundListTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/Integration/Request/ShopInfoTest.php b/tests/Integration/Request/ShopInfoTest.php
index 097050b..26438ec 100644
--- a/tests/Integration/Request/ShopInfoTest.php
+++ b/tests/Integration/Request/ShopInfoTest.php
@@ -7,12 +7,11 @@
use Answear\Payum\PayU\Request\ShopRequestService;
use Answear\Payum\PayU\Tests\Util\FileTestUtil;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
class ShopInfoTest extends AbstractRequestTestCase
{
- /**
- * @test
- */
+ #[Test]
public function shopInfoTest(): void
{
$this->mockGuzzleResponse(
diff --git a/tests/MockGuzzleTrait.php b/tests/MockGuzzleTrait.php
index ce6fa85..4c17c5c 100644
--- a/tests/MockGuzzleTrait.php
+++ b/tests/MockGuzzleTrait.php
@@ -27,7 +27,7 @@ public function setupGuzzleClient(): Client
return new Client(['handler' => $handlerStack]);
}
- public function mockGuzzleResponse(Response $response)
+ public function mockGuzzleResponse(Response $response): void
{
$this->guzzleHandler->append($response);
}
diff --git a/tests/Unit/Action/CancelActionTest.php b/tests/Unit/Action/CancelActionTest.php
index 0f80e0d..f68fee3 100644
--- a/tests/Unit/Action/CancelActionTest.php
+++ b/tests/Unit/Action/CancelActionTest.php
@@ -12,13 +12,12 @@
use Answear\Payum\PayU\ValueObject\Response\OrderCanceledResponse;
use Answear\Payum\PayU\ValueObject\Response\OrderRetrieveResponse;
use Payum\Core\Request\Cancel;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class CancelActionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function successTest(): void
{
$action = $this->getCancelAction(
@@ -44,9 +43,7 @@ public function successTest(): void
$action->execute($request);
}
- /**
- * @test
- */
+ #[Test]
public function orderHasFinalStatusTest(): void
{
$this->expectException(CannotCancelPaymentException::class);
@@ -71,9 +68,7 @@ public function orderHasFinalStatusTest(): void
$action->execute($request);
}
- /**
- * @test
- */
+ #[Test]
public function emptyOrderIdInDetails(): void
{
$action = $this->getCancelAction(
@@ -103,9 +98,7 @@ public function emptyOrderIdInDetails(): void
$action->execute($request);
}
- /**
- * @test
- */
+ #[Test]
public function emptyOrderId(): void
{
$this->expectException(\InvalidArgumentException::class);
@@ -128,7 +121,7 @@ public function emptyOrderId(): void
private function getCancelAction(
?OrderCanceledResponse $orderCanceledResponse,
- ?OrderRetrieveResponse $retrieveOrderResponse
+ ?OrderRetrieveResponse $retrieveOrderResponse,
): CancelAction {
$orderRequestService = $this->createMock(OrderRequestService::class);
if (null === $retrieveOrderResponse) {
diff --git a/tests/Unit/Exception/PayUExceptionTest.php b/tests/Unit/Exception/PayUExceptionTest.php
index 68207c6..447b215 100644
--- a/tests/Unit/Exception/PayUExceptionTest.php
+++ b/tests/Unit/Exception/PayUExceptionTest.php
@@ -8,14 +8,13 @@
use Answear\Payum\PayU\Exception\PayURequestException;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Psr7\Response;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
class PayUExceptionTest extends TestCase
{
- /**
- * @test
- */
+ #[Test]
public function emptyJsonNetworkException(): void
{
$exception = new PayUNetworkException('Exception', 0, $this->getPreviousException());
@@ -23,9 +22,7 @@ public function emptyJsonNetworkException(): void
self::assertNull($exception->response);
}
- /**
- * @test
- */
+ #[Test]
public function emptyJsonRequestException(): void
{
$exception = new PayURequestException('Exception', 0, $this->getPreviousException(''));
@@ -33,9 +30,7 @@ public function emptyJsonRequestException(): void
self::assertNull($exception->response);
}
- /**
- * @test
- */
+ #[Test]
public function jsonDecodedNetworkException(): void
{
$exception = new PayURequestException('Exception', 0, $this->getPreviousException('{"status":false}'));
@@ -43,9 +38,7 @@ public function jsonDecodedNetworkException(): void
self::assertSame(['status' => false], $exception->response);
}
- /**
- * @test
- */
+ #[Test]
public function jsonDecodedRequestException(): void
{
$exception = new PayURequestException('Exception', 0, $this->getPreviousException('{"status":true}'));
diff --git a/tests/Unit/PayUGatewayFactoryTest.php b/tests/Unit/PayUGatewayFactoryTest.php
index 5df41a2..2b3520d 100644
--- a/tests/Unit/PayUGatewayFactoryTest.php
+++ b/tests/Unit/PayUGatewayFactoryTest.php
@@ -16,17 +16,23 @@
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\LogicException;
use Payum\Core\HttpClientInterface;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class PayUGatewayFactoryTest extends TestCase
{
- /**
- * @test
- *
- * @dataProvider provideValidConfig
- */
- public function validConfigurationTest(array $config): void
+ #[Test]
+ public function validConfigurationTest(): void
{
+ $config = [
+ 'payum.action.capture' => $this->createMock(CaptureAction::class),
+ 'payum.action.refund' => $this->createMock(RefundAction::class),
+ 'payum.action.notify' => $this->createMock(NotifyAction::class),
+ 'payum.action.status' => $this->createMock(StatusAction::class),
+ 'payum.action.convert_payment' => $this->createMock(ConvertPaymentAction::class),
+ 'payum.action.sync_payment' => $this->createMock(SyncPaymentAction::class),
+ ];
+
$config['payum.http_client'] = $this->createMock(HttpClientInterface::class);
$config['httplug.message_factory'] = $this->createMock(MessageFactory::class);
$response = $this->getFactory()->createConfig($config);
@@ -49,13 +55,14 @@ public function validConfigurationTest(array $config): void
self::assertArrayHasKey('payum.action.convert_payment', $response);
}
- /**
- * @test
- *
- * @dataProvider provideInvalidConfig
- */
- public function invalidConfigurationTest(array $config, \Throwable $expectedException): void
+ #[Test]
+ public function invalidNoConfigConfigurationTest(): void
{
+ $config = [];
+ $expectedException = new LogicException(
+ 'The payum.action.capture, payum.action.refund, payum.action.notify, payum.action.status, payum.action.convert_payment, payum.action.sync_payment fields are required.'
+ );
+
$this->expectException(get_class($expectedException));
$this->expectExceptionMessage($expectedException->getMessage());
@@ -75,37 +82,35 @@ public function invalidConfigurationTest(array $config, \Throwable $expectedExce
);
}
- public function provideInvalidConfig(): iterable
+ #[Test]
+ public function invalidNoFieldsConfigurationTest(): void
{
- yield 'no configs' => [
- [],
- new LogicException('The payum.action.capture, payum.action.refund, payum.action.notify, payum.action.status, payum.action.convert_payment, payum.action.sync_payment fields are required.'),
+ $config = [
+ 'payum.action.capture' => $this->createMock(CaptureAction::class),
+ 'payum.action.refund' => $this->createMock(RefundAction::class),
+ 'payum.action.notify' => $this->createMock(NotifyAction::class),
+ 'payum.action.status' => $this->createMock(StatusAction::class),
+ 'payum.action.convert_payment' => $this->createMock(ConvertPaymentAction::class),
];
+ $expectedException = new LogicException('The payum.action.sync_payment fields are required.');
- yield 'no fields' => [
- [
- 'payum.action.capture' => $this->createMock(CaptureAction::class),
- 'payum.action.refund' => $this->createMock(RefundAction::class),
- 'payum.action.notify' => $this->createMock(NotifyAction::class),
- 'payum.action.status' => $this->createMock(StatusAction::class),
- 'payum.action.convert_payment' => $this->createMock(ConvertPaymentAction::class),
- ],
- new LogicException('The payum.action.sync_payment fields are required.'),
- ];
- }
+ $this->expectException(get_class($expectedException));
+ $this->expectExceptionMessage($expectedException->getMessage());
- public function provideValidConfig(): iterable
- {
- yield 'simple' => [
+ $config['payum.http_client'] = $this->createMock(HttpClientInterface::class);
+ $config['httplug.message_factory'] = $this->createMock(MessageFactory::class);
+ $response = $this->getFactory()->createConfig($config);
+
+ $this->assertInstanceOf(\Closure::class, $response['payum.api']);
+ $api = $response['payum.api'](new ArrayObject($response));
+ $this->assertInstanceOf(Api::class, $api);
+
+ self::assertSame(
+ [$config['configs']],
[
- 'payum.action.capture' => $this->createMock(CaptureAction::class),
- 'payum.action.refund' => $this->createMock(RefundAction::class),
- 'payum.action.notify' => $this->createMock(NotifyAction::class),
- 'payum.action.status' => $this->createMock(StatusAction::class),
- 'payum.action.convert_payment' => $this->createMock(ConvertPaymentAction::class),
- 'payum.action.sync_payment' => $this->createMock(SyncPaymentAction::class),
- ],
- ];
+ OverrideObjectPropertyUtil::getValue($api, 'configurations'),
+ ]
+ );
}
private function getFactory(): PayUGatewayFactory
diff --git a/tests/Unit/Service/SignatureValidatorTest.php b/tests/Unit/Service/SignatureValidatorTest.php
index 1ac6722..32de267 100644
--- a/tests/Unit/Service/SignatureValidatorTest.php
+++ b/tests/Unit/Service/SignatureValidatorTest.php
@@ -8,15 +8,14 @@
use Answear\Payum\PayU\Service\ConfigProvider;
use Answear\Payum\PayU\Service\SignatureValidator;
use Answear\Payum\PayU\Tests\Util\FileTestUtil;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class SignatureValidatorTest extends TestCase
{
- /**
- * @test
- *
- * @dataProvider provideSignatureData
- */
+ #[Test]
+ #[DataProvider('provideSignatureData')]
public function isValidTest(string $signatureHeader, string $data, $expectedIsValid): void
{
self::assertSame(
@@ -44,14 +43,14 @@ private function getService(): SignatureValidator
);
}
- public function provideSignatureData(): iterable
+ public static function provideSignatureData(): iterable
{
$notifyData = FileTestUtil::getFileContents(__DIR__ . '/orderNotifyData.json');
yield [
'signatureHeader' => 'sender=145227;algorithm=SHA-256;signature=5e1d044aaacd7e45f4d3a65ff2c3d294b83cada4177bb14c79fc62d9394f289a',
'data' => preg_replace('/\s+/', '', $notifyData),
- 'isValid' => true,
+ 'expectedIsValid' => true,
];
}
}