-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
33 lines (25 loc) · 770 Bytes
/
test.php
File metadata and controls
33 lines (25 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require_once './vendor/autoload.php';
use function TryPhp\jsonConfig;
try {
jsonConfig('./some/not-existent.json');
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {}
try {
jsonConfig(__DIR__ . '/composer.json');
} catch (\Exception $ex) {
trigger_error('test failed.', E_USER_ERROR);
}
try {
jsonConfig(__DIR__ . '/test/invalid.json');
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {}
$config = jsonConfig(__DIR__ . '/composer.json');
$existingValue = $config->get('autoload.files');
if (!is_array($existingValue)) {
trigger_error('test failed.', E_USER_ERROR);
}
$notExistingValue = $config->get('autoload.unicorns');
if ($notExistingValue !== null) {
trigger_error('test failed.', E_USER_ERROR);
}