diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 437f8b1e..7390468a 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -3,7 +3,7 @@ name: Documentation on: push: branches: - - '*.*.x' + - "*.*.x" concurrency: group: documentation @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run phpdoc run: | docker run --rm -v $(pwd):/data phpdoc/phpdoc:3 -d ./src -t ./docs @@ -24,4 +24,4 @@ jobs: git config user.email "" git add docs/ git commit -m "Update phpdoc" || echo "No changes to commit" - git push \ No newline at end of file + git push diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e728070b..7e6b3546 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,21 +3,20 @@ name: Test on: [push, pull_request] jobs: - phpunit10: runs-on: ubuntu-20.04 strategy: matrix: - php-version: ['8.1', '8.2', '8.3'] + php-version: ["8.1", "8.2", "8.3", "8.4"] steps: - - uses: actions/checkout@v3 - - uses: php-actions/composer@v5 + - uses: actions/checkout@v4 + - uses: php-actions/composer@v6 with: php_version: ${{ matrix.php-version }} args: --ignore-platform-reqs - - uses: php-actions/phpunit@v3 + - uses: php-actions/phpunit@v4 with: configuration: phpunit.xml php_version: ${{ matrix.php-version }} @@ -31,12 +30,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: php-actions/composer@v5 + - uses: actions/checkout@v4 + - uses: php-actions/composer@v6 with: php_version: 8.1 php_extensions: bcmath gmp xdebug - name: Install PHP_CodeSniffer run: | curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar - php phpcs.phar src --standard=ruleset.xml \ No newline at end of file + php phpcs.phar src --standard=ruleset.xml diff --git a/composer.json b/composer.json index 8abe1e4e..38cd6a61 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,13 @@ ], "homepage": "https://github.com/bitpay/php-bitpay-client-v2", "require": { - "php": "^8.1 || ^8.2 || ^8.3", + "php": "^8.1 || ^8.2 || ^8.3 || ^8.4", "ext-json": "*", "ext-reflection": "*", - "bitpay/key-utils": "^2.0", + "bitpay/key-utils": "^2.1", "guzzlehttp/guzzle": "^7.0", - "symfony/yaml": "^5.4 || ^6.0 || ^7.0", - "netresearch/jsonmapper": "^4.1", + "symfony/yaml": "^6.0 || ^7.0", + "netresearch/jsonmapper": "^5.0", "symfony/console": "^6.0" }, "authors": [ @@ -28,7 +28,7 @@ } ], "require-dev": { - "phpunit/phpunit": "^9.0 || ^10.2.2" + "phpunit/phpunit": "^10.5.45 || ^11.5.7 || ^12.0.2" }, "scripts": { "setup": [ diff --git a/composer.lock b/composer.lock index 3b85958a..25325b48 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "85a8f63fea9f82ef23028c3bfee37148", + "content-hash": "6c7eb342f7b7b810ebc95d10637af351", "packages": [ { "name": "bitpay/key-utils", - "version": "2.0.6", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/bitpay/bitpay-php-keyutils.git", - "reference": "814cf4623c015da6c6a51e45b60ac4f24470a716" + "reference": "fdf77f96b9269615b9223559d28ac6358a276c03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bitpay/bitpay-php-keyutils/zipball/814cf4623c015da6c6a51e45b60ac4f24470a716", - "reference": "814cf4623c015da6c6a51e45b60ac4f24470a716", + "url": "https://api.github.com/repos/bitpay/bitpay-php-keyutils/zipball/fdf77f96b9269615b9223559d28ac6358a276c03", + "reference": "fdf77f96b9269615b9223559d28ac6358a276c03", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ "ext-iconv": "*", "ext-json": "*", "ext-openssl": "*", - "php": "^8.1 || ^8.2 || ^8.3" + "php": "^8.1 || ^8.2 || ^8.3 || ^8.4" }, "require-dev": { "phpunit/phpunit": "10.5.45" @@ -53,9 +53,9 @@ "description": "BitPay Utils pack for cryptography", "support": { "issues": "https://github.com/bitpay/bitpay-php-keyutils/issues", - "source": "https://github.com/bitpay/bitpay-php-keyutils/tree/2.0.6" + "source": "https://github.com/bitpay/bitpay-php-keyutils/tree/2.1.0" }, - "time": "2025-02-10T15:17:09+00:00" + "time": "2025-02-11T14:15:21+00:00" }, { "name": "guzzlehttp/guzzle", @@ -384,16 +384,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v4.5.0", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5" + "reference": "8c64d8d444a5d764c641ebe97e0e3bc72b25bf6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8e76efb98ee8b6afc54687045e1b8dba55ac76e5", - "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8c64d8d444a5d764c641ebe97e0e3bc72b25bf6c", + "reference": "8c64d8d444a5d764c641ebe97e0e3bc72b25bf6c", "shasum": "" }, "require": { @@ -429,9 +429,9 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.5.0" + "source": "https://github.com/cweiske/jsonmapper/tree/v5.0.0" }, - "time": "2024-09-08T10:13:13+00:00" + "time": "2024-09-08T10:20:00+00:00" }, { "name": "psr/container", @@ -3043,7 +3043,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.1 || ^8.2 || ^8.3", + "php": "^8.1 || ^8.2 || ^8.3 || ^8.4", "ext-json": "*", "ext-reflection": "*" }, diff --git a/docs/classes/BitPaySDK-Client.html b/docs/classes/BitPaySDK-Client.html index 48c7fcb0..f20185f5 100644 --- a/docs/classes/BitPaySDK-Client.html +++ b/docs/classes/BitPaySDK-Client.html @@ -2253,7 +2253,7 @@

public - getBills([string $status = null ]) : array<string|int, Bill> + getBills([string|null $status = null ]) : array<string|int, Bill>
@@ -2263,7 +2263,7 @@

Parameters
$status - : string + : string|null = null
diff --git a/docs/classes/BitPaySDK-Env.html b/docs/classes/BitPaySDK-Env.html index 23f609f8..d7c0faeb 100644 --- a/docs/classes/BitPaySDK-Env.html +++ b/docs/classes/BitPaySDK-Env.html @@ -216,7 +216,7 @@

BITPAY_PLUGIN_INFO -  = "BitPay_PHP_Client_v9.1.6" +  = "BitPay_PHP_Client_v9.2.0"
@@ -371,7 +371,7 @@

public mixed BITPAY_PLUGIN_INFO - = "BitPay_PHP_Client_v9.1.6" + = "BitPay_PHP_Client_v9.2.0" diff --git a/docs/classes/BitPaySDK-Model-Payout-Payout.html b/docs/classes/BitPaySDK-Model-Payout-Payout.html index 507b460c..364d3b15 100644 --- a/docs/classes/BitPaySDK-Model-Payout-Payout.html +++ b/docs/classes/BitPaySDK-Model-Payout-Payout.html @@ -151,7 +151,7 @@

@@ -509,7 +509,7 @@

getShopperId() -  : string +  : string|null
Gets shopper id.
@@ -740,7 +740,7 @@

@@ -776,7 +776,7 @@

@@ -812,7 +812,7 @@

@@ -848,7 +848,7 @@

@@ -884,7 +884,7 @@

@@ -920,7 +920,7 @@

@@ -956,7 +956,7 @@

@@ -992,7 +992,7 @@

@@ -1028,7 +1028,7 @@

@@ -1064,7 +1064,7 @@

@@ -1100,7 +1100,7 @@

@@ -1136,7 +1136,7 @@

@@ -1172,7 +1172,7 @@

@@ -1208,7 +1208,7 @@

@@ -1244,7 +1244,7 @@

@@ -1280,7 +1280,7 @@

@@ -1316,7 +1316,7 @@

@@ -1352,7 +1352,7 @@

@@ -1388,7 +1388,7 @@

@@ -1424,7 +1424,7 @@

@@ -1460,7 +1460,7 @@

@@ -1496,7 +1496,7 @@

@@ -1532,7 +1532,7 @@

@@ -1573,7 +1573,7 @@

@@ -1642,7 +1642,7 @@

@@ -1687,7 +1687,7 @@

@@ -1727,7 +1727,7 @@

@@ -1766,7 +1766,7 @@

@@ -1805,7 +1805,7 @@

@@ -1844,7 +1844,7 @@

@@ -1883,7 +1883,7 @@

@@ -1943,7 +1943,7 @@

@@ -1986,7 +1986,7 @@

@@ -2025,7 +2025,7 @@

@@ -2064,7 +2064,7 @@

@@ -2103,7 +2103,7 @@

@@ -2145,7 +2145,7 @@

@@ -2205,7 +2205,7 @@

@@ -2246,7 +2246,7 @@

@@ -2287,7 +2287,7 @@

@@ -2328,7 +2328,7 @@

@@ -2367,7 +2367,7 @@

@@ -2410,7 +2410,7 @@

@@ -2449,7 +2449,7 @@

@@ -2457,7 +2457,7 @@

public - getShopperId() : string + getShopperId() : string|null
@@ -2477,7 +2477,7 @@

Return values
- string + string|null
@@ -2495,7 +2495,7 @@

@@ -2551,7 +2551,7 @@

@@ -2595,7 +2595,7 @@

@@ -2634,7 +2634,7 @@

@@ -2675,7 +2675,7 @@

@@ -2721,7 +2721,7 @@

@@ -2766,7 +2766,7 @@

@@ -2811,7 +2811,7 @@

@@ -2871,7 +2871,7 @@

@@ -2916,7 +2916,7 @@

@@ -2963,7 +2963,7 @@

@@ -3012,7 +3012,7 @@

@@ -3057,7 +3057,7 @@

@@ -3102,7 +3102,7 @@

@@ -3147,7 +3147,7 @@

@@ -3194,7 +3194,7 @@

@@ -3242,7 +3242,7 @@

@@ -3306,7 +3306,7 @@

@@ -3353,7 +3353,7 @@

@@ -3400,7 +3400,7 @@

@@ -3447,7 +3447,7 @@

@@ -3492,7 +3492,7 @@

@@ -3541,7 +3541,7 @@

@@ -3586,7 +3586,7 @@

@@ -3638,7 +3638,7 @@

@@ -3700,7 +3700,7 @@

@@ -3748,7 +3748,7 @@

@@ -3784,7 +3784,7 @@

throws
- PayoutException + BitPayGenericException
@@ -3808,7 +3808,7 @@

diff --git a/docs/classes/BitPaySDK-Model-Settlement-Settlement.html b/docs/classes/BitPaySDK-Model-Settlement-Settlement.html index 5a0bd5b3..a625a972 100644 --- a/docs/classes/BitPaySDK-Model-Settlement-Settlement.html +++ b/docs/classes/BitPaySDK-Model-Settlement-Settlement.html @@ -151,7 +151,7 @@

@@ -611,7 +611,7 @@

@@ -647,7 +647,7 @@

@@ -683,7 +683,7 @@

@@ -719,7 +719,7 @@

@@ -755,7 +755,7 @@

@@ -791,7 +791,7 @@

@@ -827,7 +827,7 @@

@@ -863,7 +863,7 @@

@@ -899,7 +899,7 @@

@@ -935,7 +935,7 @@

@@ -971,7 +971,7 @@

@@ -1007,7 +1007,7 @@

@@ -1043,7 +1043,7 @@

@@ -1079,7 +1079,7 @@

@@ -1115,7 +1115,7 @@

@@ -1151,7 +1151,7 @@

@@ -1187,7 +1187,7 @@

@@ -1228,7 +1228,7 @@

@@ -1262,7 +1262,7 @@

@@ -1303,7 +1303,7 @@

@@ -1344,7 +1344,7 @@

@@ -1386,7 +1386,7 @@

@@ -1427,7 +1427,7 @@

@@ -1468,7 +1468,7 @@

@@ -1509,7 +1509,7 @@

@@ -1550,7 +1550,7 @@

@@ -1592,7 +1592,7 @@

@@ -1634,7 +1634,7 @@

@@ -1673,7 +1673,7 @@

@@ -1716,7 +1716,7 @@

@@ -1755,7 +1755,7 @@

@@ -1794,7 +1794,7 @@

@@ -1836,7 +1836,7 @@

@@ -1877,7 +1877,7 @@

@@ -1919,7 +1919,7 @@

@@ -1958,7 +1958,7 @@

@@ -2005,7 +2005,7 @@

@@ -2052,7 +2052,7 @@

@@ -2100,7 +2100,7 @@

@@ -2147,7 +2147,7 @@

@@ -2194,7 +2194,7 @@

@@ -2241,7 +2241,7 @@

@@ -2288,7 +2288,7 @@

@@ -2327,7 +2327,7 @@

throws
- SettlementException + BitPayGenericException
@@ -2351,7 +2351,7 @@

@@ -2399,7 +2399,7 @@

@@ -2444,7 +2444,7 @@

@@ -2493,7 +2493,7 @@

@@ -2538,7 +2538,7 @@

@@ -2583,7 +2583,7 @@

@@ -2631,7 +2631,7 @@

@@ -2678,7 +2678,7 @@

@@ -2717,7 +2717,7 @@

throws
- SettlementException + BitPayGenericException
@@ -2741,7 +2741,7 @@

@@ -2786,7 +2786,7 @@

diff --git a/docs/classes/BitPaySDK-PosClient.html b/docs/classes/BitPaySDK-PosClient.html index 2ae0aa88..0f30c303 100644 --- a/docs/classes/BitPaySDK-PosClient.html +++ b/docs/classes/BitPaySDK-PosClient.html @@ -2468,7 +2468,7 @@

public - getBills([string $status = null ]) : array<string|int, Bill> + getBills([string|null $status = null ]) : array<string|int, Bill>
@@ -2478,7 +2478,7 @@

Parameters
$status - : string + : string|null = null
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index bd3bc1c7..193a44c2 100644 --- a/phpdoc.dist.xml +++ b/phpdoc.dist.xml @@ -10,7 +10,7 @@ docs - + src diff --git a/setup/ConfigGenerator.php b/setup/ConfigGenerator.php index 4eff3590..6c50f25f 100644 --- a/setup/ConfigGenerator.php +++ b/setup/ConfigGenerator.php @@ -90,7 +90,7 @@ function selectTokens(OutputInterface $output, mixed $helper, InputInterface $in $shouldGenerateMerchant = true; $shouldGeneratePayout = true; } - + return [$shouldGenerateMerchant, $shouldGeneratePayout]; } @@ -144,6 +144,9 @@ function getPublicKey(string $privateKeyLocation, string $password): PublicKey { $storageEngine = new EncryptedFilesystemStorage($password); try { // Use the EncryptedFilesystemStorage to load the Merchant's encrypted private key with the Master Password. + /** + * @var PrivateKey + */ $privateKey = $storageEngine->load($privateKeyLocation); } catch (\Exception $ex) { // Check if the loaded keys is a valid key @@ -255,13 +258,13 @@ function getPayoutToken( ->setHelp($help) ->setCode(function (InputInterface $input, OutputInterface $output): int { $helper = $this->getHelper('question'); - + try { $env = getEnv($output, $helper, $input); $apiUrl = $env === 'P' ? 'https://bitpay.com' : 'https://test.bitpay.com'; $password = getPrivateKeyPassword($helper, $input, $output); $privateKeyLocation = getPrivateKeyLocation($helper, $input, $output); - + [$shouldGenerateMerchant, $shouldGeneratePayout] = selectTokens($output, $helper, $input); $publicKey = getPublicKey($privateKeyLocation, $password); $sin = getSin($publicKey); diff --git a/src/BitPaySDK/Client.php b/src/BitPaySDK/Client.php index e738938c..cb91d1e2 100644 --- a/src/BitPaySDK/Client.php +++ b/src/BitPaySDK/Client.php @@ -257,10 +257,10 @@ public function getInvoiceByGuid( public function getInvoices( string $dateStart, string $dateEnd, - string $status = null, - string $orderId = null, - int $limit = null, - int $offset = null + ?string $status = null, + ?string $orderId = null, + ?int $limit = null, + ?int $offset = null ): array { $invoiceClient = $this->getInvoiceClient(); @@ -581,7 +581,7 @@ public function getBill(string $billId, string $facade = Facade::MERCHANT, bool * @throws BitPayApiException * @throws BitPayGenericException */ - public function getBills(string $status = null): array + public function getBills(?string $status = null): array { $billClient = $this->getBillClient(); @@ -762,7 +762,7 @@ public function getPayoutRecipient(string $recipientId): PayoutRecipient * @throws BitPayApiException * @throws BitPayGenericException */ - public function getPayoutRecipients(string $status = null, int $limit = null, int $offset = null): array + public function getPayoutRecipients(?string $status = null, ?int $limit = null, ?int $offset = null): array { $payoutRecipientsClient = $this->getPayoutRecipientsClient(); @@ -874,12 +874,12 @@ public function getPayout(string $payoutId): Payout * @throws BitPayApiException */ public function getPayouts( - string $startDate = null, - string $endDate = null, - string $status = null, - string $reference = null, - int $limit = null, - int $offset = null + ?string $startDate = null, + ?string $endDate = null, + ?string $status = null, + ?string $reference = null, + ?int $limit = null, + ?int $offset = null ): array { $payoutClient = $this->getPayoutClient(); @@ -972,9 +972,9 @@ public function getSettlements( string $currency, string $dateStart, string $dateEnd, - string $status = null, - int $limit = null, - int $offset = null + ?string $status = null, + ?int $limit = null, + ?int $offset = null ): array { $settlementsClient = $this->getSettlementClient(); diff --git a/src/BitPaySDK/Client/BillClient.php b/src/BitPaySDK/Client/BillClient.php index 539bdfae..0eac0208 100644 --- a/src/BitPaySDK/Client/BillClient.php +++ b/src/BitPaySDK/Client/BillClient.php @@ -108,7 +108,7 @@ public function get(string $billId, string $facade = Facade::MERCHANT, bool $sig * @throws BitPayApiException * @throws BitPayGenericException */ - public function getBills(string $status = null): array + public function getBills(?string $status = null): array { $params = []; $params["token"] = $this->tokenCache->getTokenByFacade(Facade::MERCHANT); diff --git a/src/BitPaySDK/Client/InvoiceClient.php b/src/BitPaySDK/Client/InvoiceClient.php index 4cab39ac..477442c2 100644 --- a/src/BitPaySDK/Client/InvoiceClient.php +++ b/src/BitPaySDK/Client/InvoiceClient.php @@ -210,10 +210,10 @@ public function getByGuid( public function getInvoices( string $dateStart, string $dateEnd, - string $status = null, - string $orderId = null, - int $limit = null, - int $offset = null + ?string $status = null, + ?string $orderId = null, + ?int $limit = null, + ?int $offset = null ): array { $params = []; $params["token"] = $this->tokenCache->getTokenByFacade(Facade::MERCHANT); diff --git a/src/BitPaySDK/Client/PayoutClient.php b/src/BitPaySDK/Client/PayoutClient.php index ebbc3f69..8fa619a3 100644 --- a/src/BitPaySDK/Client/PayoutClient.php +++ b/src/BitPaySDK/Client/PayoutClient.php @@ -125,12 +125,12 @@ public function get(string $payoutId): Payout * @throws BitPayGenericException */ public function getPayouts( - string $startDate = null, - string $endDate = null, - string $status = null, - string $reference = null, - int $limit = null, - int $offset = null + ?string $startDate = null, + ?string $endDate = null, + ?string $status = null, + ?string $reference = null, + ?int $limit = null, + ?int $offset = null ): array { $params = []; $params["token"] = $this->tokenCache->getTokenByFacade(Facade::PAYOUT); diff --git a/src/BitPaySDK/Client/PayoutRecipientsClient.php b/src/BitPaySDK/Client/PayoutRecipientsClient.php index dd8830bf..49b28f89 100644 --- a/src/BitPaySDK/Client/PayoutRecipientsClient.php +++ b/src/BitPaySDK/Client/PayoutRecipientsClient.php @@ -121,7 +121,7 @@ public function get(string $recipientId): PayoutRecipient * @throws BitPayApiException * @throws BitPayGenericException */ - public function getPayoutRecipients(string $status = null, int $limit = null, int $offset = null): array + public function getPayoutRecipients(?string $status = null, ?int $limit = null, ?int $offset = null): array { $params = []; $params["token"] = $this->tokenCache->getTokenByFacade(Facade::PAYOUT); diff --git a/src/BitPaySDK/Client/RefundClient.php b/src/BitPaySDK/Client/RefundClient.php index 7e60fddc..9b8502a4 100644 --- a/src/BitPaySDK/Client/RefundClient.php +++ b/src/BitPaySDK/Client/RefundClient.php @@ -80,7 +80,7 @@ public function create( bool $preview = false, bool $immediate = false, bool $buyerPaysRefundFee = false, - string $guid = null + ?string $guid = null ): Refund { $params = []; $params["token"] = $this->tokenCache->getTokenByFacade(Facade::MERCHANT); diff --git a/src/BitPaySDK/Client/SettlementClient.php b/src/BitPaySDK/Client/SettlementClient.php index 6f9700b5..2668e3ba 100644 --- a/src/BitPaySDK/Client/SettlementClient.php +++ b/src/BitPaySDK/Client/SettlementClient.php @@ -72,9 +72,9 @@ public function getSettlements( string $currency, string $dateStart, string $dateEnd, - string $status = null, - int $limit = null, - int $offset = null + ?string $status = null, + ?int $limit = null, + ?int $offset = null ): array { $status = $status ?? ""; $limit = $limit ?? 100; diff --git a/src/BitPaySDK/Env.php b/src/BitPaySDK/Env.php index 95a8d86f..2c1a9e09 100644 --- a/src/BitPaySDK/Env.php +++ b/src/BitPaySDK/Env.php @@ -17,7 +17,7 @@ interface Env public const TEST_URL = "https://test.bitpay.com/"; public const PROD_URL = "https://bitpay.com/"; public const BITPAY_API_VERSION = "2.0.0"; - public const BITPAY_PLUGIN_INFO = "BitPay_PHP_Client_v9.1.6"; + public const BITPAY_PLUGIN_INFO = "BitPay_PHP_Client_v9.2.0"; public const BITPAY_API_FRAME = "std"; public const BITPAY_API_FRAME_VERSION = "1.0.0"; } diff --git a/src/BitPaySDK/Model/Bill/Bill.php b/src/BitPaySDK/Model/Bill/Bill.php index 65ebd35e..6189c4ee 100644 --- a/src/BitPaySDK/Model/Bill/Bill.php +++ b/src/BitPaySDK/Model/Bill/Bill.php @@ -50,10 +50,10 @@ class Bill * @param array|null $items array The list of items to add to this bill. */ public function __construct( - string $number = null, - string $currency = null, - string $email = null, - array $items = null + ?string $number = null, + ?string $currency = null, + ?string $email = null, + ?array $items = null ) { $this->number = $number; $this->currency = $currency; diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index 586f37dd..c0d1319f 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -93,7 +93,7 @@ class Invoice * @param float|null $price float The amount for which the invoice will be created. * @param string|null $currency string three digit currency type used to compute the invoice bitcoin amount. */ - public function __construct(float $price = null, string $currency = null) + public function __construct(?float $price = null, ?string $currency = null) { $this->price = $price; $this->currency = $currency; diff --git a/src/BitPaySDK/Model/Payout/Payout.php b/src/BitPaySDK/Model/Payout/Payout.php index e43c61eb..d23e437e 100644 --- a/src/BitPaySDK/Model/Payout/Payout.php +++ b/src/BitPaySDK/Model/Payout/Payout.php @@ -10,6 +10,7 @@ use BitPaySDK\Exceptions\BitPayExceptionProvider; use BitPaySDK\Exceptions\BitPayValidationException; +use BitPaySDK\Exceptions\BitPayGenericException; use BitPaySDK\Model\Currency; /** @@ -58,7 +59,7 @@ class Payout * default to the active ledger currency on your account, e.g. your settlement * currency. */ - public function __construct(float $amount = null, string $currency = null, string $ledgerCurrency = null) + public function __construct(?float $amount = null, ?string $currency = null, ?string $ledgerCurrency = null) { $this->amount = $amount; $this->currency = $currency; @@ -376,7 +377,7 @@ public function setRecipientId(string $recipientId): void * BitPay personal accounts before completing the payment. * This can allow merchants to monitor the activity of a customer (deposits and payouts). * - * @return string + * @return string|null */ public function getShopperId(): ?string { @@ -641,13 +642,13 @@ public function getTransactions(): array * Sets transactions. Contains the cryptocurrency transaction details for the executed payout request. * * @param PayoutTransaction[] $transactions - * @throws PayoutException + * @throws BitPayGenericException */ public function setTransactions(array $transactions): void { foreach ($transactions as $transaction) { if (!$transaction instanceof PayoutTransaction) { - throw new PayoutException( + BitPayExceptionProvider::throwGenericExceptionWithMessage( 'Wrong type of transactions array. They should contains only PayoutTransaction objects' ); } diff --git a/src/BitPaySDK/Model/Payout/PayoutRecipient.php b/src/BitPaySDK/Model/Payout/PayoutRecipient.php index 997d860f..e57265e3 100644 --- a/src/BitPaySDK/Model/Payout/PayoutRecipient.php +++ b/src/BitPaySDK/Model/Payout/PayoutRecipient.php @@ -33,7 +33,7 @@ class PayoutRecipient * @param string|null $notificationURL string URL to which BitPay sends webhook notifications to inform * the merchant about the status of a given recipient. HTTPS is mandatory (Optional). */ - public function __construct(string $email = null, string $label = null, string $notificationURL = null) + public function __construct(?string $email = null, ?string $label = null, ?string $notificationURL = null) { $this->email = $email; $this->label = $label; diff --git a/src/BitPaySDK/Model/Settlement/Settlement.php b/src/BitPaySDK/Model/Settlement/Settlement.php index fd6a7b60..43d0204b 100644 --- a/src/BitPaySDK/Model/Settlement/Settlement.php +++ b/src/BitPaySDK/Model/Settlement/Settlement.php @@ -8,6 +8,9 @@ namespace BitPaySDK\Model\Settlement; +use BitPaySDK\Exceptions\BitPayExceptionProvider; +use BitPaySDK\Exceptions\BitPayGenericException; + /** * Settlement data object. * @@ -344,13 +347,15 @@ public function getWithHoldings(): array * from this settlement. Each withholding is a JSON object containing a code, amount and description field. * * @param WithHoldings[] $withHoldings - * @throws SettlementException + * @throws BitPayGenericException */ public function setWithHoldings(array $withHoldings): void { foreach ($withHoldings as $withHolding) { if (!$withHolding instanceof WithHoldings) { - throw new SettlementException('Array should contains only WithHoldings objects'); + BitPayExceptionProvider::throwGenericExceptionWithMessage( + 'Array should contains only WithHoldings objects' + ); } } @@ -421,13 +426,15 @@ public function getLedgerEntries(): array * A description of all ledger codes can be found * * @param SettlementLedgerEntry[] $ledgerEntries - * @throws SettlementException + * @throws BitPayGenericException */ public function setLedgerEntries(array $ledgerEntries): void { foreach ($ledgerEntries as $ledgerEntry) { if (!$ledgerEntry instanceof SettlementLedgerEntry) { - throw new SettlementException('Array should contains only SettlementLedgerEntry objects'); + BitPayExceptionProvider::throwGenericExceptionWithMessage( + 'Array should contains only SettlementLedgerEntry objects' + ); } } $this->ledgerEntries = $ledgerEntries; diff --git a/src/BitPaySDK/Util/RESTcli/RESTcli.php b/src/BitPaySDK/Util/RESTcli/RESTcli.php index bd70a444..f18b63ca 100644 --- a/src/BitPaySDK/Util/RESTcli/RESTcli.php +++ b/src/BitPaySDK/Util/RESTcli/RESTcli.php @@ -188,7 +188,7 @@ public function post($uri, array $formData = [], bool $signatureRequired = true) * @throws BitPayApiException * @throws BitPayGenericException */ - public function get($uri, array $parameters = null, bool $signatureRequired = true): string + public function get($uri, ?array $parameters = null, bool $signatureRequired = true): string { try { $fullURL = $this->baseUrl . $uri; @@ -251,7 +251,7 @@ public function get($uri, array $parameters = null, bool $signatureRequired = tr * @throws BitPayApiException * @throws BitPayGenericException */ - public function delete($uri, array $parameters = null): string + public function delete($uri, ?array $parameters = null): string { try { $fullURL = $this->baseUrl . $uri; diff --git a/test/functional/BitPaySDK/AbstractClientTestCase.php b/test/functional/BitPaySDK/AbstractClientTestCase.php index 02e625eb..2bdf85e7 100644 --- a/test/functional/BitPaySDK/AbstractClientTestCase.php +++ b/test/functional/BitPaySDK/AbstractClientTestCase.php @@ -17,6 +17,8 @@ abstract class AbstractClientTestCase extends TestCase */ public function setUp(): void { - $this->client = Client::createWithFile(Config::FUNCTIONAL_TEST_PATH . DIRECTORY_SEPARATOR . Config::BITPAY_CONFIG_FILE); + $this->client = Client::createWithFile( + Config::FUNCTIONAL_TEST_PATH . DIRECTORY_SEPARATOR . Config::BITPAY_CONFIG_FILE + ); } } diff --git a/test/functional/BitPaySDK/BillClientTest.php b/test/functional/BitPaySDK/BillClientTest.php index 18399235..27770029 100644 --- a/test/functional/BitPaySDK/BillClientTest.php +++ b/test/functional/BitPaySDK/BillClientTest.php @@ -1,7 +1,9 @@ expectException(BitPayGenericException::class); - $this->client->createBill($bill, "Validation errors occurred: Valid email required if emailBill is not set to false."); + $this->client->createBill( + $bill, + "Validation errors occurred: Valid email required if emailBill is not set to false." + ); } public function testGetBill(): void @@ -102,4 +107,4 @@ private function getBillExample(): Bill return new Bill("bill1234-ABCD", Currency::USD, "", $items); } -} \ No newline at end of file +} diff --git a/test/functional/BitPaySDK/Config.php b/test/functional/BitPaySDK/Config.php index f644ac6b..311264b7 100644 --- a/test/functional/BitPaySDK/Config.php +++ b/test/functional/BitPaySDK/Config.php @@ -1,4 +1,5 @@ expectException(BitPayApiException::class); $this->client->getLedgerEntries($currency, $startDate, $endDate); } -} \ No newline at end of file +} diff --git a/test/functional/BitPaySDK/PayoutClientTest.php b/test/functional/BitPaySDK/PayoutClientTest.php index f6fd02d5..828715b3 100644 --- a/test/functional/BitPaySDK/PayoutClientTest.php +++ b/test/functional/BitPaySDK/PayoutClientTest.php @@ -1,7 +1,9 @@ getCode()); self::assertEquals('US Dollar', $rate->getName()); } -} \ No newline at end of file +} diff --git a/test/functional/BitPaySDK/RefundClientTest.php b/test/functional/BitPaySDK/RefundClientTest.php index 26982c4b..8792586a 100644 --- a/test/functional/BitPaySDK/RefundClientTest.php +++ b/test/functional/BitPaySDK/RefundClientTest.php @@ -1,7 +1,9 @@ getCurrency()); self::assertEquals($status, $settlement->getStatus()); } -} \ No newline at end of file +} diff --git a/test/functional/BitPaySDK/WalletClientTest.php b/test/functional/BitPaySDK/WalletClientTest.php index da39f5dc..a849c307 100644 --- a/test/functional/BitPaySDK/WalletClientTest.php +++ b/test/functional/BitPaySDK/WalletClientTest.php @@ -1,7 +1,9 @@ createMock(Tokens::class); $result = $this->getTestedClassInstance()::createWithData( Env::TEST, @@ -116,6 +123,9 @@ public function testWithData() */ public function testWithDataAndXBitPayPlatformInfoHeader() { + /** + * @var Tokens|MockObject + */ $tokens = $this->createMock(Tokens::class); $result = $this->getTestedClassInstance()::createWithData( Env::TEST, @@ -132,6 +142,9 @@ public function testWithDataAndXBitPayPlatformInfoHeader() public function testWithDataException() { $instance = $this->getTestedClassInstance(); + /** + * @var Tokens|MockObject + */ $tokens = $this->createMock(Tokens::class); $this->expectException(BitPayGenericException::class); @@ -219,6 +232,9 @@ public function testCreateBill() $expectedStatus = 'draft'; $expectedToken = 'qVVgRARN6fKtNZ7Tcq6qpoPBBE3NxdrmdMD883RyMK4Pf8EHENKVxCXhRwyynWveo'; + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $billToArray = [ 'id' => $expectedId, @@ -244,6 +260,9 @@ public function testCreateBill() public function testCreateBillException() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $restCliMock = $this->getRestCliMock(); $billToArray = [ @@ -267,6 +286,9 @@ public function testCreateBillException() public function testCreateBillShouldCatchRestCliException() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $billToArray = [ 'id' => 'testId', @@ -290,6 +312,9 @@ public function testCreateBillShouldCatchRestCliException() public function testCreateBillShouldCatchJsonMapperException() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $exampleBillId = 'testId'; $exampleBadResponse = file_get_contents(__DIR__ . '/jsonResponse/badResponse.json'); @@ -453,10 +478,7 @@ public function testGetBillsShouldCatchRestCliBitPayException() $client->getBills($status); } - /** - * @throws BitPayApiException - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetBillsShouldCatchRestCliException() { $params['token'] = self::MERCHANT_TOKEN; @@ -477,6 +499,9 @@ public function testGetBillsShouldCatchRestCliException() public function testUpdateBill() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getBill.json'); @@ -511,6 +536,9 @@ public function testUpdateBill() public function testUpdateBillShouldCatchRestCliBitPayException() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $params['token'] = self::MERCHANT_TOKEN; $exampleBillId = 'X6KJbe9RxAGWNReCwd1xRw'; @@ -544,6 +572,9 @@ public function testUpdateBillShouldCatchRestCliBitPayException() public function testUpdateBillShouldCatchRestCliException() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $params['token'] = self::MERCHANT_TOKEN; $exampleBillId = 'X6KJbe9RxAGWNReCwd1xRw'; @@ -577,6 +608,9 @@ public function testUpdateBillShouldCatchRestCliException() public function testUpdateBillShouldCatchJsonMapperException() { + /** + * @var Bill|MockObject + */ $billMock = $this->createMock(Bill::class); $params['token'] = self::MERCHANT_TOKEN; $exampleBillId = 'X6KJbe9RxAGWNReCwd1xRw'; @@ -810,6 +844,9 @@ public function testGetLedgersShouldCatchJsonMapperException() public function testSubmitPayoutRecipients() { + /** + * @var PayoutRecipients|MockObject + */ $payoutRecipientsMock = $this->createMock(PayoutRecipients::class); $exampleRecipientId = 'X6KJbe9RxAGWNReCwd1xRw'; $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/submitPayoutRecipientsResponse.json'); @@ -834,6 +871,9 @@ public function testSubmitPayoutRecipients() public function testSubmitPayoutRecipientsShouldCatchRestCliBitPayException() { + /** + * @var PayoutRecipients|MockObject + */ $payoutRecipientsMock = $this->createMock(PayoutRecipients::class); $exampleRecipientId = 'X6KJbe9RxAGWNReCwd1xRw'; $payoutRecipientToArray = [ @@ -857,6 +897,9 @@ public function testSubmitPayoutRecipientsShouldCatchRestCliBitPayException() public function testSubmitPayoutRecipientsShouldCatchRestCliException() { + /** + * @var PayoutRecipients|MockObject + */ $payoutRecipientsMock = $this->createMock(PayoutRecipients::class); $exampleRecipientId = 'X6KJbe9RxAGWNReCwd1xRw'; $payoutRecipientToArray = [ @@ -878,11 +921,12 @@ public function testSubmitPayoutRecipientsShouldCatchRestCliException() $client->submitPayoutRecipients($payoutRecipientsMock); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testSubmitPayoutRecipientsShouldCatchJsonMapperException() { + /** + * @var PayoutRecipients|MockObject + */ $payoutRecipientsMock = $this->createMock(PayoutRecipients::class); $exampleRecipientId = 'X6KJbe9RxAGWNReCwd1xRw'; $badResponse = file_get_contents(__DIR__ . '/jsonResponse/badResponse.json'); @@ -1084,6 +1128,9 @@ public function testUpdatePayoutRecipient() { $exampleRecipientId = 'X3icwc4tE8KJ5hEPNPpDXW'; $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getPayoutRecipient.json'); + /** + * @var PayoutRecipient|MockObject + */ $payoutRecipientMock = $this->createMock(PayoutRecipient::class); $payoutRecipientToArray = [ 'token' => self::MERCHANT_TOKEN, @@ -1106,6 +1153,9 @@ public function testUpdatePayoutRecipient() public function testUpdatePayoutRecipientShouldCatchRestCliBitPayException() { $exampleRecipientId = 'X3icwc4tE8KJ5hEPNPpDXW'; + /** + * @var PayoutRecipient|MockObject + */ $payoutRecipientMock = $this->createMock(PayoutRecipient::class); $payoutRecipientToArray = [ 'token' => self::MERCHANT_TOKEN, @@ -1128,6 +1178,9 @@ public function testUpdatePayoutRecipientShouldCatchRestCliBitPayException() public function testUpdatePayoutRecipientShouldCatchRestCliException() { $exampleRecipientId = 'X3icwc4tE8KJ5hEPNPpDXW'; + /** + * @var PayoutRecipient|MockObject + */ $payoutRecipientMock = $this->createMock(PayoutRecipient::class); $payoutRecipientToArray = [ 'token' => self::MERCHANT_TOKEN, @@ -1150,6 +1203,9 @@ public function testUpdatePayoutRecipientShouldCatchRestCliException() public function testUpdatePayoutRecipientShouldCatchJsonMapperException() { $exampleRecipientId = 'X3icwc4tE8KJ5hEPNPpDXW'; + /** + * @var PayoutRecipient|MockObject + */ $payoutRecipientMock = $this->createMock(PayoutRecipient::class); $badResponse = file_get_contents(__DIR__ . '/jsonResponse/badResponse.json'); @@ -1807,15 +1863,13 @@ public function testGetSettlementReconciliationReportShouldCatchJsonMapperExcept $client->getSettlementReconciliationReport($exampleId, $exampleToken); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetPayout() { $params['token'] = self::MERCHANT_TOKEN; $restCliMock = $this->getRestCliMock(); $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getPayout.json'); - $exampleResponseArray = json_decode($exampleResponse, true); + $exampleResponseArray = json_decode($exampleResponse, true); $payoutId = $exampleResponseArray['id']; $restCliMock->expects(self::once())->method('get') ->with("payouts/" . $payoutId, $params) @@ -1825,15 +1879,13 @@ public function testGetPayout() self::assertEquals(self::MERCHANT_TOKEN, $result->getToken()); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetPayoutShouldHandleRestCliBitPayException() { $params['token'] = self::MERCHANT_TOKEN; $restCliMock = $this->getRestCliMock(); $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getPayout.json'); - $exampleResponseArray = json_decode($exampleResponse, true); + $exampleResponseArray = json_decode($exampleResponse, true); $payoutId = $exampleResponseArray['id']; $restCliMock->expects(self::once())->method('get') ->with("payouts/" . $payoutId, $params) @@ -1849,7 +1901,7 @@ public function testGetPayoutShouldHandleJsonMapperException() $params['token'] = self::MERCHANT_TOKEN; $restCliMock = $this->getRestCliMock(); $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getPayout.json'); - $exampleResponseArray = json_decode($exampleResponse, true); + $exampleResponseArray = json_decode($exampleResponse, true); $payoutId = $exampleResponseArray['id']; $restCliMock->expects(self::once())->method('get') ->with("payouts/" . $payoutId, $params) @@ -1860,15 +1912,13 @@ public function testGetPayoutShouldHandleJsonMapperException() $client->getPayout($payoutId); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetPayoutShouldHandleRestCliException() { $params['token'] = self::MERCHANT_TOKEN; $restCliMock = $this->getRestCliMock(); $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getPayout.json'); - $exampleResponseArray = json_decode($exampleResponse, true); + $exampleResponseArray = json_decode($exampleResponse, true); $payoutId = $exampleResponseArray['id']; $restCliMock->expects(self::once())->method('get') ->with("payouts/" . $payoutId, $params) @@ -1904,9 +1954,7 @@ public function testGetPayouts() self::assertInstanceOf(Payout::class, $result[0]); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetPayoutsShouldHandleRestCliBitPayException() { $params = $this->getPayoutParams(); @@ -2027,6 +2075,9 @@ public function testCancelPayoutShouldCatchUnexistentPropertyError() public function testSubmitPayout() { + /** + * @var Payout|MockObject + */ $payoutMock = $this->createMock(Payout::class); $exampleCurrency = Currency::USD; $payoutBatchToArray = [ @@ -2048,6 +2099,9 @@ public function testSubmitPayout() public function testSubmitPayoutShouldCatchRestCliBitPayException() { + /** + * @var Payout|MockObject + */ $payoutMock = $this->createMock(Payout::class); $exampleCurrency = Currency::USD; $payoutBatchToArray = [ @@ -2068,6 +2122,9 @@ public function testSubmitPayoutShouldCatchRestCliBitPayException() public function testSubmitPayoutShouldCatchRestCliException() { + /** + * @var Payout|MockObject + */ $payoutMock = $this->createMock(Payout::class); $exampleCurrency = Currency::USD; $payoutBatchToArray = [ @@ -2088,6 +2145,9 @@ public function testSubmitPayoutShouldCatchRestCliException() public function testSubmitPayoutShouldCatchJsonMapperException() { + /** + * @var Payout|MockObject + */ $payoutMock = $this->createMock(Payout::class); $exampleCurrency = Currency::USD; $payoutBatchToArray = [ @@ -2296,7 +2356,10 @@ public function testCreateRefundShouldCatchJsonMapperException() { $params = $this->getInvoiceRefundParams(); $restCliMock = $this->getRestCliMock(); - $restCliMock->expects(self::once())->method('post')->with("refunds/", $params, true)->willReturn(self::CORRUPT_JSON_STRING); + $restCliMock->expects(self::once()) + ->method('post') + ->with("refunds/", $params, true) + ->willReturn(self::CORRUPT_JSON_STRING); $client = $this->getClient($restCliMock); $this->expectException(BitPayGenericException::class); @@ -2584,9 +2647,7 @@ public function testGetRefunds() self::assertInstanceOf(Refund::class, $result[0]); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundsShouldCatchRestCliBitPayException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2602,9 +2663,7 @@ public function testGetRefundsShouldCatchRestCliBitPayException() $client->getRefunds($exampleInvoiceId); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundsShouldCatchRestCliException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2621,9 +2680,7 @@ public function testGetRefundsShouldCatchRestCliException() $client->getRefunds($exampleInvoiceId); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundsShouldCatchJsonMapperException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2640,9 +2697,7 @@ public function testGetRefundsShouldCatchJsonMapperException() $client->getRefunds($exampleInvoiceId); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefund() { $params['token'] = self::MERCHANT_TOKEN; @@ -2663,9 +2718,7 @@ public function testGetRefund() self::assertInstanceOf(Refund::class, $result); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundShouldCatchRestCliBitPayException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2681,9 +2734,7 @@ public function testGetRefundShouldCatchRestCliBitPayException() $client->getRefund($exampleRefundId); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundShouldCatchRestCliException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2699,9 +2750,7 @@ public function testGetRefundShouldCatchRestCliException() $client->getRefund($exampleRefundId); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundShouldCatchRestCliJsonMapperException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2737,9 +2786,7 @@ public function testGetRefundByGuid() self::assertInstanceOf(Refund::class, $result); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundByGuidShouldCatchRestCliBitPayException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2755,9 +2802,7 @@ public function testGetRefundByGuidShouldCatchRestCliBitPayException() $client->getRefundByGuid($guid); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundByGuidShouldCatchRestCliException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2773,9 +2818,7 @@ public function testGetRefundByGuidShouldCatchRestCliException() $client->getRefundByGuid($guid); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testGetRefundByGuidShouldCatchRestCliJsonMapperException() { $params['token'] = self::MERCHANT_TOKEN; @@ -2791,9 +2834,7 @@ public function testGetRefundByGuidShouldCatchRestCliJsonMapperException() $client->getRefundByGuid($guid); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testSendRefundNotification() { $exampleRefundId = 'testId'; @@ -2810,9 +2851,7 @@ public function testSendRefundNotification() self::assertIsBool($result); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testSendRefundNotificationShouldCatchRestCliBitPayException() { $exampleRefundId = 'testId'; @@ -2829,9 +2868,7 @@ public function testSendRefundNotificationShouldCatchRestCliBitPayException() $client->sendRefundNotification($exampleRefundId, $exampleRefundToken); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testSendRefundNotificationShouldCatchRestCliException() { $exampleRefundId = 'testId'; @@ -2848,9 +2885,7 @@ public function testSendRefundNotificationShouldCatchRestCliException() $client->sendRefundNotification($exampleRefundId, $exampleRefundToken); } - /** - * @depends testWithFileJsonConfig - */ + #[Depends('testWithFileJsonConfig')] public function testSendRefundNotificationShouldCatchJsonMapperException() { $exampleRefundId = 'testId'; @@ -2868,14 +2903,14 @@ public function testSendRefundNotificationShouldCatchJsonMapperException() public function testGetInvoice() { - $exampleInvoiceObject = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + $exampleInvoiceObject = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $restCliMock = $this->getRestCliMock(); $restCliMock ->expects(self::once()) ->method("get") ->with('invoices/' . $exampleInvoiceObject->id, ['token' => self::MERCHANT_TOKEN], true) - ->willReturn(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + ->willReturn(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $testedObject = $this->getClient($restCliMock); $result = $testedObject->getInvoice($exampleInvoiceObject->id, Facade::MERCHANT, true); @@ -2887,14 +2922,14 @@ public function testGetInvoice() public function testGetInvoiceByGuid() { - $exampleInvoiceObject = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + $exampleInvoiceObject = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $restCliMock = $this->getRestCliMock(); $restCliMock ->expects(self::once()) ->method("get") ->with('invoices/guid/' . $exampleInvoiceObject->guid, ['token' => self::MERCHANT_TOKEN], true) - ->willReturn(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + ->willReturn(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $testedObject = $this->getClient($restCliMock); $result = $testedObject->getInvoiceByGuid($exampleInvoiceObject->guid, Facade::MERCHANT, true); @@ -2906,7 +2941,7 @@ public function testGetInvoiceByGuid() public function testGetInvoiceShouldCatchRestCliExceptions(): void { - $exampleInvoiceObject = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + $exampleInvoiceObject = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $restCliMock = $this->getRestCliMock(); $restCliMock @@ -2923,7 +2958,7 @@ public function testGetInvoiceShouldCatchRestCliExceptions(): void public function testGetInvoiceShouldCatchJsonMapperException() { - $exampleInvoiceObject = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + $exampleInvoiceObject = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $restCliMock = $this->getRestCliMock(); $restCliMock @@ -2965,7 +3000,8 @@ public function testGetInvoices() $params['status'], $params['orderId'], $params['limit'], - $params['offset']); + $params['offset'] + ); $responseToCompare = json_decode($successResponse, true); @@ -2974,9 +3010,7 @@ public function testGetInvoices() self::assertEquals($responseToCompare[0]['guid'], $result[0]->getGuid()); } - /** - * @dataProvider exceptionClassProvider - */ + #[DataProvider('exceptionClassProvider')] public function testGetInvoicesShouldCatchRestCliExceptions(Exception $exceptionClass) { $params = [ @@ -3005,7 +3039,8 @@ public function testGetInvoicesShouldCatchRestCliExceptions(Exception $exception $params['status'], $params['orderId'], $params['limit'], - $params['offset']); + $params['offset'] + ); } public function testGetInvoicesShouldCatchJsonMapperException() @@ -3036,7 +3071,8 @@ public function testGetInvoicesShouldCatchJsonMapperException() $params['status'], $params['orderId'], $params['limit'], - $params['offset']); + $params['offset'] + ); } public function testRequestInvoiceNotificationShouldReturnTrueOnSuccess() @@ -3099,9 +3135,12 @@ public function testCancelInvoice() 'token' => self::MERCHANT_TOKEN, 'forceCancel' => true ]; - $invoice = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + $invoice = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $invoice->isCancelled = true; - $restCliMock->expects(self::once())->method('delete')->with("invoices/" . self::TEST_INVOICE_ID, $params)->willReturn(json_encode($invoice)); + $restCliMock->expects(self::once()) + ->method('delete') + ->with("invoices/" . self::TEST_INVOICE_ID, $params) + ->willReturn(json_encode($invoice)); $testedObject = $this->getClient($restCliMock); $result = $testedObject->cancelInvoice(self::TEST_INVOICE_ID, $params['forceCancel']); @@ -3109,9 +3148,7 @@ public function testCancelInvoice() self::assertTrue($result->getIsCancelled()); } - /** - * @dataProvider exceptionClassProvider - */ + #[DataProvider('exceptionClassProvider')] public function testCancelInvoiceShouldCatchRestCliExceptions(Exception $exceptionClass) { $restCliMock = $this->getRestCliMock(); @@ -3151,7 +3188,7 @@ public function testCancelInvoiceByGuid() 'token' => self::MERCHANT_TOKEN, 'forceCancel' => true ]; - $invoice = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json')); + $invoice = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json')); $invoice->isCancelled = true; $restCliMock ->expects(self::once()) @@ -3167,9 +3204,7 @@ public function testCancelInvoiceByGuid() self::assertTrue($result->getIsCancelled()); } - /** - * @dataProvider exceptionClassProvider - */ + #[DataProvider('exceptionClassProvider')] public function testCancelInvoiceByGuidShouldCatchRestCliExceptions(Exception $exceptionClass) { $restCliMock = $this->getRestCliMock(); @@ -3226,9 +3261,7 @@ public function testPayInvoice() self::assertEquals('complete', $result->getStatus()); } - /** - * @dataProvider exceptionClassProvider - */ + #[DataProvider('exceptionClassProvider')] public function testPayInvoiceShouldCatchRestCliExceptions(Exception $exceptionClass) { $params['status'] = 'confirmed'; @@ -3264,7 +3297,10 @@ public function testPayInvoiceShouldCatchJsonMapperException() */ public function testCreateInvoice() { - $invoiceArray = json_decode(file_get_contents(__DIR__.'/jsonResponse/createInvoiceResponse.json'), true); + $invoiceArray = json_decode(file_get_contents(__DIR__ . '/jsonResponse/createInvoiceResponse.json'), true); + /** + * @var Invoice|MockObject + */ $invoiceMock = $this->createMock(Invoice::class); $invoiceMock->expects(self::once())->method('toArray')->willReturn($invoiceArray); @@ -3273,7 +3309,7 @@ public function testCreateInvoice() ->expects(self::once()) ->method('post') ->with('invoices', $invoiceArray, true) - ->willReturn(file_get_contents(__DIR__.'/jsonResponse/createInvoiceResponse.json')); + ->willReturn(file_get_contents(__DIR__ . '/jsonResponse/createInvoiceResponse.json')); $testedObject = $this->getClient($restCliMock); $result = $testedObject->createInvoice($invoiceMock); @@ -3282,12 +3318,13 @@ public function testCreateInvoice() self::assertEquals($invoiceArray['guid'], $result->getGuid()); } - /** - * @dataProvider exceptionClassProvider - */ + #[DataProvider('exceptionClassProvider')] public function testCreateInvoiceShouldCatchRestCliExceptions(Exception $exceptionClass) { - $invoiceArray = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json'), true); + $invoiceArray = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json'), true); + /** + * @var Invoice|MockObject + */ $invoiceMock = $this->createMock(Invoice::class); $invoiceMock->expects(self::once())->method('toArray')->willReturn($invoiceArray); @@ -3303,7 +3340,10 @@ public function testCreateInvoiceShouldCatchRestCliExceptions(Exception $excepti public function testCreateInvoiceShouldCatchJsonMapperException() { - $invoiceArray = json_decode(file_get_contents(__DIR__.'/jsonResponse/getInvoice.json'), true); + $invoiceArray = json_decode(file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json'), true); + /** + * @var Invoice|MockObject + */ $invoiceMock = $this->createMock(Invoice::class); $invoiceMock->expects(self::once())->method('toArray')->willReturn($invoiceArray); @@ -3331,7 +3371,7 @@ public function testUpdateInvoiceShouldCatchRestCliExceptions() $restCliMock ->expects(self::once()) ->method('update') - ->with('invoices/'. self::TEST_INVOICE_ID, $params) + ->with('invoices/' . self::TEST_INVOICE_ID, $params) ->willThrowException($this->getBitPayApiException()); $this->expectException(BitPayApiException::class); @@ -3359,7 +3399,7 @@ public function testUpdateInvoiceShouldCatchJsonMapperException() $restCliMock ->expects(self::once()) ->method('update') - ->with('invoices/'. self::TEST_INVOICE_ID, $params) + ->with('invoices/' . self::TEST_INVOICE_ID, $params) ->willReturn('corruptJson'); $this->expectException(BitPayGenericException::class); @@ -3423,12 +3463,12 @@ public function testUpdateInvoice() 'autoVerify' => false ]; - $successResponse = file_get_contents(__DIR__.'/jsonResponse/getInvoice.json'); + $successResponse = file_get_contents(__DIR__ . '/jsonResponse/getInvoice.json'); $restCliMock = $this->getRestCliMock(); $restCliMock ->expects(self::once()) ->method('update') - ->with('invoices/'. self::TEST_INVOICE_ID, $params) + ->with('invoices/' . self::TEST_INVOICE_ID, $params) ->willReturn($successResponse); $testedObject = $this->getClient($restCliMock); @@ -3453,7 +3493,7 @@ public function testGetSupportedWallets() ->expects(self::once()) ->method('get') ->with("supportedWallets/", null, false) - ->willReturn(file_get_contents(__DIR__.'/jsonResponse/getSupportedWalletsResponse.json')); + ->willReturn(file_get_contents(__DIR__ . '/jsonResponse/getSupportedWalletsResponse.json')); $client = $this->getClient($restCliMock); @@ -3523,6 +3563,9 @@ private function getClient(RESTcli $restCli) { $testToken = self::MERCHANT_TOKEN; + /** + * @var Tokens|MockObject + */ $tokens = $this->getMockBuilder(Tokens::class)->getMock(); $tokens->setMerchantToken($testToken); $tokens->method('getTokenByFacade')->willReturn($testToken); @@ -3532,13 +3575,19 @@ private function getClient(RESTcli $restCli) private function getTestedClassInstance(): Client { + /** + * @var RESTcli|MockObject + */ $restCli = $this->getMockBuilder(RESTcli::class)->disableOriginalConstructor()->getMock(); + /** + * @var Tokens|MockObject + */ $tokens = $this->getMockBuilder(Tokens::class)->disableOriginalConstructor()->getMock(); return new Client($restCli, $tokens); } - private function getRestCliMock() + private function getRestCliMock(): RestCli|MockObject { return $this->getMockBuilder(RESTcli::class)->disableOriginalConstructor()->getMock(); } @@ -3597,7 +3646,7 @@ private function refreshResourceClients(): void /** * @return BitPayApiException */ - private function getBitPayApiException(): BitPayApiException + private function getBitPayApiException(): BitPayApiException|MockObject { return $this->getMockBuilder(BitPayApiException::class)->disableOriginalConstructor()->getMock(); } diff --git a/test/unit/BitPaySDK/Exceptions/BitPayApiExceptionTest.php b/test/unit/BitPaySDK/Exceptions/BitPayApiExceptionTest.php index fd2c8255..8c78fc11 100644 --- a/test/unit/BitPaySDK/Exceptions/BitPayApiExceptionTest.php +++ b/test/unit/BitPaySDK/Exceptions/BitPayApiExceptionTest.php @@ -1,7 +1,9 @@ createClassObject(); $bill->setName($expectedName); - self::assertEquals($expectedName, $bill->getName()); + self::assertEquals($expectedName, $bill->getName()); } public function testGetAddress1() @@ -299,4 +299,4 @@ private function objectSetters(Bill $bill): void $bill->setId('1'); $bill->setMerchant('TestUser'); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Bill/ItemTest.php b/test/unit/BitPaySDK/Model/Bill/ItemTest.php index 71aa05e2..329cc60f 100644 --- a/test/unit/BitPaySDK/Model/Bill/ItemTest.php +++ b/test/unit/BitPaySDK/Model/Bill/ItemTest.php @@ -96,4 +96,4 @@ private function objectSetters(Item $item) $item->setPrice(1.2); $item->setQuantity(1); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Invoice/BuyerProvidedInfoTest.php b/test/unit/BitPaySDK/Model/Invoice/BuyerProvidedInfoTest.php index e319047c..5ad6e068 100644 --- a/test/unit/BitPaySDK/Model/Invoice/BuyerProvidedInfoTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/BuyerProvidedInfoTest.php @@ -143,4 +143,4 @@ private function objectSetters(BuyerProvidedInfo $buyerProvidedInfo) $buyerProvidedInfo->setSms('4445556666'); $buyerProvidedInfo->setSmsVerified(true); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php b/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php index 628b87a5..63abc25e 100644 --- a/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php @@ -13,6 +13,7 @@ use BitPaySDK\Model\Invoice\Shopper; use BitPaySDK\Model\Invoice\SupportedTransactionCurrencies; use BitPaySDK\Model\Invoice\UniversalCodes; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class InvoiceTest extends TestCase @@ -237,7 +238,10 @@ public function testGetForcedBuyerSelectedTransactionCurrency() $invoice = $this->createClassObject(); $invoice->setForcedBuyerSelectedTransactionCurrency($expectedForcedBuyerSelectedTransactionCurrency); - self::assertEquals($expectedForcedBuyerSelectedTransactionCurrency, $invoice->getForcedBuyerSelectedTransactionCurrency()); + self::assertEquals( + $expectedForcedBuyerSelectedTransactionCurrency, + $invoice->getForcedBuyerSelectedTransactionCurrency() + ); } /** @@ -261,6 +265,9 @@ public function testGetItemizedDetailsAsArray(): void public function testGetBuyer() { + /** + * @var Buyer|MockObject + */ $expectedBuyer = $this->getMockBuilder(Buyer::class)->getMock(); $invoice = $this->createClassObject(); @@ -401,6 +408,9 @@ public function testGetBuyerProvidedEmail() public function testGetBuyerProvidedInfo() { + /** + * @var BuyerProvidedInfo|MockObject + */ $expectedBuyerProvidedInfo = $this->getMockBuilder(BuyerProvidedInfo::class)->getMock(); $invoice = $this->createClassObject(); @@ -410,6 +420,9 @@ public function testGetBuyerProvidedInfo() public function testGetUniversalCodes() { + /** + * @var UniversalCodes|MockObject + */ $expectedUniversalCodes = $this->getMockBuilder(UniversalCodes::class)->getMock(); $invoice = $this->createClassObject(); @@ -419,7 +432,11 @@ public function testGetUniversalCodes() public function testGetSupportedTransactionCurrencies() { - $expectedSupportedTransactionCurrencies = $this->getMockBuilder(SupportedTransactionCurrencies::class)->getMock(); + /** + * @var SupportedTransactionCurrencies|MockObject + */ + $expectedSupportedTransactionCurrencies = $this->getMockBuilder(SupportedTransactionCurrencies::class) + ->getMock(); $invoice = $this->createClassObject(); $invoice->setSupportedTransactionCurrencies($expectedSupportedTransactionCurrencies); @@ -515,7 +532,7 @@ public function testGetPaymentCodes() $expectedPaymentCodes = [ 'BTC' => [ "BIP72b" => "bitcoin:?r=https://test.bitpay.com/i/UZjwcYkWAKfTMn9J1yyfs4", - "BIP73"=> "https://test.bitpay.com/i/UZjwcYkWAKfTMn9J1yyfs4" + "BIP73" => "https://test.bitpay.com/i/UZjwcYkWAKfTMn9J1yyfs4" ], "BCH" => [ "BIP72b" => "bitcoincash:?r=https://test.bitpay.com/i/UZjwcYkWAKfTMn9J1yyfs4", @@ -577,6 +594,9 @@ public function testGetOverpaidAmount() public function testGetMinerFees() { + /** + * @var MinerFees|MockObject + */ $expectedMinerFees = $this->getMockBuilder(MinerFees::class)->getMock(); $invoice = $this->createClassObject(); @@ -593,6 +613,9 @@ public function testGetNonPayProPaymentReceived() public function testGetShopper() { + /** + * @var Shopper|MockObject + */ $expectedShopper = $this->getMockBuilder(Shopper::class)->getMock(); $invoice = $this->createClassObject(); @@ -611,6 +634,9 @@ public function testGetBillId() public function testGetRefundInfo() { + /** + * @var RefundInfo|MockObject + */ $expectedRefundInfo = $this->getMockBuilder(RefundInfo::class)->getMock(); $invoice = $this->createClassObject(); @@ -812,7 +838,7 @@ private function setObjectSetters(Invoice $invoice) $invoice->setId('12'); $invoice->setUrl('http://test.com'); $invoice->setStatus('pending'); - $invoice->setLowFeeDetected('Low fee detected'); + $invoice->setLowFeeDetected(true); $invoice->setInvoiceTime(1620734545366); $invoice->setExpirationTime(123456); $invoice->setCurrentTime(456789); diff --git a/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php b/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php index e7f8ef2e..164966dd 100644 --- a/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php @@ -82,7 +82,7 @@ public function testManipulateOrderId(): void self::assertEquals($expected, $testedClass->getOrderId()); } - public function testManipulate_paymentSubtotals(): void + public function testManipulatePaymentSubtotals(): void { $testedClass = $this->getTestedClass(); $expected = []; diff --git a/test/unit/BitPaySDK/Model/Invoice/MinerFeesTest.php b/test/unit/BitPaySDK/Model/Invoice/MinerFeesTest.php index 26aa6d7c..09a3cbdf 100644 --- a/test/unit/BitPaySDK/Model/Invoice/MinerFeesTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/MinerFeesTest.php @@ -4,6 +4,7 @@ use BitPaySDK\Model\Invoice\MinerFees; use BitPaySDK\Model\Invoice\MinerFeesItem; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class MinerFeesTest extends TestCase @@ -16,6 +17,9 @@ public function testInstanceOf() public function testGetBTC() { + /** + * @var MinerFeesItem|MockObject + */ $expectedBTC = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -25,6 +29,9 @@ public function testGetBTC() public function testGetBCH() { + /** + * @var MinerFeesItem|MockObject + */ $expectedBCH = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -34,6 +41,9 @@ public function testGetBCH() public function testGetETH() { + /** + * @var MinerFeesItem|MockObject + */ $expectedETH = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -43,6 +53,9 @@ public function testGetETH() public function testGetUSDC() { + /** + * @var MinerFeesItem|MockObject + */ $expectedUSDC = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -52,6 +65,9 @@ public function testGetUSDC() public function testGetGUSD() { + /** + * @var MinerFeesItem|MockObject + */ $expectedGUSD = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -61,6 +77,9 @@ public function testGetGUSD() public function testGetPAX() { + /** + * @var MinerFeesItem|MockObject + */ $expectedPAX = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -70,6 +89,9 @@ public function testGetPAX() public function testGetBUSD() { + /** + * @var MinerFeesItem|MockObject + */ $expectedBUSD = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -79,6 +101,9 @@ public function testGetBUSD() public function testGetXRP() { + /** + * @var MinerFeesItem|MockObject + */ $expectedXRP = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -88,6 +113,9 @@ public function testGetXRP() public function testGetDOGE() { + /** + * @var MinerFeesItem|MockObject + */ $expectedDOGE = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -97,6 +125,9 @@ public function testGetDOGE() public function testGetLTC() { + /** + * @var MinerFeesItem|MockObject + */ $expectedLTC = $this->getMockBuilder(MinerFeesItem::class)->getMock(); $minesFees = $this->createClassObject(); @@ -106,8 +137,13 @@ public function testGetLTC() public function testToArray() { + /** + * @var MinerFeesItem|MockObject + */ $expectedMinerFeesItem = $this->getMockBuilder(MinerFeesItem::class)->getMock(); - $expectedMinerFeesItem->expects(self::once())->method('toArray')->willReturn(['satoshisPerByte' => 1.1, 'totalFee' => 1.1, 'fiatAmount' => 1.1]); + $expectedMinerFeesItem->expects(self::once()) + ->method('toArray') + ->willReturn(['satoshisPerByte' => 1.1, 'totalFee' => 1.1, 'fiatAmount' => 1.1]); $minesFees = $this->createClassObject(); $minesFees->setBTC($expectedMinerFeesItem); $minesFeesArray = $minesFees->toArray(); @@ -117,7 +153,10 @@ public function testToArray() self::assertArrayHasKey('btc', $minesFeesArray); self::assertArrayNotHasKey('bch', $minesFeesArray); - self::assertEquals(['btc' => ['satoshisPerByte' => 1.1, 'totalFee' => 1.1, 'fiatAmount' => 1.1]], $minesFeesArray); + self::assertEquals( + ['btc' => ['satoshisPerByte' => 1.1, 'totalFee' => 1.1, 'fiatAmount' => 1.1]], + $minesFeesArray + ); } public function testToArrayEmptyKey() diff --git a/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php b/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php index 62014832..1e25e531 100644 --- a/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php @@ -7,183 +7,183 @@ class RefundWebhookTest extends TestCase { - public function testInstanceOf() - { - $refundWebhook = $this->createClassObject(); - self::assertInstanceOf(RefundWebhook::class, $refundWebhook); - } - - public function testGetId() - { - $expectedId = 'GZBBLcsgQamua3PN8GX92s'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setId($expectedId); - self::assertEquals($expectedId, $refundWebhook->getId()); - } - - public function testGetInvoice() - { - $expectedInvoice = 'Wp9cpGphCz7cSeFh6MSYpb'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setInvoice($expectedInvoice); - self::assertEquals($expectedInvoice, $refundWebhook->getInvoice()); - } - - public function testGetSupportRequest() - { - $expectedSupportRequest = 'XuuYtZfTw7G99Ws3z38kWZ'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setSupportRequest($expectedSupportRequest); - self::assertEquals($expectedSupportRequest, $refundWebhook->getSupportRequest()); - } - - public function testGetStatus() - { - $expectedStatus = 'pending'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setStatus($expectedStatus); - self::assertEquals($expectedStatus, $refundWebhook->getStatus()); - } - - public function testGetAmount() - { - $expectedAmount = 6; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setAmount($expectedAmount); - self::assertEquals($expectedAmount, $refundWebhook->getAmount()); - } - - public function testGetCurrency() - { - $expectedCurrency = 'USD'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setCurrency($expectedCurrency); - self::assertEquals($expectedCurrency, $refundWebhook->getCurrency()); - } - - public function testGetLastRefundNotification() - { - $expectedLastRefundNotification = '2022-01-11T16:58:23.967Z'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setLastRefundNotification($expectedLastRefundNotification); - self::assertEquals($expectedLastRefundNotification, $refundWebhook->getLastRefundNotification()); - } - - public function testGetRefundFee() - { - $expectedRefundFee = 2.31; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setRefundFee($expectedRefundFee); - self::assertEquals($expectedRefundFee, $refundWebhook->getRefundFee()); - } - - public function testImmediate() - { - $refundWebhook = $this->createClassObject(); - $refundWebhook->setImmediate(false); - self::assertFalse($refundWebhook->getImmediate()); - } - - public function testGetBuyerPaysRefundFee() - { - $refundWebhook = $this->createClassObject(); - $refundWebhook->setBuyerPaysRefundFee(true); - self::assertTrue($refundWebhook->getBuyerPaysRefundFee()); - } - - public function testGetRequestDate() - { - $expectedRequestDate = '2022-01-11T16:58:23.000Z'; - - $refundWebhook = $this->createClassObject(); - $refundWebhook->setRequestDate($expectedRequestDate); - self::assertEquals($expectedRequestDate, $refundWebhook->getRequestDate()); - } - - public function testToArray() - { - $refundWebhook = $this->createClassObject(); - $this->objectSetters($refundWebhook); - - $refundWebhookArray = $refundWebhook->toArray(); - - self::assertNotNull($refundWebhookArray); - self::assertIsArray($refundWebhookArray); - - self::assertArrayHasKey('id', $refundWebhookArray); - self::assertArrayHasKey('invoice', $refundWebhookArray); - self::assertArrayHasKey('supportRequest', $refundWebhookArray); - self::assertArrayHasKey('status', $refundWebhookArray); - self::assertArrayHasKey('amount', $refundWebhookArray); - self::assertArrayHasKey('currency', $refundWebhookArray); - self::assertArrayHasKey('lastRefundNotification', $refundWebhookArray); - self::assertArrayHasKey('refundFee', $refundWebhookArray); - self::assertArrayHasKey('immediate', $refundWebhookArray); - self::assertArrayHasKey('buyerPaysRefundFee', $refundWebhookArray); - self::assertArrayHasKey('requestDate', $refundWebhookArray); - self::assertArrayHasKey('reference', $refundWebhookArray); - self::assertArrayHasKey('guid', $refundWebhookArray); - self::assertArrayHasKey('refundAddress', $refundWebhookArray); - self::assertArrayHasKey('type', $refundWebhookArray); - self::assertArrayHasKey('txid', $refundWebhookArray); - self::assertArrayHasKey('transactionCurrency', $refundWebhookArray); - self::assertArrayHasKey('transactionAmount', $refundWebhookArray); - self::assertArrayHasKey('transactionRefundFee', $refundWebhookArray); - - self::assertEquals('GZBBLcsgQamua3PN8GX92s', $refundWebhookArray['id']); - self::assertEquals('Wp9cpGphCz7cSeFh6MSYpb', $refundWebhookArray['invoice']); - self::assertEquals('XuuYtZfTw7G99Ws3z38kWZ', $refundWebhookArray['supportRequest']); - self::assertEquals('pending', $refundWebhookArray['status']); - self::assertEquals(6, $refundWebhookArray['amount']); - self::assertEquals('USD', $refundWebhookArray['currency']); - self::assertEquals('2022-01-11T16:58:23.967Z', $refundWebhookArray['lastRefundNotification']); - self::assertEquals(2.31, $refundWebhookArray['refundFee']); - self::assertFalse($refundWebhookArray['immediate']); - self::assertTrue($refundWebhookArray['buyerPaysRefundFee']); - self::assertEquals('2022-01-11T16:58:23.000Z', $refundWebhookArray['requestDate']); - self::assertEquals('someReference', $refundWebhookArray['reference']); - self::assertEquals('someGuid', $refundWebhookArray['guid']); - self::assertEquals('someRefundAddress', $refundWebhookArray['refundAddress']); - self::assertEquals('someType', $refundWebhookArray['type']); - self::assertEquals('someTxid', $refundWebhookArray['txid']); - self::assertEquals('someTransactionCurrency', $refundWebhookArray['transactionCurrency']); - self::assertEquals(12.34, $refundWebhookArray['transactionAmount']); - self::assertEquals(12.11, $refundWebhookArray['transactionRefundFee']); - } - - private function createClassObject(): RefundWebhook - { - return new RefundWebhook(); - } - - private function objectSetters(RefundWebhook $refundWebhook): void - { - $refundWebhook->setId('GZBBLcsgQamua3PN8GX92s'); - $refundWebhook->setInvoice('Wp9cpGphCz7cSeFh6MSYpb'); - $refundWebhook->setSupportRequest('XuuYtZfTw7G99Ws3z38kWZ'); - $refundWebhook->setStatus('pending'); - $refundWebhook->setAmount(6); - $refundWebhook->setCurrency('USD'); - $refundWebhook->setLastRefundNotification('2022-01-11T16:58:23.967Z'); - $refundWebhook->setRefundFee(2.31); - $refundWebhook->setImmediate(false); - $refundWebhook->setBuyerPaysRefundFee(true); - $refundWebhook->setRequestDate('2022-01-11T16:58:23.000Z'); - $refundWebhook->setReference('someReference'); - $refundWebhook->setGuid('someGuid'); - $refundWebhook->setRefundAddress('someRefundAddress'); - $refundWebhook->setType('someType'); - $refundWebhook->setTxid('someTxid'); - $refundWebhook->setTransactionCurrency('someTransactionCurrency'); - $refundWebhook->setTransactionAmount(12.34); - $refundWebhook->setTransactionRefundFee(12.11); - } -} \ No newline at end of file + public function testInstanceOf() + { + $refundWebhook = $this->createClassObject(); + self::assertInstanceOf(RefundWebhook::class, $refundWebhook); + } + + public function testGetId() + { + $expectedId = 'GZBBLcsgQamua3PN8GX92s'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setId($expectedId); + self::assertEquals($expectedId, $refundWebhook->getId()); + } + + public function testGetInvoice() + { + $expectedInvoice = 'Wp9cpGphCz7cSeFh6MSYpb'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setInvoice($expectedInvoice); + self::assertEquals($expectedInvoice, $refundWebhook->getInvoice()); + } + + public function testGetSupportRequest() + { + $expectedSupportRequest = 'XuuYtZfTw7G99Ws3z38kWZ'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setSupportRequest($expectedSupportRequest); + self::assertEquals($expectedSupportRequest, $refundWebhook->getSupportRequest()); + } + + public function testGetStatus() + { + $expectedStatus = 'pending'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setStatus($expectedStatus); + self::assertEquals($expectedStatus, $refundWebhook->getStatus()); + } + + public function testGetAmount() + { + $expectedAmount = 6; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setAmount($expectedAmount); + self::assertEquals($expectedAmount, $refundWebhook->getAmount()); + } + + public function testGetCurrency() + { + $expectedCurrency = 'USD'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setCurrency($expectedCurrency); + self::assertEquals($expectedCurrency, $refundWebhook->getCurrency()); + } + + public function testGetLastRefundNotification() + { + $expectedLastRefundNotification = '2022-01-11T16:58:23.967Z'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setLastRefundNotification($expectedLastRefundNotification); + self::assertEquals($expectedLastRefundNotification, $refundWebhook->getLastRefundNotification()); + } + + public function testGetRefundFee() + { + $expectedRefundFee = 2.31; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setRefundFee($expectedRefundFee); + self::assertEquals($expectedRefundFee, $refundWebhook->getRefundFee()); + } + + public function testImmediate() + { + $refundWebhook = $this->createClassObject(); + $refundWebhook->setImmediate(false); + self::assertFalse($refundWebhook->getImmediate()); + } + + public function testGetBuyerPaysRefundFee() + { + $refundWebhook = $this->createClassObject(); + $refundWebhook->setBuyerPaysRefundFee(true); + self::assertTrue($refundWebhook->getBuyerPaysRefundFee()); + } + + public function testGetRequestDate() + { + $expectedRequestDate = '2022-01-11T16:58:23.000Z'; + + $refundWebhook = $this->createClassObject(); + $refundWebhook->setRequestDate($expectedRequestDate); + self::assertEquals($expectedRequestDate, $refundWebhook->getRequestDate()); + } + + public function testToArray() + { + $refundWebhook = $this->createClassObject(); + $this->objectSetters($refundWebhook); + + $refundWebhookArray = $refundWebhook->toArray(); + + self::assertNotNull($refundWebhookArray); + self::assertIsArray($refundWebhookArray); + + self::assertArrayHasKey('id', $refundWebhookArray); + self::assertArrayHasKey('invoice', $refundWebhookArray); + self::assertArrayHasKey('supportRequest', $refundWebhookArray); + self::assertArrayHasKey('status', $refundWebhookArray); + self::assertArrayHasKey('amount', $refundWebhookArray); + self::assertArrayHasKey('currency', $refundWebhookArray); + self::assertArrayHasKey('lastRefundNotification', $refundWebhookArray); + self::assertArrayHasKey('refundFee', $refundWebhookArray); + self::assertArrayHasKey('immediate', $refundWebhookArray); + self::assertArrayHasKey('buyerPaysRefundFee', $refundWebhookArray); + self::assertArrayHasKey('requestDate', $refundWebhookArray); + self::assertArrayHasKey('reference', $refundWebhookArray); + self::assertArrayHasKey('guid', $refundWebhookArray); + self::assertArrayHasKey('refundAddress', $refundWebhookArray); + self::assertArrayHasKey('type', $refundWebhookArray); + self::assertArrayHasKey('txid', $refundWebhookArray); + self::assertArrayHasKey('transactionCurrency', $refundWebhookArray); + self::assertArrayHasKey('transactionAmount', $refundWebhookArray); + self::assertArrayHasKey('transactionRefundFee', $refundWebhookArray); + + self::assertEquals('GZBBLcsgQamua3PN8GX92s', $refundWebhookArray['id']); + self::assertEquals('Wp9cpGphCz7cSeFh6MSYpb', $refundWebhookArray['invoice']); + self::assertEquals('XuuYtZfTw7G99Ws3z38kWZ', $refundWebhookArray['supportRequest']); + self::assertEquals('pending', $refundWebhookArray['status']); + self::assertEquals(6, $refundWebhookArray['amount']); + self::assertEquals('USD', $refundWebhookArray['currency']); + self::assertEquals('2022-01-11T16:58:23.967Z', $refundWebhookArray['lastRefundNotification']); + self::assertEquals(2.31, $refundWebhookArray['refundFee']); + self::assertFalse($refundWebhookArray['immediate']); + self::assertTrue($refundWebhookArray['buyerPaysRefundFee']); + self::assertEquals('2022-01-11T16:58:23.000Z', $refundWebhookArray['requestDate']); + self::assertEquals('someReference', $refundWebhookArray['reference']); + self::assertEquals('someGuid', $refundWebhookArray['guid']); + self::assertEquals('someRefundAddress', $refundWebhookArray['refundAddress']); + self::assertEquals('someType', $refundWebhookArray['type']); + self::assertEquals('someTxid', $refundWebhookArray['txid']); + self::assertEquals('someTransactionCurrency', $refundWebhookArray['transactionCurrency']); + self::assertEquals(12.34, $refundWebhookArray['transactionAmount']); + self::assertEquals(12.11, $refundWebhookArray['transactionRefundFee']); + } + + private function createClassObject(): RefundWebhook + { + return new RefundWebhook(); + } + + private function objectSetters(RefundWebhook $refundWebhook): void + { + $refundWebhook->setId('GZBBLcsgQamua3PN8GX92s'); + $refundWebhook->setInvoice('Wp9cpGphCz7cSeFh6MSYpb'); + $refundWebhook->setSupportRequest('XuuYtZfTw7G99Ws3z38kWZ'); + $refundWebhook->setStatus('pending'); + $refundWebhook->setAmount(6); + $refundWebhook->setCurrency('USD'); + $refundWebhook->setLastRefundNotification('2022-01-11T16:58:23.967Z'); + $refundWebhook->setRefundFee(2.31); + $refundWebhook->setImmediate(false); + $refundWebhook->setBuyerPaysRefundFee(true); + $refundWebhook->setRequestDate('2022-01-11T16:58:23.000Z'); + $refundWebhook->setReference('someReference'); + $refundWebhook->setGuid('someGuid'); + $refundWebhook->setRefundAddress('someRefundAddress'); + $refundWebhook->setType('someType'); + $refundWebhook->setTxid('someTxid'); + $refundWebhook->setTransactionCurrency('someTransactionCurrency'); + $refundWebhook->setTransactionAmount(12.34); + $refundWebhook->setTransactionRefundFee(12.11); + } +} diff --git a/test/unit/BitPaySDK/Model/Invoice/ShopperTest.php b/test/unit/BitPaySDK/Model/Invoice/ShopperTest.php index 9fd259d1..f4704861 100644 --- a/test/unit/BitPaySDK/Model/Invoice/ShopperTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/ShopperTest.php @@ -46,4 +46,4 @@ private function createClassObject(): Shopper { return new Shopper(); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrenciesTest.php b/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrenciesTest.php index d525c8fb..2488f947 100644 --- a/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrenciesTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrenciesTest.php @@ -4,6 +4,7 @@ use BitPaySDK\Model\Invoice\SupportedTransactionCurrencies; use BitPaySDK\Model\Invoice\SupportedTransactionCurrency; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class SupportedTransactionCurrenciesTest extends TestCase @@ -16,6 +17,9 @@ public function testInstanceOf() public function testGetBTC() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setBTC($expectedSupportedTransactionCurrency); @@ -24,6 +28,9 @@ public function testGetBTC() public function testGetBCH() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setBCH($expectedSupportedTransactionCurrency); @@ -32,6 +39,9 @@ public function testGetBCH() public function testGetETH() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setETH($expectedSupportedTransactionCurrency); @@ -40,6 +50,9 @@ public function testGetETH() public function testGetUSDC() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setUSDC($expectedSupportedTransactionCurrency); @@ -48,6 +61,9 @@ public function testGetUSDC() public function testGetGUSD() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setGUSD($expectedSupportedTransactionCurrency); @@ -56,6 +72,9 @@ public function testGetGUSD() public function testGetPAX() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setPAX($expectedSupportedTransactionCurrency); @@ -64,6 +83,9 @@ public function testGetPAX() public function testGetXRP() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setXRP($expectedSupportedTransactionCurrency); @@ -72,8 +94,13 @@ public function testGetXRP() public function testToArray() { + /** + * @var SupportedTransactionCurrency|MockObject + */ $expectedSupportedTransactionCurrency = $this->getMockBuilder(SupportedTransactionCurrency::class)->getMock(); - $expectedSupportedTransactionCurrency->expects(self::once())->method('toArray')->willReturn(['enabled' => true, 'reason' => 'test']); + $expectedSupportedTransactionCurrency->expects(self::once()) + ->method('toArray') + ->willReturn(['enabled' => true, 'reason' => 'test']); $supportedTransactionCurrencies = $this->createClassObject(); $supportedTransactionCurrencies->setBTC($expectedSupportedTransactionCurrency); $supportedTransactionCurrenciesArray = $supportedTransactionCurrencies->toArray(); @@ -101,4 +128,4 @@ private function createClassObject(): SupportedTransactionCurrencies { return new SupportedTransactionCurrencies(); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrencyTest.php b/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrencyTest.php index 38e1016e..82aa6ec9 100644 --- a/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrencyTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/SupportedTransactionCurrencyTest.php @@ -7,65 +7,65 @@ class SupportedTransactionCurrencyTest extends TestCase { - public function testInstanceOf() - { - $supportedTransactionCurrency = $this->createClassObject(); - self::assertInstanceOf(SupportedTransactionCurrency::class, $supportedTransactionCurrency); - } - - public function testGetEnabled() - { - $supportedTransactionCurrency = $this->createClassObject(); - $supportedTransactionCurrency->setEnabled(true); - self::assertTrue($supportedTransactionCurrency->getEnabled()); - } - - public function testGetReason() - { - $expectedReason = "My reason"; - - $supportedTransactionCurrency = $this->createClassObject(); - $supportedTransactionCurrency->setReason($expectedReason); - self::assertEquals($expectedReason, $supportedTransactionCurrency->getReason()); - } - - public function testToArray() - { - $supportedTransactionCurrency = $this->createClassObject(); - $this->objectSetters($supportedTransactionCurrency); - - $supportedTransactionCurrencyArray = $supportedTransactionCurrency->toArray(); - - self::assertNotNull($supportedTransactionCurrencyArray); - self::assertIsArray($supportedTransactionCurrencyArray); - - self::assertArrayHasKey('enabled', $supportedTransactionCurrencyArray); - self::assertArrayHasKey('reason', $supportedTransactionCurrencyArray); - - self::assertTrue($supportedTransactionCurrencyArray['enabled']); - self::assertEquals("My reason", $supportedTransactionCurrencyArray['reason']); - } - - public function testToArrayEmptyKey() - { - $supportedTransactionCurrency = $this->createClassObject(); - - $supportedTransactionCurrencyArray = $supportedTransactionCurrency->toArray(); - - self::assertNotNull($supportedTransactionCurrencyArray); - self::assertIsArray($supportedTransactionCurrencyArray); - - self::assertArrayNotHasKey('enabled', $supportedTransactionCurrencyArray); - } - - private function createClassObject(): SupportedTransactionCurrency - { - return new SupportedTransactionCurrency(); - } - - private function objectSetters(SupportedTransactionCurrency $supportedTransactionCurrency): void - { - $supportedTransactionCurrency->setEnabled(true); - $supportedTransactionCurrency->setReason("My reason"); - } -} \ No newline at end of file + public function testInstanceOf() + { + $supportedTransactionCurrency = $this->createClassObject(); + self::assertInstanceOf(SupportedTransactionCurrency::class, $supportedTransactionCurrency); + } + + public function testGetEnabled() + { + $supportedTransactionCurrency = $this->createClassObject(); + $supportedTransactionCurrency->setEnabled(true); + self::assertTrue($supportedTransactionCurrency->getEnabled()); + } + + public function testGetReason() + { + $expectedReason = "My reason"; + + $supportedTransactionCurrency = $this->createClassObject(); + $supportedTransactionCurrency->setReason($expectedReason); + self::assertEquals($expectedReason, $supportedTransactionCurrency->getReason()); + } + + public function testToArray() + { + $supportedTransactionCurrency = $this->createClassObject(); + $this->objectSetters($supportedTransactionCurrency); + + $supportedTransactionCurrencyArray = $supportedTransactionCurrency->toArray(); + + self::assertNotNull($supportedTransactionCurrencyArray); + self::assertIsArray($supportedTransactionCurrencyArray); + + self::assertArrayHasKey('enabled', $supportedTransactionCurrencyArray); + self::assertArrayHasKey('reason', $supportedTransactionCurrencyArray); + + self::assertTrue($supportedTransactionCurrencyArray['enabled']); + self::assertEquals("My reason", $supportedTransactionCurrencyArray['reason']); + } + + public function testToArrayEmptyKey() + { + $supportedTransactionCurrency = $this->createClassObject(); + + $supportedTransactionCurrencyArray = $supportedTransactionCurrency->toArray(); + + self::assertNotNull($supportedTransactionCurrencyArray); + self::assertIsArray($supportedTransactionCurrencyArray); + + self::assertArrayNotHasKey('enabled', $supportedTransactionCurrencyArray); + } + + private function createClassObject(): SupportedTransactionCurrency + { + return new SupportedTransactionCurrency(); + } + + private function objectSetters(SupportedTransactionCurrency $supportedTransactionCurrency): void + { + $supportedTransactionCurrency->setEnabled(true); + $supportedTransactionCurrency->setReason("My reason"); + } +} diff --git a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php index d34a7334..f7ec9a6e 100644 --- a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php @@ -155,4 +155,4 @@ private function setSetters(Buyer $buyer) $buyer->setBuyerNotify(true); $buyer->setBuyerEmail('test@email.com'); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Ledger/LedgerTest.php b/test/unit/BitPaySDK/Model/Ledger/LedgerTest.php index 3898f84f..17561a58 100644 --- a/test/unit/BitPaySDK/Model/Ledger/LedgerTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/LedgerTest.php @@ -54,4 +54,4 @@ private function createClassObject(): Ledger { return new Ledger(); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Payout/PayoutRecipientTest.php b/test/unit/BitPaySDK/Model/Payout/PayoutRecipientTest.php index f69b6678..75f84608 100644 --- a/test/unit/BitPaySDK/Model/Payout/PayoutRecipientTest.php +++ b/test/unit/BitPaySDK/Model/Payout/PayoutRecipientTest.php @@ -7,124 +7,127 @@ class PayoutRecipientTest extends TestCase { - public function testInstanceOf() - { - $payoutRecipient = $this->createClassObject(); - self::assertInstanceOf(PayoutRecipient::class, $payoutRecipient); - } - - public function testGetEmail() - { - $expectedEmail = 'john@doe.com'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setEmail($expectedEmail); - - self::assertEquals($expectedEmail, $payoutRecipient->getEmail()); - } - - public function testGetLabel() - { - $expectedLabel = 'My Label'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setLabel($expectedLabel); - - self::assertEquals($expectedLabel, $payoutRecipient->getLabel()); - } - - public function testGetNotificationURL() - { - $expectedNotificationURL = 'https://www.example.com'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setNotificationURL($expectedNotificationURL); - - self::assertEquals($expectedNotificationURL, $payoutRecipient->getNotificationURL()); - } - - public function testGetStatus() - { - $expectedStatus = 'success'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setStatus($expectedStatus); - - self::assertEquals($expectedStatus, $payoutRecipient->getStatus()); - } - - public function testGetId() - { - $expectedId = 'abcd123'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setId($expectedId); - - self::assertEquals($expectedId, $payoutRecipient->getId()); - } - - public function testGetShopperId() - { - $expectedShopperId = 'efgh456'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setShopperId($expectedShopperId); - - self::assertEquals($expectedShopperId, $payoutRecipient->getShopperId()); - } - - public function testGetToken() - { - $expectedToken = '6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL'; - - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setToken($expectedToken); - - self::assertEquals($expectedToken, $payoutRecipient->getToken()); - } - - public function testToArray() - { - $payoutRecipient = $this->createClassObject(); - $payoutRecipient->setEmail('john@doe.com'); - $payoutRecipient->setLabel('My Label'); - $payoutRecipient->setNotificationURL('https://www.example.com'); - $payoutRecipient->setStatus('success'); - $payoutRecipient->setId('abcd123'); - $payoutRecipient->setShopperId('efgh456'); - $payoutRecipient->setToken('6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL'); - $payoutRecipientArray = $payoutRecipient->toArray(); - - self::assertNotNull($payoutRecipientArray); - self::assertIsArray($payoutRecipientArray); - - self::assertArrayHasKey('email', $payoutRecipientArray); - self::assertArrayHasKey('label', $payoutRecipientArray); - self::assertArrayHasKey('notificationURL', $payoutRecipientArray); - self::assertArrayHasKey('status', $payoutRecipientArray); - self::assertArrayHasKey('id', $payoutRecipientArray); - self::assertArrayHasKey('shopperId', $payoutRecipientArray); - self::assertArrayHasKey('token', $payoutRecipientArray); - - self::assertEquals('john@doe.com', $payoutRecipientArray['email']); - self::assertEquals('My Label', $payoutRecipientArray['label']); - self::assertEquals('https://www.example.com', $payoutRecipientArray['notificationURL']); - self::assertEquals('success', $payoutRecipientArray['status']); - self::assertEquals('abcd123', $payoutRecipientArray['id']); - self::assertEquals('efgh456', $payoutRecipientArray['shopperId']); - self::assertEquals('6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL', $payoutRecipientArray['token']); - } - - public function testToArrayEmptyKey() - { - $payoutRecipient = $this->createClassObject(); - $payoutRecipientArray = $payoutRecipient->toArray(); - - self::assertArrayNotHasKey('email', $payoutRecipientArray); - } - - private function createClassObject(): PayoutRecipient - { - return new PayoutRecipient(); - } -} \ No newline at end of file + public function testInstanceOf() + { + $payoutRecipient = $this->createClassObject(); + self::assertInstanceOf(PayoutRecipient::class, $payoutRecipient); + } + + public function testGetEmail() + { + $expectedEmail = 'john@doe.com'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setEmail($expectedEmail); + + self::assertEquals($expectedEmail, $payoutRecipient->getEmail()); + } + + public function testGetLabel() + { + $expectedLabel = 'My Label'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setLabel($expectedLabel); + + self::assertEquals($expectedLabel, $payoutRecipient->getLabel()); + } + + public function testGetNotificationURL() + { + $expectedNotificationURL = 'https://www.example.com'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setNotificationURL($expectedNotificationURL); + + self::assertEquals($expectedNotificationURL, $payoutRecipient->getNotificationURL()); + } + + public function testGetStatus() + { + $expectedStatus = 'success'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setStatus($expectedStatus); + + self::assertEquals($expectedStatus, $payoutRecipient->getStatus()); + } + + public function testGetId() + { + $expectedId = 'abcd123'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setId($expectedId); + + self::assertEquals($expectedId, $payoutRecipient->getId()); + } + + public function testGetShopperId() + { + $expectedShopperId = 'efgh456'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setShopperId($expectedShopperId); + + self::assertEquals($expectedShopperId, $payoutRecipient->getShopperId()); + } + + public function testGetToken() + { + $expectedToken = '6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL'; + + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setToken($expectedToken); + + self::assertEquals($expectedToken, $payoutRecipient->getToken()); + } + + public function testToArray() + { + $payoutRecipient = $this->createClassObject(); + $payoutRecipient->setEmail('john@doe.com'); + $payoutRecipient->setLabel('My Label'); + $payoutRecipient->setNotificationURL('https://www.example.com'); + $payoutRecipient->setStatus('success'); + $payoutRecipient->setId('abcd123'); + $payoutRecipient->setShopperId('efgh456'); + $payoutRecipient->setToken('6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL'); + $payoutRecipientArray = $payoutRecipient->toArray(); + + self::assertNotNull($payoutRecipientArray); + self::assertIsArray($payoutRecipientArray); + + self::assertArrayHasKey('email', $payoutRecipientArray); + self::assertArrayHasKey('label', $payoutRecipientArray); + self::assertArrayHasKey('notificationURL', $payoutRecipientArray); + self::assertArrayHasKey('status', $payoutRecipientArray); + self::assertArrayHasKey('id', $payoutRecipientArray); + self::assertArrayHasKey('shopperId', $payoutRecipientArray); + self::assertArrayHasKey('token', $payoutRecipientArray); + + self::assertEquals('john@doe.com', $payoutRecipientArray['email']); + self::assertEquals('My Label', $payoutRecipientArray['label']); + self::assertEquals('https://www.example.com', $payoutRecipientArray['notificationURL']); + self::assertEquals('success', $payoutRecipientArray['status']); + self::assertEquals('abcd123', $payoutRecipientArray['id']); + self::assertEquals('efgh456', $payoutRecipientArray['shopperId']); + self::assertEquals( + '6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL', + $payoutRecipientArray['token'] + ); + } + + public function testToArrayEmptyKey() + { + $payoutRecipient = $this->createClassObject(); + $payoutRecipientArray = $payoutRecipient->toArray(); + + self::assertArrayNotHasKey('email', $payoutRecipientArray); + } + + private function createClassObject(): PayoutRecipient + { + return new PayoutRecipient(); + } +} diff --git a/test/unit/BitPaySDK/Model/Payout/PayoutRecipientsTest.php b/test/unit/BitPaySDK/Model/Payout/PayoutRecipientsTest.php index d245f68e..e5d56bce 100644 --- a/test/unit/BitPaySDK/Model/Payout/PayoutRecipientsTest.php +++ b/test/unit/BitPaySDK/Model/Payout/PayoutRecipientsTest.php @@ -41,9 +41,6 @@ public function testGetRecipientsObject() self::assertEquals($expectedPayoutRecipients[0]->toArray(), $payoutRecipients->getRecipients()[0]->toArray()); } - /** - * @throws \BitPaySDK\Exceptions\PayoutRecipientException - */ public function testGetRecipientsArray() { $payoutRecipient = new PayoutRecipient(); @@ -101,8 +98,14 @@ public function testToArray() self::assertEquals('success', $payoutRecipientsArray['recipients'][0]['status']); self::assertEquals('abcd123', $payoutRecipientsArray['recipients'][0]['id']); self::assertEquals('efgh456', $payoutRecipientsArray['recipients'][0]['shopperId']); - self::assertEquals('6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL', $payoutRecipientsArray['recipients'][0]['token']); - self::assertEquals('6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL', $payoutRecipientsArray['token']); + self::assertEquals( + '6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL', + $payoutRecipientsArray['recipients'][0]['token'] + ); + self::assertEquals( + '6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL', + $payoutRecipientsArray['token'] + ); } public function testToArrayEmptyKey() @@ -116,4 +119,4 @@ private function createClassObject(): PayoutRecipients { return new PayoutRecipients(); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Payout/PayoutTest.php b/test/unit/BitPaySDK/Model/Payout/PayoutTest.php index 972609d9..f8fc7b50 100644 --- a/test/unit/BitPaySDK/Model/Payout/PayoutTest.php +++ b/test/unit/BitPaySDK/Model/Payout/PayoutTest.php @@ -351,4 +351,4 @@ private function objectSetters(Payout $payout) ]); $payout->setTransactions($transactions); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php b/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php index a1ba47fb..ab12c008 100644 --- a/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php +++ b/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php @@ -14,142 +14,142 @@ public function testModifyCurrency(): void $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setCurrency($expected); - + self::assertEquals($expected, $testedClass->getCurrency()); } - + public function testModifyEffectiveDate(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setEffectiveDate($expected); - + self::assertEquals($expected, $testedClass->getEffectiveDate()); } - + public function testModifyEmail(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setEmail($expected); - + self::assertEquals($expected, $testedClass->getEmail()); } - + public function testModifyExchangeRates(): void { $testedClass = $this->getTestedClass(); $expected = []; $testedClass->setExchangeRates($expected); - + self::assertEquals($expected, $testedClass->getExchangeRates()); } - + public function testModifyId(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setId($expected); - + self::assertEquals($expected, $testedClass->getId()); } - + public function testModifyLabel(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setLabel($expected); - + self::assertEquals($expected, $testedClass->getLabel()); } - + public function testModifyLedgerCurrency(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setLedgerCurrency($expected); - + self::assertEquals($expected, $testedClass->getLedgerCurrency()); } - + public function testModifyNotificationEmail(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setNotificationEmail($expected); - + self::assertEquals($expected, $testedClass->getNotificationEmail()); } - + public function testModifyNotificationURL(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setNotificationURL($expected); - + self::assertEquals($expected, $testedClass->getNotificationURL()); } - + public function testModifyPrice(): void { $testedClass = $this->getTestedClass(); $expected = 12.67; $testedClass->setprice($expected); - + self::assertEquals($expected, $testedClass->getPrice()); } - + public function testModifyRecipientId(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setRecipientId($expected); - + self::assertEquals($expected, $testedClass->getRecipientId()); } - + public function testModifyReference(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setReference($expected); - + self::assertEquals($expected, $testedClass->getReference()); } - + public function testModifyRequestDate(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setRequestDate($expected); - + self::assertEquals($expected, $testedClass->getRequestDate()); } - + public function testModifyShopperId(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setShopperId($expected); - + self::assertEquals($expected, $testedClass->getShopperId()); } - + public function testModifyStatus(): void { $testedClass = $this->getTestedClass(); $expected = 'someValue'; $testedClass->setStatus($expected); - + self::assertEquals($expected, $testedClass->getStatus()); } - + public function testModifyTransactions(): void { $testedClass = $this->getTestedClass(); $expected = []; $testedClass->setTransactions($expected); - + self::assertEquals($expected, $testedClass->getTransactions()); } diff --git a/test/unit/BitPaySDK/Model/Rate/RatesTest.php b/test/unit/BitPaySDK/Model/Rate/RatesTest.php index c8ff60e5..a4a2dcda 100644 --- a/test/unit/BitPaySDK/Model/Rate/RatesTest.php +++ b/test/unit/BitPaySDK/Model/Rate/RatesTest.php @@ -7,6 +7,7 @@ use BitPaySDK\Exceptions\BitPayGenericException; use BitPaySDK\Model\Rate\Rate; use BitPaySDK\Model\Rate\Rates; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class RatesTest extends TestCase @@ -37,6 +38,9 @@ public function testUpdate(): void $expectedRatesArray = [$bch]; $expectedRates = new Rates($expectedRatesArray); + /** + * @var Client|MockObject + */ $bp = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); $bp->method('getRates')->willReturn($expectedRates); @@ -61,6 +65,9 @@ public function testUpdateShouldThrowsExceptionsForInvalidRateFormat(): void ] ]; $expectedRates = new Rates($clientApiResponse); + /** + * @var Client|MockObject + */ $bp = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); $bp->method('getRates')->willReturn($expectedRates); @@ -110,4 +117,4 @@ private function createClassObject(): Rates return new Rates($rates); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php b/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php index 498b1150..2aada975 100644 --- a/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php +++ b/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php @@ -4,6 +4,7 @@ use BitPaySDK\Model\Settlement\InvoiceData; use BitPaySDK\Model\Settlement\RefundInfo; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class InvoiceDataTest extends TestCase @@ -79,6 +80,9 @@ public function testGetPayoutPercentage() public function testGetRefundInfo() { + /** + * @var RefundInfo|MockObject + */ $expectedRefundInfo = $this->getMockBuilder(RefundInfo::class)->getMock(); $invoiceData = $this->createClassObject(); @@ -125,6 +129,10 @@ private function setSetters(InvoiceData $invoiceData) $invoiceData->setCurrency('BTC'); $invoiceData->setTransactionCurrency('BTC'); $invoiceData->setPayoutPercentage(['USD' => 15.12]); - $invoiceData->setRefundInfo($this->getMockBuilder(RefundInfo::class)->getMock()); + /** + * @var RefundInfo|MockObject + */ + $refundInfo = $this->getMockBuilder(RefundInfo::class)->getMock(); + $invoiceData->setRefundInfo($refundInfo); } } diff --git a/test/unit/BitPaySDK/Model/Settlement/PayoutInfoTest.php b/test/unit/BitPaySDK/Model/Settlement/PayoutInfoTest.php index 96fc758c..d24baf85 100644 --- a/test/unit/BitPaySDK/Model/Settlement/PayoutInfoTest.php +++ b/test/unit/BitPaySDK/Model/Settlement/PayoutInfoTest.php @@ -123,7 +123,7 @@ public function testGetSort() public function testGetWire() { - $expectedWire = 'Test wire'; + $expectedWire = true; $payoutInfo = $this->createClassObject(); $payoutInfo->setWire($expectedWire); @@ -297,7 +297,7 @@ private function setSetters(PayoutInfo $payoutInfo) $payoutInfo->setCity('Miami'); $payoutInfo->setPostal('12345'); $payoutInfo->setSort('Sort'); - $payoutInfo->setWire('Wire'); + $payoutInfo->setWire(true); $payoutInfo->setBankName('Bank name'); $payoutInfo->setBankAddress('Bank address'); $payoutInfo->setIban('KW81CBKU00000000000012345601013'); diff --git a/test/unit/BitPaySDK/Model/Settlement/RefundInfoTest.php b/test/unit/BitPaySDK/Model/Settlement/RefundInfoTest.php index 1032aca5..b74a1217 100644 --- a/test/unit/BitPaySDK/Model/Settlement/RefundInfoTest.php +++ b/test/unit/BitPaySDK/Model/Settlement/RefundInfoTest.php @@ -78,4 +78,4 @@ private function setSetters(RefundInfo $refundInfo) $refundInfo->setCurrency('BTC'); $refundInfo->setAmounts([25]); } -} \ No newline at end of file +} diff --git a/test/unit/BitPaySDK/Model/Settlement/SettlementLedgerEntryTest.php b/test/unit/BitPaySDK/Model/Settlement/SettlementLedgerEntryTest.php index 5763e0ea..fd9037c7 100644 --- a/test/unit/BitPaySDK/Model/Settlement/SettlementLedgerEntryTest.php +++ b/test/unit/BitPaySDK/Model/Settlement/SettlementLedgerEntryTest.php @@ -4,6 +4,7 @@ use BitPaySDK\Model\Settlement\InvoiceData; use BitPaySDK\Model\Settlement\SettlementLedgerEntry; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class SettlementLedgerEntryTest extends TestCase @@ -70,6 +71,9 @@ public function testGetReference() public function testGetInvoiceData() { + /** + * @var InvoiceData|MockObject + */ $expectedInvoiceData = $this->getMockBuilder(InvoiceData::class)->getMock(); $settlementLedgerEntry = $this->createClassObject(); @@ -115,6 +119,10 @@ private function setSetters(SettlementLedgerEntry $settlementLedgerEntry) $settlementLedgerEntry->setTimestamp('2022-01-11 01:01:01'); $settlementLedgerEntry->setDescription('Description'); $settlementLedgerEntry->setReference('Reference'); - $settlementLedgerEntry->setInvoiceData($this->getMockBuilder(InvoiceData::class)->getMock()); + /** + * @var InvoiceData|MockObject + */ + $invoiceData = $this->getMockBuilder(InvoiceData::class)->getMock(); + $settlementLedgerEntry->setInvoiceData($invoiceData); } } diff --git a/test/unit/BitPaySDK/Model/Settlement/SettlementTest.php b/test/unit/BitPaySDK/Model/Settlement/SettlementTest.php index f9e28685..0fb490cc 100644 --- a/test/unit/BitPaySDK/Model/Settlement/SettlementTest.php +++ b/test/unit/BitPaySDK/Model/Settlement/SettlementTest.php @@ -6,6 +6,7 @@ use BitPaySDK\Model\Settlement\Settlement; use BitPaySDK\Model\Settlement\SettlementLedgerEntry; use BitPaySDK\Model\Settlement\WithHoldings; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class SettlementTest extends TestCase @@ -48,6 +49,9 @@ public function testGetCurrency() public function testGetPayoutInfo() { + /** + * @var PayoutInfo|MockObject + */ $expectedPayoutInfo = $this->getMockBuilder(PayoutInfo::class)->getMock(); $settlement = $this->createClassObject(); @@ -155,9 +159,6 @@ public function testGetTotalAmount() self::assertEquals($expectedTotalAmount, $settlement->getTotalAmount()); } - /** - * @throws \BitPaySDK\Exceptions\SettlementException - */ public function testGetLedgerEntries() { $settlement = $this->createClassObject(); @@ -177,9 +178,6 @@ public function testGetToken() self::assertEquals($expectedToken, $settlement->getToken()); } - /** - * @throws \BitPaySDK\Exceptions\SettlementException - */ public function testToArray() { $settlement = $this->createClassObject(); @@ -231,9 +229,6 @@ private function createClassObject(): Settlement return new Settlement(); } - /** - * @throws \BitPaySDK\Exceptions\SettlementException - */ private function prepareSettlementForTests(Settlement $settlement) { $withHoldings = new WithHoldings(); diff --git a/test/unit/BitPaySDK/Model/Wallet/CurrenciesTest.php b/test/unit/BitPaySDK/Model/Wallet/CurrenciesTest.php index ed4e2b69..2ce19717 100644 --- a/test/unit/BitPaySDK/Model/Wallet/CurrenciesTest.php +++ b/test/unit/BitPaySDK/Model/Wallet/CurrenciesTest.php @@ -8,126 +8,126 @@ class CurrenciesTest extends TestCase { - public function testInstanceOf() - { - $currencies = $this->createClassObject(); - self::assertInstanceOf(Currencies::class, $currencies); - } - - public function testGetCode() - { - $expectedCode = 'BTH'; - - $currencies = $this->createClassObject(); - $currencies->setCode($expectedCode); - self::assertEquals($expectedCode, $currencies->getCode()); - } - - public function testGetP2p() - { - $currencies = $this->createClassObject(); - $currencies->setP2p(true); - self::assertTrue($currencies->getP2p()); - } - - public function testGetDappBrowser() - { - $currencies = $this->createClassObject(); - $currencies->setDappBrowser(true); - self::assertTrue($currencies->getDappBrowser()); - } - - public function testGetImage() - { - $expectedImage = 'https://bitpay.com/api/images/logo-6fa5404d.svg'; - - $currencies = $this->createClassObject(); - $currencies->setImage($expectedImage); - self::assertEquals($expectedImage, $currencies->getImage()); - } - - public function testGetPayPro() - { - $currencies = $this->createClassObject(); - $currencies->setPayPro(true); - self::assertTrue($currencies->getPayPro()); - } - - public function testGetQr() - { - $expectedCurrencyQr = new CurrencyQr; - $expectedCurrencyQr->setType('BIP21'); - $expectedCurrencyQr->setCollapsed(false); - - $currencies = $this->createClassObject(); - $currencies->setQr($expectedCurrencyQr); - - self::assertEquals($expectedCurrencyQr, $currencies->getQr()); - } - - public function testGetWithdrawalFee() - { - $expectedWithdrawalFee = '1.23'; - - $currencies = $this->createClassObject(); - $currencies->setWithdrawalFee($expectedWithdrawalFee); - self::assertEquals($expectedWithdrawalFee, $currencies->getWithdrawalFee()); - } - - public function testGetWalletConnect() - { - $currencies = $this->createClassObject(); - $currencies->setWalletConnect(true); - self::assertTrue($currencies->getWalletConnect()); - } - - public function testToArray() - { - $currencies = $this->createClassObject(); - $this->objectSetters($currencies); - $currenciesArray = $currencies->toArray(); - - self::assertNotNull($currenciesArray); - self::assertIsArray($currenciesArray); - - self::assertArrayHasKey('code', $currenciesArray); - self::assertArrayHasKey('p2p', $currenciesArray); - self::assertArrayHasKey('dappBrowser', $currenciesArray); - self::assertArrayHasKey('image', $currenciesArray); - self::assertArrayHasKey('paypro', $currenciesArray); - self::assertArrayHasKey('qr', $currenciesArray); - self::assertArrayHasKey('withdrawalFee', $currenciesArray); - self::assertArrayHasKey('walletConnect', $currenciesArray); - - self::assertEquals('BTH', $currenciesArray['code']); - self::assertTrue($currenciesArray['p2p']); - self::assertTrue($currenciesArray['dappBrowser']); - self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $currenciesArray['image']); - self::assertTrue($currenciesArray['paypro']); - self::assertEquals('BIP21', $currenciesArray['qr']['type']); - self::assertFalse($currenciesArray['qr']['collapsed']); - self::assertEquals('1.23', $currenciesArray['withdrawalFee']); - self::assertTrue($currenciesArray['walletConnect']); - } - - private function createClassObject(): Currencies - { - return new Currencies(); - } - - private function objectSetters(Currencies $currencies): void - { - $currencyQr = new CurrencyQr; - $currencyQr->setType('BIP21'); - $currencyQr->setCollapsed(false); - - $currencies->setCode('BTH'); - $currencies->setP2p(true); - $currencies->setDappBrowser(true); - $currencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); - $currencies->setPayPro(true); - $currencies->setQr($currencyQr); - $currencies->setWithdrawalFee('1.23'); - $currencies->setWalletConnect(true); - } -} \ No newline at end of file + public function testInstanceOf() + { + $currencies = $this->createClassObject(); + self::assertInstanceOf(Currencies::class, $currencies); + } + + public function testGetCode() + { + $expectedCode = 'BTH'; + + $currencies = $this->createClassObject(); + $currencies->setCode($expectedCode); + self::assertEquals($expectedCode, $currencies->getCode()); + } + + public function testGetP2p() + { + $currencies = $this->createClassObject(); + $currencies->setP2p(true); + self::assertTrue($currencies->getP2p()); + } + + public function testGetDappBrowser() + { + $currencies = $this->createClassObject(); + $currencies->setDappBrowser(true); + self::assertTrue($currencies->getDappBrowser()); + } + + public function testGetImage() + { + $expectedImage = 'https://bitpay.com/api/images/logo-6fa5404d.svg'; + + $currencies = $this->createClassObject(); + $currencies->setImage($expectedImage); + self::assertEquals($expectedImage, $currencies->getImage()); + } + + public function testGetPayPro() + { + $currencies = $this->createClassObject(); + $currencies->setPayPro(true); + self::assertTrue($currencies->getPayPro()); + } + + public function testGetQr() + { + $expectedCurrencyQr = new CurrencyQr(); + $expectedCurrencyQr->setType('BIP21'); + $expectedCurrencyQr->setCollapsed(false); + + $currencies = $this->createClassObject(); + $currencies->setQr($expectedCurrencyQr); + + self::assertEquals($expectedCurrencyQr, $currencies->getQr()); + } + + public function testGetWithdrawalFee() + { + $expectedWithdrawalFee = '1.23'; + + $currencies = $this->createClassObject(); + $currencies->setWithdrawalFee($expectedWithdrawalFee); + self::assertEquals($expectedWithdrawalFee, $currencies->getWithdrawalFee()); + } + + public function testGetWalletConnect() + { + $currencies = $this->createClassObject(); + $currencies->setWalletConnect(true); + self::assertTrue($currencies->getWalletConnect()); + } + + public function testToArray() + { + $currencies = $this->createClassObject(); + $this->objectSetters($currencies); + $currenciesArray = $currencies->toArray(); + + self::assertNotNull($currenciesArray); + self::assertIsArray($currenciesArray); + + self::assertArrayHasKey('code', $currenciesArray); + self::assertArrayHasKey('p2p', $currenciesArray); + self::assertArrayHasKey('dappBrowser', $currenciesArray); + self::assertArrayHasKey('image', $currenciesArray); + self::assertArrayHasKey('paypro', $currenciesArray); + self::assertArrayHasKey('qr', $currenciesArray); + self::assertArrayHasKey('withdrawalFee', $currenciesArray); + self::assertArrayHasKey('walletConnect', $currenciesArray); + + self::assertEquals('BTH', $currenciesArray['code']); + self::assertTrue($currenciesArray['p2p']); + self::assertTrue($currenciesArray['dappBrowser']); + self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $currenciesArray['image']); + self::assertTrue($currenciesArray['paypro']); + self::assertEquals('BIP21', $currenciesArray['qr']['type']); + self::assertFalse($currenciesArray['qr']['collapsed']); + self::assertEquals('1.23', $currenciesArray['withdrawalFee']); + self::assertTrue($currenciesArray['walletConnect']); + } + + private function createClassObject(): Currencies + { + return new Currencies(); + } + + private function objectSetters(Currencies $currencies): void + { + $currencyQr = new CurrencyQr(); + $currencyQr->setType('BIP21'); + $currencyQr->setCollapsed(false); + + $currencies->setCode('BTH'); + $currencies->setP2p(true); + $currencies->setDappBrowser(true); + $currencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); + $currencies->setPayPro(true); + $currencies->setQr($currencyQr); + $currencies->setWithdrawalFee('1.23'); + $currencies->setWalletConnect(true); + } +} diff --git a/test/unit/BitPaySDK/Model/Wallet/CurrencyQrTest.php b/test/unit/BitPaySDK/Model/Wallet/CurrencyQrTest.php index b30d56ee..eeb37780 100644 --- a/test/unit/BitPaySDK/Model/Wallet/CurrencyQrTest.php +++ b/test/unit/BitPaySDK/Model/Wallet/CurrencyQrTest.php @@ -7,52 +7,52 @@ class CurrencyQrTest extends TestCase { - public function testInstanceOf() - { - $currencyQr = $this->createClassObject(); - self::assertInstanceOf(CurrencyQr::class, $currencyQr); - } - - public function testGetType() - { - $expectedType = 'BIP21'; - - $currencyQr = $this->createClassObject(); - $currencyQr->setType($expectedType); - self::assertEquals($expectedType, $currencyQr->getType()); - } - - public function testGetCollapsed() - { - $currencyQr = $this->createClassObject(); - $currencyQr->setCollapsed(false); - self::assertFalse($currencyQr->getCollapsed()); - } - - public function testToArray() - { - $currencyQr = $this->createClassObject(); - $this->objectSetters($currencyQr); - $currencyQrArray = $currencyQr->toArray(); - - self::assertNotNull($currencyQrArray); - self::assertIsArray($currencyQrArray); - - self::assertArrayHasKey('type', $currencyQrArray); - self::assertArrayHasKey('collapsed', $currencyQrArray); - - self::assertEquals('BIP21', $currencyQrArray['type']); - self::assertFalse($currencyQrArray['collapsed']); - } - - private function createClassObject(): CurrencyQr - { - return new CurrencyQr(); - } - - private function objectSetters(CurrencyQr $currencyQr): void - { - $currencyQr->setType('BIP21'); - $currencyQr->setCollapsed(false); - } -} \ No newline at end of file + public function testInstanceOf() + { + $currencyQr = $this->createClassObject(); + self::assertInstanceOf(CurrencyQr::class, $currencyQr); + } + + public function testGetType() + { + $expectedType = 'BIP21'; + + $currencyQr = $this->createClassObject(); + $currencyQr->setType($expectedType); + self::assertEquals($expectedType, $currencyQr->getType()); + } + + public function testGetCollapsed() + { + $currencyQr = $this->createClassObject(); + $currencyQr->setCollapsed(false); + self::assertFalse($currencyQr->getCollapsed()); + } + + public function testToArray() + { + $currencyQr = $this->createClassObject(); + $this->objectSetters($currencyQr); + $currencyQrArray = $currencyQr->toArray(); + + self::assertNotNull($currencyQrArray); + self::assertIsArray($currencyQrArray); + + self::assertArrayHasKey('type', $currencyQrArray); + self::assertArrayHasKey('collapsed', $currencyQrArray); + + self::assertEquals('BIP21', $currencyQrArray['type']); + self::assertFalse($currencyQrArray['collapsed']); + } + + private function createClassObject(): CurrencyQr + { + return new CurrencyQr(); + } + + private function objectSetters(CurrencyQr $currencyQr): void + { + $currencyQr->setType('BIP21'); + $currencyQr->setCollapsed(false); + } +} diff --git a/test/unit/BitPaySDK/Model/Wallet/WalletTest.php b/test/unit/BitPaySDK/Model/Wallet/WalletTest.php index 57fbda65..60fca567 100644 --- a/test/unit/BitPaySDK/Model/Wallet/WalletTest.php +++ b/test/unit/BitPaySDK/Model/Wallet/WalletTest.php @@ -51,7 +51,7 @@ public function testGetPayPro() public function testGetCurrencies() { - $currencyQr = new CurrencyQr; + $currencyQr = new CurrencyQr(); $currencyQr->setType('BIP21'); $currencyQr->setCollapsed(false); @@ -91,7 +91,7 @@ public function modifyUniCode(): void public function modifyOffChainMode(): void { $testedClass = $this->createClassObject(); - $expected = 'someValue'; + $expected = true; $testedClass->setOffChainMode($expected); self::assertEquals($expected, $testedClass->getOffChainMode()); @@ -145,7 +145,7 @@ private function createClassObject(): Wallet private function objectSetters(Wallet $wallet): void { - $currencyQr = new CurrencyQr; + $currencyQr = new CurrencyQr(); $currencyQr->setType('BIP21'); $currencyQr->setCollapsed(false); @@ -166,4 +166,4 @@ private function objectSetters(Wallet $wallet): void $wallet->setCurrencies($currencies); $wallet->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); } -} \ No newline at end of file +} diff --git a/test/unit/Logger/LoggerTest.php b/test/unit/Logger/LoggerTest.php index 0dcc2078..4938c883 100644 --- a/test/unit/Logger/LoggerTest.php +++ b/test/unit/Logger/LoggerTest.php @@ -18,7 +18,7 @@ public function testGetEmptyLoggerAsDefault(): void public function testChangeDefaultLogger(): void { - $customLogger = new class() implements BitPayLogger { + $customLogger = new class () implements BitPayLogger { public function logRequest(string $method, string $endpoint, ?string $json): void { }