forked from FreePBX/devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpunit.php
executable file
·52 lines (46 loc) · 1.45 KB
/
phpunit.php
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env php
<?php
$options = getopt('',array("skipfreepbxbootstrap","moddir:"));
$config = '';
$mod_dir = isset($options['moddir']) ? $options['moddir'] : getcwd();
$test_dir = $mod_dir .'/utests';
if(file_exists($mod_dir."/phpunit.xml")) {
$configFile = $mod_dir."/phpunit.xml";
}
if(file_exists($mod_dir."/utests/utests.xml")) {
$configFile = $mod_dir."/utests/utests.xml";
}
if(!empty($configFile)) {
$xml = simplexml_load_file($configFile);
if(isset($xml['freepbxBootstrap']) && (string)$xml['freepbxBootstrap'][0] == 'false') {
$options['skipfreepbxbootstrap'] = false;
}
$config = "-c ".$configFile;
}
if(!file_exists($test_dir)) {
echo "No Unit Test Folder!\n";
exit(1);
}
if(version_compare(phpversion(), "8.2", ">="))
{
$bin = 'phpunit-11.4.2.phar';
}
elseif(version_compare(phpversion(), "5.6", ">="))
{
$bin = 'phpunit-5.7.21.phar';
}
else
{
$bin = 'phpunit-4.8.36.phar';
}
// Build an args string to pass along to PHPUnit
array_shift($argv);
$args = join(' ', array_map(function ($s) { return "'{$s}'"; }, $argv));
if(isset($options['skipfreepbxbootstrap'])) {
echo "Running in non-freepbx bootstrap mode\n";
passthru(__DIR__.'/binaries/'.$bin.' --bootstrap "'.__DIR__.'/phpunitNoFreePBXBootstrap.php" '.$config.' '.$test_dir.' '.$args, $result_code);
exit($result_code);
} else {
passthru(__DIR__.'/binaries/'.$bin.' --bootstrap "'.__DIR__.'/phpunitBootstrap.php" '.$config.' '.$test_dir.' '.$args, $result_code);
exit($result_code);
}