|
@@ 116-147 (lines=32) @@
|
| 113 |
|
* @test |
| 114 |
|
* @expectedException \SoapFault |
| 115 |
|
*/ |
| 116 |
|
public function magicCallClientReturnSoapFault() |
| 117 |
|
{ |
| 118 |
|
$this->deferredInterpreter = new FulfilledPromise($this->interpreterMock); |
| 119 |
|
|
| 120 |
|
$this->interpreterMock->method('request') |
| 121 |
|
->willReturn( |
| 122 |
|
new SoapRequest('www.endpoint.com', 'soapaction', '2', 'message') |
| 123 |
|
) |
| 124 |
|
->with( |
| 125 |
|
'someSoapMethod', [['some-key' => 'some-value']] |
| 126 |
|
); |
| 127 |
|
|
| 128 |
|
$this->interpreterMock->method('response') |
| 129 |
|
->will( |
| 130 |
|
$this->throwException(new \SoapFault('soap fault', 'soap fault')) |
| 131 |
|
) |
| 132 |
|
->with( |
| 133 |
|
'body', 'someSoapMethod', null |
| 134 |
|
); |
| 135 |
|
|
| 136 |
|
$this->httpBindingMock->expects($this->never())->method('isSOAP11'); |
| 137 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('isSOAP12'); |
| 138 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('setEndpoint')->with('www.endpoint.com'); |
| 139 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('setSoapAction')->with('soapaction'); |
| 140 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('setSoapMessage')->with('message'); |
| 141 |
|
$this->httpBindingMock->method('getSoapHttpRequest')->willReturn(new Request('POST', 'www.endpoint.com')); |
| 142 |
|
|
| 143 |
|
$this->handlerMock->append(new Response('200', [], 'body')); |
| 144 |
|
|
| 145 |
|
$client = new SoapClient($this->clientMock, $this->deferredInterpreter, $this->httpBindingMock); |
| 146 |
|
$client->someSoapMethod(['some-key' => 'some-value'])->wait(); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
/** |
| 150 |
|
* @test |
|
@@ 152-183 (lines=32) @@
|
| 149 |
|
/** |
| 150 |
|
* @test |
| 151 |
|
*/ |
| 152 |
|
public function magicCallSuccess() |
| 153 |
|
{ |
| 154 |
|
$this->deferredInterpreter = new FulfilledPromise($this->interpreterMock); |
| 155 |
|
|
| 156 |
|
$this->interpreterMock->method('request') |
| 157 |
|
->willReturn( |
| 158 |
|
new SoapRequest('www.endpoint.com', 'soapaction', '1', 'message') |
| 159 |
|
) |
| 160 |
|
->with( |
| 161 |
|
'someSoapMethod', [['some-key' => 'some-value']] |
| 162 |
|
); |
| 163 |
|
|
| 164 |
|
$this->interpreterMock->method('response') |
| 165 |
|
->willReturn( |
| 166 |
|
'SoapResult' |
| 167 |
|
) |
| 168 |
|
->with( |
| 169 |
|
'body', 'someSoapMethod', null |
| 170 |
|
); |
| 171 |
|
|
| 172 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('isSOAP11'); |
| 173 |
|
$this->httpBindingMock->expects($this->never())->method('isSOAP12'); |
| 174 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('setEndpoint')->with('www.endpoint.com'); |
| 175 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('setSoapAction')->with('soapaction'); |
| 176 |
|
$this->httpBindingMock->expects($this->exactly(1))->method('setSoapMessage')->with('message'); |
| 177 |
|
$this->httpBindingMock->method('getSoapHttpRequest')->willReturn(new Request('POST', 'www.endpoint.com')); |
| 178 |
|
|
| 179 |
|
$this->handlerMock->append(new Response('200', [], 'body')); |
| 180 |
|
|
| 181 |
|
$client = new SoapClient($this->clientMock, $this->deferredInterpreter, $this->httpBindingMock); |
| 182 |
|
$this->assertEquals('SoapResult', $client->someSoapMethod(['some-key' => 'some-value'])->wait()); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
/** |
| 186 |
|
* @test |