|
| 1 | +<?php |
| 2 | + |
| 3 | +use MusahMusah\LaravelMultipaymentGateways\Contracts\FlutterwaveContract; |
| 4 | + |
| 5 | +beforeEach(function () { |
| 6 | + $this->flutterwave = $this->mock(FlutterwaveContract::class); |
| 7 | +}); |
| 8 | + |
| 9 | +it('can instantiate FlutterwaveContract instance', function () { |
| 10 | + expect($this->flutterwave) |
| 11 | + ->toBeObject() |
| 12 | + ->toBeInstanceOf(FlutterwaveContract::class); |
| 13 | +}); |
| 14 | + |
| 15 | +it('can create a transfer beneficiary', function () { |
| 16 | + |
| 17 | + $beneficiaryPayload = [ |
| 18 | + 'account_bank' => '044', |
| 19 | + 'account_number' => '0690000032', |
| 20 | + 'beneficiary_name' => 'Flutterwave Developers', |
| 21 | + 'currency' => 'NGN', |
| 22 | + 'bank_name' => 'Beneficiary Bank', |
| 23 | + ]; |
| 24 | + |
| 25 | + $this->flutterwave |
| 26 | + ->shouldReceive('createTransferBeneficiary') |
| 27 | + ->once() |
| 28 | + ->withArgs([$beneficiaryPayload]) |
| 29 | + ->andReturn([ |
| 30 | + 'status' => 'success', |
| 31 | + 'message' => 'Transfer beneficiary created', |
| 32 | + 'data' => ['*'], |
| 33 | + ]); |
| 34 | + |
| 35 | + expect($this->flutterwave->createTransferBeneficiary($beneficiaryPayload)) |
| 36 | + ->toBeArray() |
| 37 | + ->toBe([ |
| 38 | + 'status' => 'success', |
| 39 | + 'message' => 'Transfer beneficiary created', |
| 40 | + 'data' => ['*'], |
| 41 | + ]); |
| 42 | +}); |
| 43 | + |
| 44 | +it('can delete a transfer beneficiary a subscription', function () { |
| 45 | + |
| 46 | + $beneficiaryId = 1234; |
| 47 | + |
| 48 | + $this->flutterwave |
| 49 | + ->shouldReceive('deleteTransferBeneficiary') |
| 50 | + ->once() |
| 51 | + ->withArgs([$beneficiaryId]) |
| 52 | + ->andReturn([ |
| 53 | + 'status' => true, |
| 54 | + 'message' => 'Transfer beneficiary deleted', |
| 55 | + 'data' => ['*'], |
| 56 | + ]); |
| 57 | + |
| 58 | + expect($this->flutterwave->deleteTransferBeneficiary($beneficiaryId)) |
| 59 | + ->toBeArray() |
| 60 | + ->toBe([ |
| 61 | + 'status' => true, |
| 62 | + 'message' => 'Transfer beneficiary deleted', |
| 63 | + 'data' => ['*'], |
| 64 | + ]); |
| 65 | +}); |
| 66 | + |
| 67 | +it('can get information for a transfer beneficiary', function () { |
| 68 | + |
| 69 | + $beneficiaryId = 1234; |
| 70 | + |
| 71 | + $this->flutterwave |
| 72 | + ->shouldReceive('getTransferBeneficiary') |
| 73 | + ->once() |
| 74 | + ->withArgs([$beneficiaryId]) |
| 75 | + ->andReturn([ |
| 76 | + 'status' => true, |
| 77 | + 'message' => 'Beneficiary retrieved', |
| 78 | + 'data' => ['*'], |
| 79 | + ]); |
| 80 | + |
| 81 | + expect($this->flutterwave->getTransferBeneficiary($beneficiaryId)) |
| 82 | + ->toBeArray() |
| 83 | + ->toBe([ |
| 84 | + 'status' => true, |
| 85 | + 'message' => 'Beneficiary retrieved', |
| 86 | + 'data' => ['*'], |
| 87 | + ]); |
| 88 | +}); |
| 89 | + |
| 90 | +it('can get information for all transfer beneficiaries', function () { |
| 91 | + |
| 92 | + $queryParams = ['page' => 1]; |
| 93 | + |
| 94 | + $this->flutterwave |
| 95 | + ->shouldReceive('getAllTransferBeneficiaries') |
| 96 | + ->once() |
| 97 | + ->withArgs([$queryParams]) |
| 98 | + ->andReturn([ |
| 99 | + 'status' => true, |
| 100 | + 'message' => 'All Transfer Beneficiaries retrieved', |
| 101 | + 'data' => ['*'], |
| 102 | + ]); |
| 103 | + |
| 104 | + expect($this->flutterwave->getAllTransferBeneficiaries($queryParams)) |
| 105 | + ->toBeArray() |
| 106 | + ->toBe([ |
| 107 | + 'status' => true, |
| 108 | + 'message' => 'All Transfer Beneficiaries retrieved', |
| 109 | + 'data' => ['*'], |
| 110 | + ]); |
| 111 | +}); |
0 commit comments