Skip to content

Commit 8364cd4

Browse files
committed
PHPC-270: add TESTCOMMANDS() skipif to confirm mongod is running with required options
1 parent 4b1a7ef commit 8364cd4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/utils/tools.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ function makeCollectionNameFromFilename($filename)
6060
return preg_replace(array_keys($replacements), array_values($replacements), $filename);
6161
}
6262

63+
function TESTCOMMANDS($uri) {
64+
$cmd = array(
65+
"configureFailPoint" => 1,
66+
);
67+
$command = new MongoDB\Driver\Command($cmd);
68+
69+
$manager = new MongoDB\Driver\Manager($uri);
70+
try {
71+
$result = $manager->executeCommand("test", $command);
72+
} catch(Exception $e) {
73+
/* command not found */
74+
if ($e->getCode() == 59) {
75+
die("skip this test requires mongod with enableTestCommands");
76+
}
77+
}
78+
}
6379
function NEEDS($uri) {
6480
if (!constant($uri)) {
6581
exit("skip -- need '$uri' defined");

0 commit comments

Comments
 (0)