Skip to content

Commit 499bae1

Browse files
committed
PHPC-268: Add NEEDS() function to check if that environment is available
1 parent 122d1fd commit 499bae1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/utils/basic.inc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ require __DIR__ . "/" . "tools.php";
55
$FILENAME = sys_get_temp_dir() . "/PHONGO-SERVERS.json";
66

77
$json = file_get_contents($FILENAME);
8-
$servers = json_decode($json);
8+
$config = json_decode($json, true);
9+
if (!$config) {
10+
exit("skip Couldn't json_decode(file_get_contents($FILENAME));");
11+
}
12+
13+
$servers = array(
14+
"STANDALONE" => "",
15+
"STANDALONE_SSL" => "",
16+
"STANDALONE_AUTH" => "",
17+
"STANDALONE_X509" => "",
18+
"STANDALONE_PLAIN" => "",
19+
"REPLICASET" => "",
20+
);
21+
$servers = array_merge($servers, $config);
922
def($servers);
1023

1124
$consts = array(

tests/utils/tools.php

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

63+
function NEEDS($uri) {
64+
if (!constant($uri)) {
65+
exit("skip -- need '$uri' defined");
66+
}
67+
}
6368
function LOAD($uri, $dbname = DATABASE_NAME, $collname = COLLECTION_NAME, $filename = null) {
6469
if (!$filename) {
6570
$filename = "compress.zlib://" . __DIR__ . "/" . "PHONGO-FIXTURES.json.gz";

0 commit comments

Comments
 (0)