|
35 | 35 | expect($result)->toBe($expectedResult); |
36 | 36 | }); |
37 | 37 |
|
38 | | -test('bank calls expected methods and returns result', function () { |
| 38 | +test('updateOrganisation calls expected methods and returns result', function () { |
39 | 39 | $mock = $this->getMockBuilder(PaymentPlatformAPI::class) |
40 | 40 | ->onlyMethods(['init', 'setVersion', 'setData', 'setEndpoint', 'setRequestType', 'execute']) |
41 | 41 | ->getMock(); |
42 | 42 |
|
43 | 43 | $id = '1'; |
44 | | - $includes = ['statuses']; |
45 | | - $version = 'v2.1'; |
| 44 | + $data = ['name' => 'Updated Organisation']; |
| 45 | + $version = 'v3.0'; |
46 | 46 |
|
47 | 47 | $mock->expects($this->once())->method('init')->willReturnSelf(); |
48 | 48 | $mock->expects($this->once())->method('setVersion')->with($version)->willReturnSelf(); |
49 | | - $mock->expects($this->once())->method('setData')->with($this->callback(function ($data) use ($includes) { |
| 49 | + $mock->expects($this->once())->method('setData')->with(['form_params' => $data])->willReturnSelf(); |
| 50 | + $mock->expects($this->once())->method('setEndpoint')->with('organisations/'.$id)->willReturnSelf(); |
| 51 | + $mock->expects($this->once())->method('setRequestType')->with('PUT')->willReturnSelf(); |
| 52 | + |
| 53 | + $expectedResult = 'update-bank-result'; |
| 54 | + $mock->expects($this->once())->method('execute')->willReturn($expectedResult); |
| 55 | + |
| 56 | + $result = $mock->updateOrganisation($id, $data, $version); |
| 57 | + expect($result)->toBe($expectedResult); |
| 58 | +}); |
| 59 | + |
| 60 | +test('createOrganisation calls expected methods and returns result', function () { |
| 61 | + $mock = $this->getMockBuilder(PaymentPlatformAPI::class) |
| 62 | + ->onlyMethods(['init', 'setVersion', 'setData', 'setEndpoint', 'setRequestType', 'execute']) |
| 63 | + ->getMock(); |
| 64 | + |
| 65 | + $data = ['name' => 'New Organisation']; |
| 66 | + $version = 'v4.0'; |
| 67 | + |
| 68 | + $mock->expects($this->once())->method('init')->willReturnSelf(); |
| 69 | + $mock->expects($this->once())->method('setVersion')->with($version)->willReturnSelf(); |
| 70 | + $mock->expects($this->once())->method('setData')->with(['form_params' => $data])->willReturnSelf(); |
| 71 | + $mock->expects($this->once())->method('setEndpoint')->with('organisations')->willReturnSelf(); |
| 72 | + $mock->expects($this->once())->method('setRequestType')->with('POST')->willReturnSelf(); |
| 73 | + |
| 74 | + $expectedResult = 'create-organisation-result'; |
| 75 | + $mock->expects($this->once())->method('execute')->willReturn($expectedResult); |
| 76 | + |
| 77 | + $result = $mock->createOrganisation($data, $version); |
| 78 | + expect($result)->toBe($expectedResult); |
| 79 | +}); |
| 80 | + |
| 81 | +test('allowedOrganisationStatuses calls expected methods and returns result', function () { |
| 82 | + $mock = $this->getMockBuilder(PaymentPlatformAPI::class) |
| 83 | + ->onlyMethods(['init', 'setVersion', 'setData', 'setEndpoint', 'setRequestType', 'execute']) |
| 84 | + ->getMock(); |
| 85 | + |
| 86 | + $version = 'v5.0'; |
| 87 | + |
| 88 | + $mock->expects($this->once())->method('init')->willReturnSelf(); |
| 89 | + $mock->expects($this->once())->method('setVersion')->with($version)->willReturnSelf(); |
| 90 | + $mock->expects($this->once())->method('setData')->with($this->callback(function ($data) { |
50 | 91 | parse_str($data['query'], $queryArray); |
51 | 92 |
|
52 | | - return $queryArray['include'] === $includes; |
| 93 | + return $queryArray === []; |
53 | 94 | }))->willReturnSelf(); |
54 | | - $mock->expects($this->once())->method('setEndpoint')->with('banks/show/'.$id)->willReturnSelf(); |
| 95 | + $mock->expects($this->once())->method('setEndpoint')->with('organisations/allowedStatuses')->willReturnSelf(); |
55 | 96 | $mock->expects($this->once())->method('setRequestType')->with('GET')->willReturnSelf(); |
56 | 97 |
|
57 | | - $expectedResult = 'bank-result'; |
| 98 | + $expectedResult = 'allowed-statuses-result'; |
58 | 99 | $mock->expects($this->once())->method('execute')->willReturn($expectedResult); |
59 | 100 |
|
60 | | - $result = $mock->bank($id, $includes, $version); |
| 101 | + $result = $mock->allowedOrganisationStatuses($version); |
61 | 102 | expect($result)->toBe($expectedResult); |
62 | 103 | }); |
63 | | -// |
64 | | -//test('updateBank calls expected methods and returns result', function () { |
65 | | -// $mock = $this->getMockBuilder(PaymentPlatformAPI::class) |
66 | | -// ->onlyMethods(['init', 'setVersion', 'setData', 'setEndpoint', 'setRequestType', 'execute']) |
67 | | -// ->getMock(); |
68 | | -// |
69 | | -// $id = 'bank-101'; |
70 | | -// $data = ['name' => 'Updated Bank']; |
71 | | -// $version = 'v3.0'; |
72 | | -// |
73 | | -// $mock->expects($this->once())->method('init')->willReturnSelf(); |
74 | | -// $mock->expects($this->once())->method('setVersion')->with($version)->willReturnSelf(); |
75 | | -// $mock->expects($this->once())->method('setData')->with(['form_params' => $data])->willReturnSelf(); |
76 | | -// $mock->expects($this->once())->method('setEndpoint')->with('banks/'.$id)->willReturnSelf(); |
77 | | -// $mock->expects($this->once())->method('setRequestType')->with('PUT')->willReturnSelf(); |
78 | | -// |
79 | | -// $expectedResult = 'update-bank-result'; |
80 | | -// $mock->expects($this->once())->method('execute')->willReturn($expectedResult); |
81 | | -// |
82 | | -// $result = $mock->updateBank($id, $data, $version); |
83 | | -// expect($result)->toBe($expectedResult); |
84 | | -//}); |
85 | | -// |
86 | | -//test('createBank calls expected methods and returns result', function () { |
87 | | -// $mock = $this->getMockBuilder(PaymentPlatformAPI::class) |
88 | | -// ->onlyMethods(['init', 'setVersion', 'setData', 'setEndpoint', 'setRequestType', 'execute']) |
89 | | -// ->getMock(); |
90 | | -// |
91 | | -// $data = ['name' => 'New Bank']; |
92 | | -// $version = 'v4.0'; |
93 | | -// |
94 | | -// $mock->expects($this->once())->method('init')->willReturnSelf(); |
95 | | -// $mock->expects($this->once())->method('setVersion')->with($version)->willReturnSelf(); |
96 | | -// $mock->expects($this->once())->method('setData')->with(['form_params' => $data])->willReturnSelf(); |
97 | | -// $mock->expects($this->once())->method('setEndpoint')->with('banks')->willReturnSelf(); |
98 | | -// $mock->expects($this->once())->method('setRequestType')->with('POST')->willReturnSelf(); |
99 | | -// |
100 | | -// $expectedResult = 'create-bank-result'; |
101 | | -// $mock->expects($this->once())->method('execute')->willReturn($expectedResult); |
102 | | -// |
103 | | -// $result = $mock->createBank($data, $version); |
104 | | -// expect($result)->toBe($expectedResult); |
105 | | -//}); |
106 | | -// |
107 | | -//test('allowedBankStatuses calls expected methods and returns result', function () { |
108 | | -// $mock = $this->getMockBuilder(PaymentPlatformAPI::class) |
109 | | -// ->onlyMethods(['init', 'setVersion', 'setData', 'setEndpoint', 'setRequestType', 'execute']) |
110 | | -// ->getMock(); |
111 | | -// |
112 | | -// $version = 'v5.0'; |
113 | | -// |
114 | | -// $mock->expects($this->once())->method('init')->willReturnSelf(); |
115 | | -// $mock->expects($this->once())->method('setVersion')->with($version)->willReturnSelf(); |
116 | | -// $mock->expects($this->once())->method('setData')->with($this->callback(function ($data) { |
117 | | -// parse_str($data['query'], $queryArray); |
118 | | -// |
119 | | -// return $queryArray === []; |
120 | | -// }))->willReturnSelf(); |
121 | | -// $mock->expects($this->once())->method('setEndpoint')->with('banks/allowedStatuses')->willReturnSelf(); |
122 | | -// $mock->expects($this->once())->method('setRequestType')->with('GET')->willReturnSelf(); |
123 | | -// |
124 | | -// $expectedResult = 'allowed-statuses-result'; |
125 | | -// $mock->expects($this->once())->method('execute')->willReturn($expectedResult); |
126 | | -// |
127 | | -// $result = $mock->allowedBankStatuses($version); |
128 | | -// expect($result)->toBe($expectedResult); |
129 | | -//}); |
0 commit comments