Skip to content

Commit b982568

Browse files
committed
Merge branch 'release/2.0.1'
2 parents 99d8c73 + 35d3396 commit b982568

File tree

3 files changed

+29
-44
lines changed

3 files changed

+29
-44
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.0.1 - 2018-05-08
4+
- Issue #19 - WSDL_CACHE_WSDL does not work!
5+
- Code reviewed as it was not complete, default options were not taken into account properly too, it's working right from now on!
6+
37
## 2.0.0 - 2018-04-17
48
- Issue #15 - AbstractSoapClientBase should not define static SoapClient instance
59

src/AbstractSoapClientBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public function initSoapClient(array $options)
6565
$wsdlOptions = [];
6666
$defaultWsdlOptions = static::getDefaultWsdlOptions();
6767
foreach ($defaultWsdlOptions as $optionName => $optionValue) {
68-
if (array_key_exists($optionName, $options)) {
68+
if (array_key_exists($optionName, $options) && !is_null($options[$optionName])) {
6969
$wsdlOptions[str_replace(self::OPTION_PREFIX, '', $optionName)] = $options[$optionName];
70-
} elseif (!empty($optionValue)) {
70+
} elseif (!is_null($optionValue)) {
7171
$wsdlOptions[str_replace(self::OPTION_PREFIX, '', $optionName)] = $optionValue;
7272
}
7373
}

tests/SoapClientTest.php

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
declare(strict_types=1);
32

43
namespace WsdlToPhp\PackageBase\Tests;
54

@@ -220,11 +219,8 @@ public function testSetHeaders()
220219

221220
$this->assertTrue(is_resource($soapClient->getSoapClient()->_stream_context));
222221

223-
$this->assertSame(array(
224-
'http' => array(
225-
'header' => 'X-Header-Name: X-Header-Value',
226-
),
227-
), stream_context_get_options($soapClient->getSoapClient()->_stream_context));
222+
$o = stream_context_get_options($soapClient->getSoapClient()->_stream_context);
223+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
228224
}
229225
/**
230226
*
@@ -241,12 +237,9 @@ public function testSetHeadersOnExistingHeaders()
241237

242238
$this->assertTrue(is_resource($soapClient->getSoapClient()->_stream_context));
243239

244-
$this->assertSame(array(
245-
'http' => array(
246-
'header' => 'X-Header-Name: X-Header-Value' . "\r\n" .
247-
'X-Header-ID: X-Header-ID-Value',
248-
),
249-
), stream_context_get_options($soapClient->getSoapClient()->_stream_context));
240+
$o = stream_context_get_options($soapClient->getSoapClient()->_stream_context);
241+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
242+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-ID: X-Header-ID-Value') !== false);
250243
}
251244
/**
252245
*
@@ -271,17 +264,14 @@ public function testSetHeadersOnExistingHttpsHeaders()
271264

272265
$this->assertTrue(is_resource($soapClient->getSoapClient()->_stream_context));
273266

267+
$o = stream_context_get_options($soapClient->getSoapClient()->_stream_context);
274268
$this->assertSame(array(
275-
'https' => array(
276-
'header' => array(
277-
'X-HEADER' => 'X-VALUE',
278-
),
269+
'header' => array(
270+
'X-HEADER' => 'X-VALUE',
279271
),
280-
'http' => array(
281-
'header' => 'X-Header-Name: X-Header-Value' . "\r\n" .
282-
'X-Header-ID: X-Header-ID-Value',
283-
),
284-
), stream_context_get_options($soapClient->getSoapClient()->_stream_context));
272+
), $o['https']);
273+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
274+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-ID: X-Header-ID-Value') !== false);
285275
}
286276
/**
287277
*
@@ -306,15 +296,12 @@ public function testSetHeadersOnExistingHttpHeaders()
306296

307297
$this->assertTrue(is_resource($soapClient->getSoapClient()->_stream_context));
308298

299+
$o = stream_context_get_options($soapClient->getSoapClient()->_stream_context);
309300
$this->assertSame(array(
310-
'http' => array(
311-
'Auth' => array(
312-
'X-HEADER' => 'X-VALUE',
313-
),
314-
'header' => 'X-Header-Name: X-Header-Value' . "\r\n" .
315-
'X-Header-ID: X-Header-ID-Value',
316-
),
317-
), stream_context_get_options($soapClient->getSoapClient()->_stream_context));
301+
'X-HEADER' => 'X-VALUE',
302+
), $o['http']['Auth']);
303+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
304+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-ID: X-Header-ID-Value') !== false);
318305
}
319306
/**
320307
*
@@ -330,11 +317,8 @@ public function testGetStreamContext()
330317

331318
$this->assertTrue(is_resource($soapClient->getStreamContext()));
332319

333-
$this->assertSame(array(
334-
'http' => array(
335-
'header' => 'X-Header-Name: X-Header-Value',
336-
),
337-
), stream_context_get_options($soapClient->getStreamContext()));
320+
$o = stream_context_get_options($soapClient->getStreamContext());
321+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
338322
}
339323
/**
340324
*
@@ -375,15 +359,12 @@ public function testSetHeadersOnExistingHttpHeadersWithGetStreamContextOptions()
375359

376360
$this->assertTrue(is_resource($soapClient->getStreamContext()));
377361

362+
$o = $soapClient->getStreamContextOptions();
378363
$this->assertSame(array(
379-
'http' => array(
380-
'Auth' => array(
381-
'X-HEADER' => 'X-VALUE',
382-
),
383-
'header' => 'X-Header-Name: X-Header-Value' . "\r\n" .
384-
'X-Header-ID: X-Header-ID-Value',
385-
),
386-
), $soapClient->getStreamContextOptions());
364+
'X-HEADER' => 'X-VALUE',
365+
), $o['http']['Auth']);
366+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
367+
$this->assertTrue(strpos($o['http']['header'], 'X-Header-ID: X-Header-ID-Value') !== false);
387368
}
388369
/**
389370
*

0 commit comments

Comments
 (0)