Skip to content

Commit c3559d3

Browse files
authored
Merge pull request php-vcr#171 from renatomefi/pr/154
Fixes php-vcr#153: SoapClient::__getLastRequest() returns NULL in PHP 5.3 and 5.4
2 parents 1330000 + e6d2bce commit c3559d3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/VCR/Util/SoapClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public function __construct($wsdl, $options = array()) {
4747
*/
4848
public function __doRequest($request, $location, $action, $version, $one_way = 0)
4949
{
50-
$this->request = $request;
50+
// Save a copy of the request, not the request itself -- see issue #153
51+
$this->request = (string) $request;
5152

5253
$soapHook = $this->getLibraryHook();
5354

tests/VCR/LibraryHooks/SoapHookTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ public function testShouldHandleSOAPVersion12()
7272
$client->GetCityWeatherByZIP(array('ZIP' => '10013'));
7373
}
7474

75+
public function testShouldReturnLastRequestWithTraceOn()
76+
{
77+
$this->soapHook->enable($this->getContentCheckCallback());
78+
79+
$client = new \SoapClient(
80+
'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL',
81+
array('soap_version' => SOAP_1_1, 'trace' => 1)
82+
);
83+
$client->setLibraryHook($this->soapHook);
84+
$client->GetCityWeatherByZIP(array('ZIP' => '10013'));
85+
$actual = $client->__getLastRequest();
86+
87+
$this->soapHook->disable();
88+
$this->assertTrue(!is_null($actual), '__getLastRequest() returned NULL.');
89+
}
90+
7591
/**
7692
* @return \callable
7793
*/

0 commit comments

Comments
 (0)