xref: /php-src/ext/soap/tests/bugs/bug49278.phpt (revision de354683)
1--TEST--
2Bug #49278 (SoapClient::__getLastResponseHeaders returns NULL if wsdl operation !has output)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--SKIPIF--
8<?php
9    if (!file_exists(__DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc")) {
10        echo "skip sapi/cli/tests/php_cli_server.inc required but not found";
11    }
12?>
13--FILE--
14<?php
15
16include __DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc";
17
18$args = ["-d", "extension_dir=" . ini_get("extension_dir"), "-d", "extension=" . (substr(PHP_OS, 0, 3) == "WIN" ? "php_" : "") . "soap." . PHP_SHLIB_SUFFIX];
19if (php_ini_loaded_file()) {
20  // Necessary such that it works from a development directory in which case extension_dir might not be the real extension dir
21  $args[] = "-c";
22  $args[] = php_ini_loaded_file();
23}
24$code = '$server = new SoapServer("' . __DIR__ . '"/bug49278.wsdl", ["trace"=>1]);' .
25        <<<'PHP'
26        function Add() {}
27        $server->addFunction('Add');
28        $server->handle();
29        PHP;
30
31php_cli_server_start($code, null, $args);
32
33$client = new SoapClient(__DIR__ . '/bug49278.wsdl', array('location' => "http://".PHP_CLI_SERVER_ADDRESS, 'trace' => 1));
34$client->Add();
35var_dump($client->__getLastResponse());
36var_dump($client->__getLastResponse());
37var_dump($client->__getLastRequestHeaders());
38var_dump($client->__getLastResponseHeaders());
39
40?>
41--EXPECTF--
42string(0) ""
43string(0) ""
44string(%d) "POST / HTTP/1.1
45Host: %s
46Connection: Keep-Alive
47User-Agent: PHP-SOAP/%s
48Content-Type: text/xml; charset=utf-8
49SOAPAction: "Add"
50Content-Length: %d
51
52"
53string(%s) "HTTP/1.1 200 OK
54Host: %s
55Date: %s
56Connection: close
57X-Powered-By: PHP/%s
58Content-type: text/html; charset=UTF-8
59"
60