diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index 6f4819f6..4c223fe7 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -78,9 +78,9 @@ class Invoice protected bool $extendedNotifications = false; protected ?bool $isCancelled = null; protected ?string $transactionCurrency = null; - protected ?int $underpaidAmount = null; - protected ?int $overpaidAmount = null; - protected ?int $amountPaid = null; + protected ?float $underpaidAmount = null; + protected ?float $overpaidAmount = null; + protected ?float $amountPaid = null; protected ?string $displayAmountPaid = null; protected ?array $exchangeRates = null; protected ?bool $bitpayIdRequired = null; @@ -1455,9 +1455,9 @@ public function setPaymentCodes(?array $paymentCodes) * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @return int|null + * @return float|null */ - public function getUnderpaidAmount(): ?int + public function getUnderpaidAmount(): ?float { return $this->underpaidAmount; } @@ -1470,9 +1470,9 @@ public function getUnderpaidAmount(): ?int * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @param int $underpaidAmount the underpaid amount + * @param float|null $underpaidAmount the underpaid amount */ - public function setUnderpaidAmount(int $underpaidAmount): void + public function setUnderpaidAmount(?float $underpaidAmount): void { $this->underpaidAmount = $underpaidAmount; } @@ -1485,9 +1485,9 @@ public function setUnderpaidAmount(int $underpaidAmount): void * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @return int|null + * @return float|null */ - public function getOverpaidAmount(): ?int + public function getOverpaidAmount(): ?float { return $this->overpaidAmount; } @@ -1500,9 +1500,9 @@ public function getOverpaidAmount(): ?int * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @param int $overpaidAmount the overpaid amount + * @param float|null $overpaidAmount the overpaid amount */ - public function setOverpaidAmount(int $overpaidAmount): void + public function setOverpaidAmount(?float $overpaidAmount): void { $this->overpaidAmount = $overpaidAmount; } @@ -1714,9 +1714,9 @@ public function setTransactionCurrency(string $transactionCurrency): void * The total amount paid to the invoice in terms of the invoice transactionCurrency indicated * in the smallest possible unit for the corresponding transactionCurrency (e.g satoshis for BTC and BCH) * - * @return int|null + * @return float|null */ - public function getAmountPaid(): ?int + public function getAmountPaid(): ?float { return $this->amountPaid; } @@ -1727,9 +1727,9 @@ public function getAmountPaid(): ?int * The total amount paid to the invoice in terms of the invoice transactionCurrency indicated * in the smallest possible unit for the corresponding transactionCurrency (e.g satoshis for BTC and BCH) * - * @param int $amountPaid The total amount paid to the invoice + * @param float|null $amountPaid The total amount paid to the invoice */ - public function setAmountPaid(int $amountPaid): void + public function setAmountPaid(?float $amountPaid): void { $this->amountPaid = $amountPaid; } diff --git a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php index 9f601cb1..57fcb5c7 100644 --- a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php +++ b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php @@ -29,7 +29,7 @@ class InvoiceWebhook protected ?array $paymentSubtotals; protected ?array $paymentTotals; protected ?array $exchangeRates; - protected ?int $amountPaid; + protected ?float $amountPaid; protected ?string $orderId; protected ?string $transactionCurrency; @@ -163,12 +163,12 @@ public function setExchangeRates(?array $exchangeRates): void $this->exchangeRates = $exchangeRates; } - public function getAmountPaid(): ?int + public function getAmountPaid(): ?float { return $this->amountPaid; } - public function setAmountPaid(?int $amountPaid): void + public function setAmountPaid(?float $amountPaid): void { $this->amountPaid = $amountPaid; } diff --git a/src/BitPaySDK/Model/Invoice/RefundWebhook.php b/src/BitPaySDK/Model/Invoice/RefundWebhook.php index 8299ca3d..ac2187ce 100644 --- a/src/BitPaySDK/Model/Invoice/RefundWebhook.php +++ b/src/BitPaySDK/Model/Invoice/RefundWebhook.php @@ -22,7 +22,7 @@ class RefundWebhook protected ?string $invoice = null; protected ?string $supportRequest = null; protected ?string $status = null; - protected ?int $amount = null; + protected ?float $amount = null; protected ?string $currency = null; protected ?string $lastRefundNotification = null; protected ?float $refundFee = null; @@ -70,12 +70,12 @@ public function setStatus(?string $status): void $this->status = $status; } - public function getAmount(): ?int + public function getAmount(): ?float { return $this->amount; } - public function setAmount(?int $amount): void + public function setAmount(?float $amount): void { $this->amount = $amount; } diff --git a/test/unit/BitPaySDK/Model/CurrencyTest.php b/test/unit/BitPaySDK/Model/CurrencyTest.php index df337d04..2f553cdc 100644 --- a/test/unit/BitPaySDK/Model/CurrencyTest.php +++ b/test/unit/BitPaySDK/Model/CurrencyTest.php @@ -132,6 +132,14 @@ public function testGetDecimals() self::assertEquals($expected, $currency->getDecimals()); } + public function testModifyChain(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setChain($expected); + + self::assertEquals($expected, $testedClass->getChain()); + } private function createClassObject(): Currency { diff --git a/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php b/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php index cfd3952a..6c21c7ec 100644 --- a/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php @@ -99,7 +99,6 @@ public function testManipulateBuyerZip(): void self::assertEquals($expected, $testedClass->getBuyerZip()); } - private function getTestedClass(): BuyerFields { return new BuyerFields(); diff --git a/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php b/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php new file mode 100644 index 00000000..e7f8ef2e --- /dev/null +++ b/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php @@ -0,0 +1,145 @@ +getTestedClass(); + $expected = 12.23; + $testedClass->setAmountPaid($expected); + self::assertEquals($expected, $testedClass->getamountPaid()); + } + + public function testManipulateBuyerFields(): void + { + $testedClass = $this->getTestedClass(); + $expected = new BuyerFields(); + $testedClass->setBuyerFields($expected); + self::assertEquals($expected, $testedClass->getbuyerFields()); + } + + public function testManipulateCurrency(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setCurrency($expected); + self::assertEquals($expected, $testedClass->getCurrency()); + } + + public function testManipulateCurrencyTime(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setCurrencyTime($expected); + self::assertEquals($expected, $testedClass->getCurrencyTime()); + } + + public function testManipulateExceptionStatus(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setExceptionStatus($expected); + self::assertEquals($expected, $testedClass->getExceptionStatus()); + } + + public function testManipulateExchangeRates(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setExchangeRates($expected); + self::assertEquals($expected, $testedClass->getExchangeRates()); + } + + public function testManipulateId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setid($expected); + self::assertEquals($expected, $testedClass->getId()); + } + + public function testManipulateInvoiceTime(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setInvoiceTime($expected); + self::assertEquals($expected, $testedClass->getInvoiceTime()); + } + + public function testManipulateOrderId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setOrderId($expected); + self::assertEquals($expected, $testedClass->getOrderId()); + } + + public function testManipulate_paymentSubtotals(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setPaymentSubtotals($expected); + self::assertEquals($expected, $testedClass->getPaymentSubtotals()); + } + + public function testManipulatePaymentTotals(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setPaymentTotals($expected); + self::assertEquals($expected, $testedClass->getPaymentTotals()); + } + + public function testManipulatePosData(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setPosData($expected); + self::assertEquals($expected, $testedClass->getPosData()); + } + + public function testManipulatePrice(): void + { + $testedClass = $this->getTestedClass(); + $expected = 123.78; + $testedClass->setPrice($expected); + self::assertEquals($expected, $testedClass->getPrice()); + } + + public function testManipulateStatus(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setStatus($expected); + self::assertEquals($expected, $testedClass->getStatus()); + } + + public function testManipulateTransactionCurrency(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setTransactionCurrency($expected); + self::assertEquals($expected, $testedClass->getTransactionCurrency()); + } + + public function testManipulateUrl(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setUrl($expected); + self::assertEquals($expected, $testedClass->getUrl()); + } + + private function getTestedClass(): InvoiceWebhook + { + return new InvoiceWebhook(); + } +} diff --git a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php index b0f1c330..d34a7334 100644 --- a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php @@ -7,13 +7,13 @@ class BuyerTest extends TestCase { - public function testInstanceOf() + public function testInstanceOf(): void { $buyer = $this->createClassObject(); self::assertInstanceOf(Buyer::class, $buyer); } - public function testGetName() + public function testModifyBuyerName(): void { $expectedName = 'Test Name'; @@ -22,7 +22,7 @@ public function testGetName() self::assertEquals($expectedName, $buyer->getBuyerName()); } - public function testGetAddress1() + public function testModifyBuyerAddress1(): void { $expectedAddress1 = 'Address 1'; @@ -31,7 +31,7 @@ public function testGetAddress1() self::assertEquals($expectedAddress1, $buyer->getBuyerAddress1()); } - public function testGetAddress2() + public function testModifyBuyerAddress2(): void { $expectedAddress2 = 'Address 2'; @@ -40,7 +40,7 @@ public function testGetAddress2() self::assertEquals($expectedAddress2, $buyer->getBuyerAddress2()); } - public function testGetCity() + public function testModifyBuyerCity(): void { $expectedCity = 'Miami'; @@ -49,7 +49,7 @@ public function testGetCity() self::assertEquals($expectedCity, $buyer->getBuyerCity()); } - public function testGetState() + public function testModifyBuyerState(): void { $expectedState = 'AB'; @@ -58,7 +58,7 @@ public function testGetState() self::assertEquals($expectedState, $buyer->getBuyerState()); } - public function testGetZip() + public function testModifyBuyerZip(): void { $expectedZip = '12345'; @@ -67,7 +67,7 @@ public function testGetZip() self::assertEquals($expectedZip, $buyer->getBuyerZip()); } - public function testGetCountry() + public function testModifyBuyerCountry(): void { $expectedCountry = 'Canada'; @@ -76,7 +76,7 @@ public function testGetCountry() self::assertEquals($expectedCountry, $buyer->getBuyerCountry()); } - public function testGetEmail() + public function testModifyBuyerEmail(): void { $expectedEmail = 'test@email.com'; @@ -85,7 +85,7 @@ public function testGetEmail() self::assertEquals($expectedEmail, $buyer->getBuyerEmail()); } - public function testGetPhone() + public function testModifyBuyerPhone(): void { $expectedPhone = '123456789'; @@ -94,7 +94,7 @@ public function testGetPhone() self::assertEquals($expectedPhone, $buyer->getBuyerPhone()); } - public function testGetNotify() + public function testModifyBuyerNotify(): void { $buyer = $this->createClassObject(); $buyer->setBuyerNotify(true); @@ -104,7 +104,7 @@ public function testGetNotify() self::assertFalse($buyer->getBuyerNotify()); } - public function testToArray() + public function testToArray(): void { $buyer = $this->createClassObject(); $this->setSetters($buyer); diff --git a/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php b/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php new file mode 100644 index 00000000..a1ba47fb --- /dev/null +++ b/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php @@ -0,0 +1,160 @@ +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()); + } + + private function getTestedClass(): PayoutWebhook + { + return new PayoutWebhook(); + } +} diff --git a/test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php b/test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php new file mode 100644 index 00000000..3f13b8a1 --- /dev/null +++ b/test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php @@ -0,0 +1,61 @@ +getTestedClass(); + $expected = 'someValue'; + $testedClass->setEmail($expected); + + self::assertEquals($expected, $testedClass->getEmail()); + } + + 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 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()); + } + + private function getTestedClass(): RecipientWebhook + { + return new RecipientWebhook(); + } +} diff --git a/test/unit/BitPaySDK/Model/Wallet/WalletTest.php b/test/unit/BitPaySDK/Model/Wallet/WalletTest.php index 066d030d..57fbda65 100644 --- a/test/unit/BitPaySDK/Model/Wallet/WalletTest.php +++ b/test/unit/BitPaySDK/Model/Wallet/WalletTest.php @@ -9,134 +9,161 @@ class WalletTest extends TestCase { - public function testInstanceOf() - { - $wallet = $this->createClassObject(); - self::assertInstanceOf(Wallet::class, $wallet); - } - - public function testGetKey() - { - $expectedKey = 'abcd123'; - - $wallet = $this->createClassObject(); - $wallet->setKey($expectedKey); - self::assertEquals($expectedKey, $wallet->getKey()); - } - - public function testGetDisplayName() - { - $expectedDisplayName = 'My Wallet'; - - $wallet = $this->createClassObject(); - $wallet->setDisplayName($expectedDisplayName); - self::assertEquals($expectedDisplayName, $wallet->getDisplayName()); - } - - public function testGetAvatar() - { - $expectedAvatar = 'image.png'; - - $wallet = $this->createClassObject(); - $wallet->setAvatar($expectedAvatar); - self::assertEquals($expectedAvatar, $wallet->getAvatar()); - } - - public function testGetPayPro() - { - $wallet = $this->createClassObject(); - $wallet->setPayPro(true); - self::assertTrue($wallet->getPayPro()); - } - - public function testGetCurrencies() - { - $currencyQr = new CurrencyQr; - $currencyQr->setType('BIP21'); - $currencyQr->setCollapsed(false); - - $expectedCurrencies = new Currencies(); - $expectedCurrencies->setCode('BTH'); - $expectedCurrencies->setP2p(true); - $expectedCurrencies->setDappBrowser(true); - $expectedCurrencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); - $expectedCurrencies->setPayPro(true); - $expectedCurrencies->setQr($currencyQr); - $expectedCurrencies->setWithdrawalFee('1.23'); - $expectedCurrencies->setWalletConnect(true); - - $wallet = $this->createClassObject(); - $wallet->setCurrencies($expectedCurrencies); - self::assertEquals($expectedCurrencies, $wallet->getCurrencies()); - } - - public function testGetImage() - { - $expectedImage = 'https://bitpay.com/api/images/logo-6fa5404d.svg'; - - $wallet = $this->createClassObject(); - $wallet->setImage($expectedImage); - self::assertEquals($expectedImage, $wallet->getImage()); - } - - public function testToArray() - { - $wallet = $this->createClassObject(); - $this->objectSetters($wallet); - $walletArray = $wallet->toArray(); - - self::assertNotNull($walletArray); - self::assertIsArray($walletArray); - - self::assertArrayHasKey('key', $walletArray); - self::assertArrayHasKey('displayName', $walletArray); - self::assertArrayHasKey('avatar', $walletArray); - self::assertArrayHasKey('paypro', $walletArray); - self::assertArrayHasKey('currencies', $walletArray); - self::assertArrayHasKey('image', $walletArray); - - self::assertEquals('abcd123', $walletArray['key']); - self::assertEquals('My Wallet', $walletArray['displayName']); - self::assertEquals('image.png', $walletArray['avatar']); - self::assertTrue($walletArray['paypro']); - self::assertEquals('BTH', $walletArray['currencies']['code']); - self::assertTrue($walletArray['currencies']['p2p']); - self::assertTrue($walletArray['currencies']['dappBrowser']); - self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['currencies']['image']); - self::assertTrue($walletArray['currencies']['paypro']); - self::assertEquals('BIP21', $walletArray['currencies']['qr']['type']); - self::assertFalse($walletArray['currencies']['qr']['collapsed']); - self::assertEquals('1.23', $walletArray['currencies']['withdrawalFee']); - self::assertTrue($walletArray['currencies']['walletConnect']); - self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['image']); - } - - private function createClassObject(): Wallet - { - return new Wallet(); - } - - private function objectSetters(Wallet $wallet): void - { - $currencyQr = new CurrencyQr; - $currencyQr->setType('BIP21'); - $currencyQr->setCollapsed(false); - - $currencies = new Currencies(); - $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); - - $wallet->setKey('abcd123'); - $wallet->setDisplayName('My Wallet'); - $wallet->setAvatar('image.png'); - $wallet->setPayPro(true); - $wallet->setCurrencies($currencies); - $wallet->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); - } + public function testInstanceOf() + { + $wallet = $this->createClassObject(); + self::assertInstanceOf(Wallet::class, $wallet); + } + + public function testGetKey() + { + $expectedKey = 'abcd123'; + + $wallet = $this->createClassObject(); + $wallet->setKey($expectedKey); + self::assertEquals($expectedKey, $wallet->getKey()); + } + + public function testGetDisplayName() + { + $expectedDisplayName = 'My Wallet'; + + $wallet = $this->createClassObject(); + $wallet->setDisplayName($expectedDisplayName); + self::assertEquals($expectedDisplayName, $wallet->getDisplayName()); + } + + public function testGetAvatar() + { + $expectedAvatar = 'image.png'; + + $wallet = $this->createClassObject(); + $wallet->setAvatar($expectedAvatar); + self::assertEquals($expectedAvatar, $wallet->getAvatar()); + } + + public function testGetPayPro() + { + $wallet = $this->createClassObject(); + $wallet->setPayPro(true); + self::assertTrue($wallet->getPayPro()); + } + + public function testGetCurrencies() + { + $currencyQr = new CurrencyQr; + $currencyQr->setType('BIP21'); + $currencyQr->setCollapsed(false); + + $expectedCurrencies = new Currencies(); + $expectedCurrencies->setCode('BTH'); + $expectedCurrencies->setP2p(true); + $expectedCurrencies->setDappBrowser(true); + $expectedCurrencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); + $expectedCurrencies->setPayPro(true); + $expectedCurrencies->setQr($currencyQr); + $expectedCurrencies->setWithdrawalFee('1.23'); + $expectedCurrencies->setWalletConnect(true); + + $wallet = $this->createClassObject(); + $wallet->setCurrencies($expectedCurrencies); + self::assertEquals($expectedCurrencies, $wallet->getCurrencies()); + } + + public function testGetImage() + { + $expectedImage = 'https://bitpay.com/api/images/logo-6fa5404d.svg'; + + $wallet = $this->createClassObject(); + $wallet->setImage($expectedImage); + self::assertEquals($expectedImage, $wallet->getImage()); + } + + public function modifyUniCode(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setUniCode($expected); + + self::assertEquals($expected, $testedClass->getUniCode()); + } + + public function modifyOffChainMode(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setOffChainMode($expected); + + self::assertEquals($expected, $testedClass->getOffChainMode()); + } + + public function modifyInvoiceDefault(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setInvoiceDefault($expected); + + self::assertEquals($expected, $testedClass->getInvoiceDefault()); + } + + public function testToArray() + { + $wallet = $this->createClassObject(); + $this->objectSetters($wallet); + $walletArray = $wallet->toArray(); + + self::assertNotNull($walletArray); + self::assertIsArray($walletArray); + + self::assertArrayHasKey('key', $walletArray); + self::assertArrayHasKey('displayName', $walletArray); + self::assertArrayHasKey('avatar', $walletArray); + self::assertArrayHasKey('paypro', $walletArray); + self::assertArrayHasKey('currencies', $walletArray); + self::assertArrayHasKey('image', $walletArray); + + self::assertEquals('abcd123', $walletArray['key']); + self::assertEquals('My Wallet', $walletArray['displayName']); + self::assertEquals('image.png', $walletArray['avatar']); + self::assertTrue($walletArray['paypro']); + self::assertEquals('BTH', $walletArray['currencies']['code']); + self::assertTrue($walletArray['currencies']['p2p']); + self::assertTrue($walletArray['currencies']['dappBrowser']); + self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['currencies']['image']); + self::assertTrue($walletArray['currencies']['paypro']); + self::assertEquals('BIP21', $walletArray['currencies']['qr']['type']); + self::assertFalse($walletArray['currencies']['qr']['collapsed']); + self::assertEquals('1.23', $walletArray['currencies']['withdrawalFee']); + self::assertTrue($walletArray['currencies']['walletConnect']); + self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['image']); + } + + private function createClassObject(): Wallet + { + return new Wallet(); + } + + private function objectSetters(Wallet $wallet): void + { + $currencyQr = new CurrencyQr; + $currencyQr->setType('BIP21'); + $currencyQr->setCollapsed(false); + + $currencies = new Currencies(); + $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); + + $wallet->setKey('abcd123'); + $wallet->setDisplayName('My Wallet'); + $wallet->setAvatar('image.png'); + $wallet->setPayPro(true); + $wallet->setCurrencies($currencies); + $wallet->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); + } } \ No newline at end of file