xref: /PHP-8.0/ext/soap/tests/fault_warning.phpt (revision c4a25da0)
1--TEST--
2SoapFault class: Invalid Fault code warning given? Can't be an empty string, an array of not 2 elements etc.
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7
8try {
9    new SoapFault("", "message"); // Can't be an empty string
10} catch (ValueError $exception) {
11    echo $exception->getMessage() . "\n";
12}
13
14try {
15    new SoapFault(new stdClass(), "message");  // Can't be a non-string (except for null)
16} catch (TypeError $exception) {
17    echo $exception->getMessage() . "\n";
18}
19
20$fault = new SoapFault("Sender", "message");
21echo get_class($fault) . "\n";
22$fault = new SoapFault(null, "message");
23echo get_class($fault) . "\n";
24
25try {
26    new SoapFault(["more"], "message");  // two elements in array required
27} catch (ValueError $exception) {
28    echo $exception->getMessage() . "\n";
29}
30
31try {
32    new SoapFault(["m", "more", "superfluous"], "message"); // two required
33} catch (ValueError $exception) {
34    echo $exception->getMessage() . "\n";
35}
36
37$fault = new SoapFault(["more-ns", "Sender"], "message");  // two given
38echo get_class($fault);
39
40?>
41--EXPECT--
42SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
43SoapFault::__construct(): Argument #1 ($code) must be of type array|string|null, stdClass given
44SoapFault
45SoapFault
46SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
47SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
48SoapFault
49