Revision cafc7c3b
Added by Andreas Kohlbecker about 13 years ago
modules/cdm_dataportal/test/phpUnit/TestUtils.php | ||
---|---|---|
14 | 14 |
|
15 | 15 |
$absoluteFilePath = TEST_RESOURCES_FOLDER . $fileInTestResources; |
16 | 16 |
if(!is_file($absoluteFilePath)){ |
17 |
print ("ERROR: File '$absoluteFilePath' does not exist.");
|
|
17 |
TestUtils::stderr ("ERROR: File '$absoluteFilePath' does not exist.");
|
|
18 | 18 |
} |
19 | 19 |
if(!is_readable($absoluteFilePath)){ |
20 |
print ("ERROR: File '$absoluteFilePath' is not readable");
|
|
20 |
TestUtils::stderr ("ERROR: File '$absoluteFilePath' is not readable");
|
|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
$datastr = file_get_contents($absoluteFilePath); |
24 | 24 |
if(!is_string($datastr)){ |
25 |
print ("ERROR: File '$absoluteFilePath' is empty: $datastr");
|
|
25 |
TestUtils::stderr ("ERROR: File '$absoluteFilePath' is empty: $datastr");
|
|
26 | 26 |
} |
27 | 27 |
|
28 | 28 |
$obj = json_decode($datastr); |
29 | 29 |
|
30 | 30 |
if(!$obj){ |
31 |
print ("ERROR: File '$absoluteFilePath' contains invalid json");
|
|
31 |
TestUtils::stderr ("ERROR: File '$absoluteFilePath' contains invalid json");
|
|
32 | 32 |
} |
33 | 33 |
return $obj; |
34 | 34 |
} |
35 |
|
|
36 |
static function stdout($string){ |
|
37 |
file_put_contents("php://stdout", $string); |
|
38 |
} |
|
39 |
|
|
40 |
static function stderr($string){ |
|
41 |
file_put_contents("php://stderr", $string); |
|
42 |
} |
|
35 | 43 |
} |
Also available in: Unified diff
displaying polytomous keys (addons to #2152)