|
| 1 | +--TEST-- |
| 2 | +SoapClient and SoapServer classmap options must only contain string keys |
| 3 | +--EXTENSIONS-- |
| 4 | +soap |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +$emptyHash = ['type' => 'stdClass']; |
| 9 | +unset($emptyHash['type']); |
| 10 | + |
| 11 | +$cases = [ |
| 12 | + 'empty' => [], |
| 13 | + 'empty hash' => $emptyHash, |
| 14 | + 'packed' => ['stdClass'], |
| 15 | + 'sparse numeric' => [100 => 'stdClass'], |
| 16 | + 'numeric string' => ['1' => 'stdClass'], |
| 17 | + 'mixed' => ['type' => 'stdClass', 1 => 'stdClass'], |
| 18 | + 'associative' => ['type' => 'stdClass'], |
| 19 | +]; |
| 20 | + |
| 21 | +foreach ($cases as $name => $classmap) { |
| 22 | + echo "-- $name --\n"; |
| 23 | + |
| 24 | + try { |
| 25 | + new SoapClient(null, [ |
| 26 | + 'location' => 'http://example.com/', |
| 27 | + 'uri' => 'urn:test', |
| 28 | + 'classmap' => $classmap, |
| 29 | + ]); |
| 30 | + echo "SoapClient: OK\n"; |
| 31 | + } catch (Throwable $e) { |
| 32 | + echo $e->getMessage(), "\n"; |
| 33 | + } |
| 34 | + |
| 35 | + try { |
| 36 | + new SoapServer(null, [ |
| 37 | + 'uri' => 'urn:test', |
| 38 | + 'classmap' => $classmap, |
| 39 | + ]); |
| 40 | + echo "SoapServer: OK\n"; |
| 41 | + } catch (Throwable $e) { |
| 42 | + echo $e->getMessage(), "\n"; |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +?> |
| 47 | +--EXPECT-- |
| 48 | +-- empty -- |
| 49 | +SoapClient: OK |
| 50 | +SoapServer: OK |
| 51 | +-- empty hash -- |
| 52 | +SoapClient: OK |
| 53 | +SoapServer: OK |
| 54 | +-- packed -- |
| 55 | +SoapClient::__construct(): 'classmap' option must be an associative array |
| 56 | +SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array |
| 57 | +-- sparse numeric -- |
| 58 | +SoapClient::__construct(): 'classmap' option must be an associative array |
| 59 | +SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array |
| 60 | +-- numeric string -- |
| 61 | +SoapClient::__construct(): 'classmap' option must be an associative array |
| 62 | +SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array |
| 63 | +-- mixed -- |
| 64 | +SoapClient::__construct(): 'classmap' option must be an associative array |
| 65 | +SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array |
| 66 | +-- associative -- |
| 67 | +SoapClient: OK |
| 68 | +SoapServer: OK |
0 commit comments