@@ 71-96 (lines=26) @@ | ||
68 | /** |
|
69 | * @test |
|
70 | */ |
|
71 | public function magicCallClientReturnError() |
|
72 | { |
|
73 | $this->deferredHttpBinding = new FulfilledPromise($this->httpBindingMock); |
|
74 | ||
75 | $this->httpBindingMock->method('request') |
|
76 | ->willReturn( |
|
77 | new Request('POST', 'www.endpoint.com') |
|
78 | ) |
|
79 | ->with( |
|
80 | 'someSoapMethod', [['some-key' => 'some-value']] |
|
81 | ); |
|
82 | ||
83 | $response = new Response('500'); |
|
84 | $this->httpBindingMock->method('response') |
|
85 | ->willReturn( |
|
86 | 'SoapResult' |
|
87 | ) |
|
88 | ->with( |
|
89 | $response, 'someSoapMethod', null |
|
90 | ); |
|
91 | ||
92 | $this->handlerMock->append(GuzzleRequestException::create(new Request('POST', 'www.endpoint.com'), $response)); |
|
93 | ||
94 | $client = new SoapClient($this->clientMock, $this->deferredHttpBinding); |
|
95 | $this->assertEquals('SoapResult', $client->someSoapMethod(['some-key' => 'some-value'])->wait()); |
|
96 | } |
|
97 | ||
98 | /** |
|
99 | * @test |
|
@@ 102-127 (lines=26) @@ | ||
99 | * @test |
|
100 | * @expectedException \SoapFault |
|
101 | */ |
|
102 | public function magicCallClientReturnSoapFault() |
|
103 | { |
|
104 | $this->deferredHttpBinding = new FulfilledPromise($this->httpBindingMock); |
|
105 | ||
106 | $this->httpBindingMock->method('request') |
|
107 | ->willReturn( |
|
108 | new Request('POST', 'www.endpoint.com') |
|
109 | ) |
|
110 | ->with( |
|
111 | 'someSoapMethod', [['some-key' => 'some-value']] |
|
112 | ); |
|
113 | ||
114 | $response = new Response('200', [], 'body'); |
|
115 | $this->httpBindingMock->method('response') |
|
116 | ->will( |
|
117 | $this->throwException(new \SoapFault('soap fault', 'soap fault')) |
|
118 | ) |
|
119 | ->with( |
|
120 | $response, 'someSoapMethod', null |
|
121 | ); |
|
122 | ||
123 | $this->handlerMock->append($response); |
|
124 | ||
125 | $client = new SoapClient($this->clientMock, $this->deferredHttpBinding); |
|
126 | $client->someSoapMethod(['some-key' => 'some-value'])->wait(); |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * @test |
|
@@ 132-157 (lines=26) @@ | ||
129 | /** |
|
130 | * @test |
|
131 | */ |
|
132 | public function magicCallSuccess() |
|
133 | { |
|
134 | $this->deferredHttpBinding = new FulfilledPromise($this->httpBindingMock); |
|
135 | ||
136 | $this->httpBindingMock->method('request') |
|
137 | ->willReturn( |
|
138 | new Request('POST', 'www.endpoint.com') |
|
139 | ) |
|
140 | ->with( |
|
141 | 'someSoapMethod', [['some-key' => 'some-value']] |
|
142 | ); |
|
143 | ||
144 | $response = new Response('200', [], 'body'); |
|
145 | $this->httpBindingMock->method('response') |
|
146 | ->willReturn( |
|
147 | 'SoapResult' |
|
148 | ) |
|
149 | ->with( |
|
150 | $response, 'someSoapMethod', null |
|
151 | ); |
|
152 | ||
153 | $this->handlerMock->append($response); |
|
154 | ||
155 | $client = new SoapClient($this->clientMock, $this->deferredHttpBinding); |
|
156 | $this->assertEquals('SoapResult', $client->someSoapMethod(['some-key' => 'some-value'])->wait()); |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * @test |