Skip to content

Commit 51c2cf0

Browse files
committed
ext/soap: Add some SoapServer tests
1 parent d8d1cb4 commit 51c2cf0

File tree

3 files changed

+250
-0
lines changed

3 files changed

+250
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
--TEST--
2+
SoapServer handle with WSDL that has disappeared
3+
--EXTENSIONS--
4+
soap
5+
--GET--
6+
WSDL
7+
--FILE--
8+
<?php
9+
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
10+
11+
$wsdl = <<<'WSDL'
12+
<?xml version="1.0" ?>
13+
<definitions
14+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
15+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
16+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
17+
xmlns="http://schemas.xmlsoap.org/wsdl/">
18+
19+
<types>
20+
<xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl">
21+
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
22+
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
23+
</xsd:schema>
24+
</types>
25+
26+
<message name="AddRequest">
27+
<part name="x" type="xsd:double" />
28+
<part name="y" type="xsd:double" />
29+
</message>
30+
<message name="AddResponse">
31+
<part name="result" type="xsd:double" />
32+
</message>
33+
34+
<portType name="TestServicePortType">
35+
<operation name="Add">
36+
<input message="tns:AddRequest" />
37+
<output message="tns:AddResponse" />
38+
</operation>
39+
</portType>
40+
41+
<binding name="TestServiceBinding" type="tns:TestServicePortType">
42+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
43+
<operation name="Add">
44+
<soap:operation soapAction="Add" style="rpc" />
45+
<input>
46+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
47+
</input>
48+
<output>
49+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
50+
</output>
51+
</operation>
52+
</binding>
53+
54+
<service name="TestService">
55+
<port name="TestServicePort" binding="tns:TestServiceBinding">
56+
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" />
57+
</port>
58+
</service>
59+
60+
</definitions>
61+
WSDL;
62+
63+
file_put_contents($wsdlFile, $wsdl);
64+
65+
$options = [];
66+
$server = new SoapServer($wsdlFile, $options);
67+
68+
unlink($wsdlFile);
69+
70+
$server->handle();
71+
72+
?>
73+
--CLEAN--
74+
<?php
75+
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
76+
@unlink($wsdlFile);
77+
?>
78+
--EXPECT--
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
--TEST--
2+
SoapServer handle with WSDL that has disappeared and disabled readfile function
3+
--EXTENSIONS--
4+
soap
5+
--GET--
6+
WSDL
7+
--INI--
8+
disable_functions=readfile
9+
--FILE--
10+
<?php
11+
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
12+
13+
$wsdl = <<<'WSDL'
14+
<?xml version="1.0" ?>
15+
<definitions
16+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
17+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
18+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
19+
xmlns="http://schemas.xmlsoap.org/wsdl/">
20+
21+
<types>
22+
<xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl">
23+
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
24+
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
25+
</xsd:schema>
26+
</types>
27+
28+
<message name="AddRequest">
29+
<part name="x" type="xsd:double" />
30+
<part name="y" type="xsd:double" />
31+
</message>
32+
<message name="AddResponse">
33+
<part name="result" type="xsd:double" />
34+
</message>
35+
36+
<portType name="TestServicePortType">
37+
<operation name="Add">
38+
<input message="tns:AddRequest" />
39+
<output message="tns:AddResponse" />
40+
</operation>
41+
</portType>
42+
43+
<binding name="TestServiceBinding" type="tns:TestServicePortType">
44+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
45+
<operation name="Add">
46+
<soap:operation soapAction="Add" style="rpc" />
47+
<input>
48+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
49+
</input>
50+
<output>
51+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
52+
</output>
53+
</operation>
54+
</binding>
55+
56+
<service name="TestService">
57+
<port name="TestServicePort" binding="tns:TestServiceBinding">
58+
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" />
59+
</port>
60+
</service>
61+
62+
</definitions>
63+
WSDL;
64+
65+
file_put_contents($wsdlFile, $wsdl);
66+
67+
$options = [];
68+
$server = new SoapServer($wsdlFile, $options);
69+
70+
unlink($wsdlFile);
71+
72+
try {
73+
$server->handle();
74+
} catch (Throwable $e) {
75+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
76+
}
77+
?>
78+
--CLEAN--
79+
<?php
80+
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
81+
@unlink($wsdlFile);
82+
?>
83+
--EXPECT--
84+
Error: Invalid callback readfile, function "readfile" not found or invalid function name
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
--TEST--
2+
SoapServer handle with WSDL that has disappeared and disabled and redefined readfile function
3+
--EXTENSIONS--
4+
soap
5+
--GET--
6+
WSDL
7+
--INI--
8+
disable_functions=readfile
9+
--FILE--
10+
<?php
11+
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
12+
13+
$wsdl = <<<'WSDL'
14+
<?xml version="1.0" ?>
15+
<definitions
16+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
17+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
18+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
19+
xmlns="http://schemas.xmlsoap.org/wsdl/">
20+
21+
<types>
22+
<xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl">
23+
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
24+
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
25+
</xsd:schema>
26+
</types>
27+
28+
<message name="AddRequest">
29+
<part name="x" type="xsd:double" />
30+
<part name="y" type="xsd:double" />
31+
</message>
32+
<message name="AddResponse">
33+
<part name="result" type="xsd:double" />
34+
</message>
35+
36+
<portType name="TestServicePortType">
37+
<operation name="Add">
38+
<input message="tns:AddRequest" />
39+
<output message="tns:AddResponse" />
40+
</operation>
41+
</portType>
42+
43+
<binding name="TestServiceBinding" type="tns:TestServicePortType">
44+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
45+
<operation name="Add">
46+
<soap:operation soapAction="Add" style="rpc" />
47+
<input>
48+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
49+
</input>
50+
<output>
51+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
52+
</output>
53+
</operation>
54+
</binding>
55+
56+
<service name="TestService">
57+
<port name="TestServicePort" binding="tns:TestServiceBinding">
58+
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" />
59+
</port>
60+
</service>
61+
62+
</definitions>
63+
WSDL;
64+
65+
function readfile(string $str) {
66+
throw new Exception('BOO');
67+
}
68+
69+
file_put_contents($wsdlFile, $wsdl);
70+
71+
$options = [];
72+
$server = new SoapServer($wsdlFile, $options);
73+
74+
unlink($wsdlFile);
75+
76+
try {
77+
$server->handle();
78+
} catch (Throwable $e) {
79+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
80+
}
81+
?>
82+
--CLEAN--
83+
<?php
84+
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
85+
@unlink($wsdlFile);
86+
?>
87+
--EXPECT--
88+
Exception: BOO

0 commit comments

Comments
 (0)