File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
Test/Unit/Gateway/Http/Client Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,21 @@ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $tr
43
43
44
44
$ client ->setConfig ($ transferObject ->getClientConfig ());
45
45
$ client ->setMethod ($ transferObject ->getMethod ());
46
- $ client ->setParameterPost ($ transferObject ->getBody ());
46
+
47
+ switch ($ transferObject ->getMethod ()) {
48
+ case \Zend_Http_Client::GET :
49
+ $ client ->setParameterGet ($ transferObject ->getBody ());
50
+ break ;
51
+ case \Zend_Http_Client::POST :
52
+ $ client ->setParameterPost ($ transferObject ->getBody ());
53
+ break ;
54
+ default :
55
+ throw new \LogicException (sprintf ('Unsupported HTTP method %s ' , $ transferObject ->getMethod ()));
56
+ }
57
+
47
58
$ client ->setHeaders ($ transferObject ->getHeaders ());
48
59
$ client ->setUrlEncodeBody ($ transferObject ->shouldEncode ());
60
+ $ client ->setUri ($ transferObject ->getUri ());
49
61
50
62
try {
51
63
$ response = $ client ->request ();
Original file line number Diff line number Diff line change @@ -41,4 +41,11 @@ public function shouldEncode();
41
41
* @return string
42
42
*/
43
43
public function getBody ();
44
+
45
+ /**
46
+ * Returns URI
47
+ *
48
+ * @return string
49
+ */
50
+ public function getUri ();
44
51
}
Original file line number Diff line number Diff line change @@ -127,21 +127,24 @@ public function testPlaceRequestConvertResponseFail()
127
127
private function setClientTransferObjects ()
128
128
{
129
129
$ config = ['key1 ' => 'value1 ' , 'key2 ' => 'value2 ' ];
130
- $ method = ' methodName ' ;
130
+ $ method = \Zend_Http_Client:: POST ;
131
131
$ headers = ['key1 ' => 'value1 ' , 'key2 ' => 'value2 ' ];
132
132
$ body = 'Body content ' ;
133
+ $ uri = 'https://example.com/listener ' ;
133
134
$ shouldEncode = true ;
134
135
135
136
$ this ->transferObjectMock ->expects ($ this ->once ())->method ('getClientConfig ' )->willReturn ($ config );
136
- $ this ->transferObjectMock ->expects ($ this ->once ())->method ('getMethod ' )->willReturn ($ method );
137
+ $ this ->transferObjectMock ->expects ($ this ->atLeastOnce ())->method ('getMethod ' )->willReturn ($ method );
137
138
$ this ->transferObjectMock ->expects ($ this ->once ())->method ('getHeaders ' )->willReturn ($ headers );
138
139
$ this ->transferObjectMock ->expects ($ this ->once ())->method ('getBody ' )->willReturn ($ body );
139
140
$ this ->transferObjectMock ->expects ($ this ->once ())->method ('shouldEncode ' )->willReturn ($ shouldEncode );
141
+ $ this ->transferObjectMock ->expects ($ this ->once ())->method ('getUri ' )->willReturn ($ uri );
140
142
141
143
$ this ->clientMock ->expects ($ this ->once ())->method ('setConfig ' )->with ($ config )->willReturnSelf ();
142
144
$ this ->clientMock ->expects ($ this ->once ())->method ('setMethod ' )->with ($ method )->willReturnSelf ();
143
145
$ this ->clientMock ->expects ($ this ->once ())->method ('setParameterPost ' )->with ($ body )->willReturnSelf ();
144
146
$ this ->clientMock ->expects ($ this ->once ())->method ('setHeaders ' )->with ($ headers )->willReturnSelf ();
145
147
$ this ->clientMock ->expects ($ this ->once ())->method ('setUrlEncodeBody ' )->with ($ shouldEncode )->willReturnSelf ();
148
+ $ this ->clientMock ->expects ($ this ->once ())->method ('setUri ' )->with ($ uri )->willReturnSelf ();
146
149
}
147
150
}
You can’t perform that action at this time.
0 commit comments