44
55
66use WsdlToPhp \PackageBase \Utils ;
7-
87use WsdlToPhp \PackageBase \Tests \SoapClient ;
98
109class SoapClientTest extends TestCase
@@ -59,8 +58,8 @@ public function testSetLocation()
5958 public function testGetLastRequestAsString ()
6059 {
6160 $ soapClient = new SoapClient (array (
62- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
63- SoapClient::WSDL_CLASSMAP => self ::classMap (),
61+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
62+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
6463 ));
6564
6665 $ this ->assertSame (Utils::getFormatedXml (file_get_contents (__DIR__ . '/resources/oneline.xml ' )), $ soapClient ->getLastRequest (false ));
@@ -71,8 +70,8 @@ public function testGetLastRequestAsString()
7170 public function testGetLastRequestAsDomDocument ()
7271 {
7372 $ soapClient = new SoapClient (array (
74- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
75- SoapClient::WSDL_CLASSMAP => self ::classMap (),
73+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
74+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
7675 ));
7776
7877 $ this ->assertInstanceOf ('\\DOMDocument ' , $ soapClient ->getLastRequest (true ));
@@ -83,8 +82,8 @@ public function testGetLastRequestAsDomDocument()
8382 public function testGetLastResponseAsString ()
8483 {
8584 $ soapClient = new SoapClient (array (
86- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
87- SoapClient::WSDL_CLASSMAP => self ::classMap (),
85+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
86+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
8887 ));
8988
9089 $ this ->assertSame (Utils::getFormatedXml (file_get_contents (__DIR__ . '/resources/oneline.xml ' )), $ soapClient ->getLastResponse (false ));
@@ -95,8 +94,8 @@ public function testGetLastResponseAsString()
9594 public function testGetLastResponseAsDomDocument ()
9695 {
9796 $ soapClient = new SoapClient (array (
98- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
99- SoapClient::WSDL_CLASSMAP => self ::classMap (),
97+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
98+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
10099 ));
101100
102101 $ this ->assertInstanceOf ('\\DOMDocument ' , $ soapClient ->getLastResponse (true ));
@@ -107,8 +106,8 @@ public function testGetLastResponseAsDomDocument()
107106 public function testGetLastRequestHeadersAsString ()
108107 {
109108 $ soapClient = new SoapClient (array (
110- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
111- SoapClient::WSDL_CLASSMAP => self ::classMap (),
109+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
110+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
112111 ));
113112
114113 $ this ->assertSame ($ soapClient ->getSoapClient ()->__getLastRequestHeaders (), $ soapClient ->getLastRequestHeaders (false ));
@@ -119,8 +118,8 @@ public function testGetLastRequestHeadersAsString()
119118 public function testGetLastRequestHeadersAsArray ()
120119 {
121120 $ soapClient = new SoapClient (array (
122- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
123- SoapClient::WSDL_CLASSMAP => self ::classMap (),
121+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
122+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
124123 ));
125124
126125 $ this ->assertSame ($ soapClient ->getSoapClient ()->getLastRequestHeadersAsArray (), $ soapClient ->getLastRequestHeaders (true ));
@@ -131,8 +130,8 @@ public function testGetLastRequestHeadersAsArray()
131130 public function testGetLastResponseHeadersAsString ()
132131 {
133132 $ soapClient = new SoapClient (array (
134- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
135- SoapClient::WSDL_CLASSMAP => self ::classMap (),
133+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
134+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
136135 ));
137136
138137 $ this ->assertSame ($ soapClient ->getSoapClient ()->__getLastResponseHeaders (), $ soapClient ->getLastResponseHeaders (false ));
@@ -143,8 +142,8 @@ public function testGetLastResponseHeadersAsString()
143142 public function testGetLastResponseHeadersAsArray ()
144143 {
145144 $ soapClient = new SoapClient (array (
146- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
147- SoapClient::WSDL_CLASSMAP => self ::classMap (),
145+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
146+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
148147 ));
149148
150149 $ this ->assertSame ($ soapClient ->getSoapClient ()->getLastResponseHeadersAsArray (), $ soapClient ->getLastResponseHeaders (true ));
@@ -155,8 +154,8 @@ public function testGetLastResponseHeadersAsArray()
155154 public function testSetGetLastErrorForMethod ()
156155 {
157156 $ soapClient = new SoapClient (array (
158- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
159- SoapClient::WSDL_CLASSMAP => self ::classMap (),
157+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
158+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
160159 ));
161160
162161 // this call should fail as no parameter is defined in the request
@@ -170,8 +169,8 @@ public function testSetGetLastErrorForMethod()
170169 public function testSetGetLastError ()
171170 {
172171 $ soapClient = new SoapClient (array (
173- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
174- SoapClient::WSDL_CLASSMAP => self ::classMap (),
172+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
173+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
175174 ));
176175
177176 // this call should fail as no parameter is defined in the request
@@ -185,8 +184,8 @@ public function testSetGetLastError()
185184 public function testSetGetResult ()
186185 {
187186 $ soapClient = new SoapClient (array (
188- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
189- SoapClient::WSDL_CLASSMAP => self ::classMap (),
187+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
188+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
190189 ));
191190
192191 // this call should fail as no parameter is defined in the request
@@ -200,8 +199,8 @@ public function testSetGetResult()
200199 public function testSetHeaders ()
201200 {
202201 $ soapClient = new SoapClient (array (
203- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
204- SoapClient::WSDL_CLASSMAP => self ::classMap (),
202+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
203+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
205204 ));
206205
207206 $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-Name ' , 'X-Header-Value ' ));
@@ -220,8 +219,8 @@ public function testSetHeaders()
220219 public function testSetHeadersOnExistingHeaders ()
221220 {
222221 $ soapClient = new SoapClient (array (
223- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
224- SoapClient::WSDL_CLASSMAP => self ::classMap (),
222+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
223+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
225224 ));
226225
227226 $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-Name ' , 'X-Header-Value ' ));
@@ -249,9 +248,9 @@ public function testSetHeadersOnExistingHttpsHeaders()
249248 ),
250249 ));
251250 $ soapClient = new SoapClient (array (
252- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
253- SoapClient::WSDL_CLASSMAP => self ::classMap (),
254- SoapClient::WSDL_STREAM_CONTEXT => $ streamContext ,
251+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
252+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
253+ SoapClient::WSDL_STREAM_CONTEXT => $ streamContext ,
255254 ));
256255
257256 $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-Name ' , 'X-Header-Value ' ));
@@ -284,9 +283,9 @@ public function testSetHeadersOnExistingHttpHeaders()
284283 ),
285284 ));
286285 $ soapClient = new SoapClient (array (
287- SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
288- SoapClient::WSDL_CLASSMAP => self ::classMap (),
289- SoapClient::WSDL_STREAM_CONTEXT => $ streamContext ,
286+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
287+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
288+ SoapClient::WSDL_STREAM_CONTEXT => $ streamContext ,
290289 ));
291290
292291 $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-Name ' , 'X-Header-Value ' ));
@@ -304,6 +303,71 @@ public function testSetHeadersOnExistingHttpHeaders()
304303 ),
305304 ), stream_context_get_options (SoapClient::getSoapClient ()->_stream_context ));
306305 }
306+ /**
307+ *
308+ */
309+ public function testGetStreamContext ()
310+ {
311+ $ soapClient = new SoapClient (array (
312+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
313+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
314+ ));
315+
316+ $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-Name ' , 'X-Header-Value ' ));
317+
318+ $ this ->assertTrue (is_resource ($ soapClient ->getStreamContext ()));
319+
320+ $ this ->assertSame (array (
321+ 'http ' => array (
322+ 'header ' => 'X-Header-Name: X-Header-Value ' ,
323+ ),
324+ ), stream_context_get_options ($ soapClient ->getStreamContext ()));
325+ }
326+ /**
327+ *
328+ */
329+ public function testGetStreamContextAsNill ()
330+ {
331+ $ soapClient = new SoapClient (array (
332+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
333+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
334+ ));
335+
336+ $ this ->assertNull ($ soapClient ->getStreamContext ());
337+ }
338+ /**
339+ *
340+ */
341+ public function testSetHeadersOnExistingHttpHeadersWithGetStreamContextOptions ()
342+ {
343+ $ streamContext = stream_context_create (array (
344+ 'http ' => array (
345+ 'Auth ' => array (
346+ 'X-HEADER ' => 'X-VALUE ' ,
347+ ),
348+ ),
349+ ));
350+ $ soapClient = new SoapClient (array (
351+ SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl ' ,
352+ SoapClient::WSDL_CLASSMAP => self ::classMap (),
353+ SoapClient::WSDL_STREAM_CONTEXT => $ streamContext ,
354+ ));
355+
356+ $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-Name ' , 'X-Header-Value ' ));
357+ $ this ->assertTrue ($ soapClient ->setHttpHeader ('X-Header-ID ' , 'X-Header-ID-Value ' ));
358+
359+ $ this ->assertTrue (is_resource ($ soapClient ->getStreamContext ()));
360+
361+ $ this ->assertSame (array (
362+ 'http ' => array (
363+ 'Auth ' => array (
364+ 'X-HEADER ' => 'X-VALUE ' ,
365+ ),
366+ 'header ' => 'X-Header-Name: X-Header-Value ' . "\r\n" .
367+ 'X-Header-ID: X-Header-ID-Value ' ,
368+ ),
369+ ), $ soapClient ->getStreamContextOptions ());
370+ }
307371 /**
308372 *
309373 */
0 commit comments