-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-app.php
62 lines (46 loc) · 1.52 KB
/
test-app.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
53
54
55
56
57
58
59
60
61
62
<?php
namespace towa0131\deresute
{
require_once "./vendor/autoload.php";
use towa0131\deresute\TestAPI;
$test = new TestAPI();
echo "Testing..." . PHP_EOL;
$time = time();
$tests = 0;
$successful = 0;
$failed = 0;
$warning = 0;
$result = $test->checkExtensions(false);
$tests++;
getResult($result, $successful, $failed, $warning);
$result = $test->checkAPI(false);
$tests++;
getResult($result, $successful, $failed, $warning);
$duration = time() - $time;
$time = sprintf("%02d:%02d:%02d", floor($duration / 3600), floor(($duration / 60) % 60), ($duration % 60));
$titleFormat = str_repeat("=", 80) . PHP_EOL .
" %s " . PHP_EOL .
str_repeat("-", 80) . PHP_EOL;
$format = " %-20s : %s" . PHP_EOL;
echo sprintf($titleFormat, "TEST RESULT");
echo sprintf($format, "Number of tests", $tests);
echo sprintf($format, "Tests successful", $successful);
echo sprintf($format, "Tests failed", $failed);
echo sprintf($format, "Tests warning", $warning);
echo sprintf($titleFormat, "TIME RESULT");
echo sprintf($format, "Time taken", $time);
function getResult($result, &$successful, &$failed, &$warning): void
{
switch ($result) {
case TestAPI::TEST_ERROR:
$failed++;
break;
case TestAPI::TEST_OK:
$successful++;
break;
case TestAPI::TEST_WARNING:
$warning++;
break;
}
}
}