|
3 | 3 | namespace BitPaySDK\Test; |
4 | 4 |
|
5 | 5 | use BitPaySDK\Client; |
| 6 | +use BitPaySDK\Env; |
6 | 7 | use BitPaySDK\Exceptions\BillCreationException; |
7 | 8 | use BitPaySDK\Exceptions\BillDeliveryException; |
8 | 9 | use BitPaySDK\Exceptions\BillQueryException; |
|
47 | 48 | use BitPaySDK\Model\Ledger\LedgerEntry; |
48 | 49 | use BitPaySDK\Model\Payout\Payout; |
49 | 50 | use BitPaySDK\Model\Payout\PayoutBatch; |
| 51 | +use BitPaySDK\Model\Payout\PayoutInstruction; |
50 | 52 | use BitPaySDK\Model\Payout\PayoutRecipient; |
51 | 53 | use BitPaySDK\Model\Payout\PayoutRecipients; |
| 54 | +use BitPaySDK\Model\Payout\RecipientReferenceMethod; |
52 | 55 | use BitPaySDK\Model\Rate\Rate; |
53 | 56 | use BitPaySDK\Model\Rate\Rates; |
54 | 57 | use BitPaySDK\Model\Settlement\Settlement; |
55 | 58 | use BitPaySDK\Model\Subscription\Subscription; |
56 | 59 | use BitPaySDK\Model\Wallet\Wallet; |
| 60 | +use BitPaySDK\Tokens; |
57 | 61 | use BitPaySDK\Util\RESTcli\RESTcli; |
58 | 62 | use Exception; |
59 | 63 | use PHPUnit\Framework\TestCase; |
60 | | -use BitPaySDK\Env; |
61 | | -use BitPaySDK\Tokens; |
62 | 64 |
|
63 | 65 |
|
64 | 66 | class ClientTest extends TestCase |
@@ -2334,15 +2336,22 @@ public function testGetPayoutBatch($testedObject) |
2334 | 2336 | $examplePayoutBatchId = 'test'; |
2335 | 2337 | $params['token'] = $this->getPayoutTokenFromFile(); |
2336 | 2338 | $restCliMock = $this->getRestCliMock(); |
2337 | | - $restCliMock->expects($this->once())->method('get')->with("payoutBatches/" . $examplePayoutBatchId, $params)->willReturn(self::CORRECT_JSON_STRING); |
| 2339 | + $restCliMock->expects(self::once())->method('get') |
| 2340 | + ->with("payoutBatches/" . $examplePayoutBatchId, $params) |
| 2341 | + ->willReturn(file_get_contents('json/getPayoutBatchResponse.json', true)); |
2338 | 2342 | $setRestCli = function () use ($restCliMock) { |
2339 | 2343 | $this->_RESTcli = $restCliMock; |
2340 | 2344 | }; |
2341 | 2345 | $doSetRestCli = $setRestCli->bindTo($testedObject, get_class($testedObject)); |
2342 | 2346 | $doSetRestCli(); |
2343 | 2347 |
|
2344 | 2348 | $result = $testedObject->getPayoutBatch($examplePayoutBatchId); |
2345 | | - $this->assertInstanceOf(PayoutBatch::class, $result); |
| 2349 | + self::assertEquals('8dJGJ65BhrKJmcgfChfg65dn6fuENkKzhgf3hg4hglkj675hn', $result->getToken()); |
| 2350 | + self::assertEquals(24.0, $result->getAmount()); |
| 2351 | + self::assertEquals('USD', $result->getLedgerCurrency()); |
| 2352 | + self::assertEquals('1-855-4-BITPAY', $result->getSupportPhone()); |
| 2353 | + self::assertEquals('LRNmxyjRN1e2JUc6fhgfd', $result->getId()); |
| 2354 | + self::assertEquals(12.0, $result->getInstructions()[0]->amount); |
2346 | 2355 | } |
2347 | 2356 |
|
2348 | 2357 | /** |
@@ -3046,27 +3055,32 @@ public function testRequestPayoutBatchNotificationShouldCatchJsonEncodeException |
3046 | 3055 | */ |
3047 | 3056 | public function testSubmitPayoutBatch($testedObject) |
3048 | 3057 | { |
3049 | | - $payoutBatchMock = $this->createMock(PayoutBatch::class); |
3050 | | - $exampleCurrency = Currency::USD; |
3051 | | - $payoutBatchToArray = [ |
3052 | | - 'token' => $this->getPayoutTokenFromFile(), |
3053 | | - 'currency' => $exampleCurrency |
3054 | | - ]; |
| 3058 | + $payoutBatchMock = new PayoutBatch(); |
| 3059 | + $payoutInstruction = new PayoutInstruction(12, RecipientReferenceMethod::EMAIL, 'any@email.com'); |
| 3060 | + $payoutInstruction2 = new PayoutInstruction(12, RecipientReferenceMethod::EMAIL, 'any2@email.com'); |
3055 | 3061 |
|
3056 | | - $payoutBatchMock->method('getCurrency')->willReturn(Currency::USD); |
3057 | | - $payoutBatchMock->method('toArray')->willReturn($payoutBatchToArray); |
3058 | | - $restCliMock = $this->getRestCliMock(); |
3059 | | - $restCliMock->expects($this->once())->method('post')->with("payoutBatches", $payoutBatchMock->toArray()) |
3060 | | - ->willReturn(json_encode($payoutBatchMock->toArray())); |
| 3062 | + $payoutBatchMock->setToken($this->getPayoutTokenFromFile()); |
| 3063 | + $payoutBatchMock->setCurrency(Currency::USD); |
| 3064 | + $payoutBatchMock->setLedgerCurrency(Currency::USD); |
| 3065 | + $payoutBatchMock->setInstructions([$payoutInstruction, $payoutInstruction2]); |
3061 | 3066 |
|
| 3067 | + $restCliMock = $this->getRestCliMock(); |
| 3068 | + $restCliMock->expects(self::once())->method('post')->with("payoutBatches", $payoutBatchMock->toArray()) |
| 3069 | + ->willReturn(file_get_contents('json/getPayoutBatchResponse.json', true)); |
3062 | 3070 | $setRestCli = function () use ($restCliMock) { |
3063 | 3071 | $this->_RESTcli = $restCliMock; |
3064 | 3072 | }; |
| 3073 | + |
3065 | 3074 | $doSetRestCli = $setRestCli->bindTo($testedObject, get_class($testedObject)); |
3066 | 3075 | $doSetRestCli(); |
3067 | 3076 |
|
3068 | 3077 | $result = $testedObject->submitPayoutBatch($payoutBatchMock); |
3069 | | - $this->assertInstanceOf(PayoutBatch::class, $result); |
| 3078 | + self::assertEquals('8dJGJ65BhrKJmcgfChfg65dn6fuENkKzhgf3hg4hglkj675hn', $result->getToken()); |
| 3079 | + self::assertEquals(24.0, $result->getAmount()); |
| 3080 | + self::assertEquals('USD', $result->getLedgerCurrency()); |
| 3081 | + self::assertEquals('1-855-4-BITPAY', $result->getSupportPhone()); |
| 3082 | + self::assertEquals('LRNmxyjRN1e2JUc6fhgfd', $result->getId()); |
| 3083 | + self::assertEquals(12.0, $result->getInstructions()[0]->amount); |
3070 | 3084 | } |
3071 | 3085 |
|
3072 | 3086 | /** |
|
0 commit comments