-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinferno_client_example.php
More file actions
72 lines (59 loc) · 2.25 KB
/
inferno_client_example.php
File metadata and controls
72 lines (59 loc) · 2.25 KB
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
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Example usage of the Inferno API client
*/
require_once 'vendor/autoload.php';
use OpenCoreEmr\InfernoClient\InfernoClient;
// Create a new client instance
$client = new InfernoClient(
'localhost', // Host name
4567, // Port number
false // Use HTTPS
);
try { // Get the Inferno version
$version = $client->getVersion();
echo "Inferno Version: " . $version->version . "\n";
// Get all available test suites
$testSuites = $client->getTestSuites();
echo "Found " . count($testSuites) . " test suites\n";
if (!empty($testSuites)) {
// Get the first test suite ID
$testSuiteId = $testSuites[0]->id;
echo "Using test suite ID: " . $testSuiteId . "\n";
// Create a new test session with this test suite
$testSession = $client->createTestSession($testSuiteId);
echo "Created test session with ID: " . $testSession->id . "\n";
// Create a test run for the test suite
$testRun = $client->createTestRun([
'test_session_id' => $testSession->id,
'test_suite_id' => $testSuiteId
]);
// Get the test run with results
if (isset($testRun->id)) {
echo "Created test run with ID: " . $testRun->id . "\n";
// Check test run results
$results = $client->getTestRunResults($testRun->id);
echo "Got " . count($results) . " test results\n";
// Display summary of results
$statusCounts = ['pass' => 0, 'fail' => 0, 'skip' => 0, 'error' => 0, 'other' => 0];
foreach ($results as $result) {
if (isset($result->result)) {
$status = $result->result;
if (array_key_exists($status, $statusCounts)) {
$statusCounts[$status]++;
} else {
$statusCounts['other']++;
}
}
}
echo "Results summary:\n";
foreach ($statusCounts as $status => $count) {
if ($count > 0) {
echo " - {$status}: {$count}\n";
}
}
}
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}