fault_warning.phpt 1.4 KB

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