|
| 1 | +--TEST-- |
| 2 | +PHPC-655: Use case insensitive parsing for Manager connectTimeoutMS array option |
| 3 | +--SKIPIF-- |
| 4 | +<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM does not use custom streams"); ?> |
| 5 | +<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> |
| 6 | +--FILE-- |
| 7 | +<?php |
| 8 | +require_once __DIR__ . "/../utils/basic.inc"; |
| 9 | + |
| 10 | +$command = new MongoDB\Driver\Command(['ping' => 1]); |
| 11 | + |
| 12 | +// Invalid host cannot be resolved |
| 13 | +$manager = new MongoDB\Driver\Manager('mongodb://invalid.host:27017', ['connectTimeoutMS' => 1]); |
| 14 | + |
| 15 | +ini_set('mongodb.debug', 'stderr'); |
| 16 | + |
| 17 | +echo throws(function() use ($manager, $command) { |
| 18 | + $manager->executeCommand(DATABASE_NAME, $command); |
| 19 | +}, 'MongoDB\Driver\Exception\ConnectionTimeoutException'), "\n"; |
| 20 | + |
| 21 | +// Valid host refuses connection |
| 22 | +$manager = new MongoDB\Driver\Manager('mongodb://localhost:54321', ['CONNECTTIMEOUTMS' => 1]); |
| 23 | + |
| 24 | +echo throws(function() use ($manager, $command) { |
| 25 | + $manager->executeCommand(DATABASE_NAME, $command); |
| 26 | +}, 'MongoDB\Driver\Exception\ConnectionTimeoutException'), "\n"; |
| 27 | + |
| 28 | +ini_set('mongodb.debug', 'off'); |
| 29 | + |
| 30 | +?> |
| 31 | +===DONE=== |
| 32 | +<?php exit(0); ?> |
| 33 | +--EXPECTF-- |
| 34 | +%a |
| 35 | +[%s] PHONGO: DEBUG > Applying connectTimeoutMS: 1 |
| 36 | +[%s] PHONGO: DEBUG > Connecting to 'invalid.host:27017[mongodb://invalid.host:27017]' |
| 37 | +%a |
| 38 | +OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException |
| 39 | +No suitable servers found (`serverselectiontryonce` set): %s |
| 40 | +%a |
| 41 | +[%s] PHONGO: DEBUG > Applying connectTimeoutMS: 1 |
| 42 | +[%s] PHONGO: DEBUG > Connecting to 'localhost:54321[mongodb://localhost:54321]' |
| 43 | +%a |
| 44 | +OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException |
| 45 | +No suitable servers found (`serverselectiontryonce` set): %s |
| 46 | +===DONE=== |
0 commit comments