Skip to content

Commit a3cd4cd

Browse files
committed
Add methods to retrieve server status and license information
1 parent 7bf77d7 commit a3cd4cd

2 files changed

Lines changed: 79 additions & 23 deletions

File tree

src/AbraFlexi/Root.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ public function uploadCertificate(string $pem): bool
3434
return $this->lastResponseCode === 201;
3535
}
3636

37+
/**
38+
* Server Status data.
39+
*
40+
* @return array<string, string>
41+
*/
42+
public function getStatus(): array
43+
{
44+
$statusRaw = $this->performRequest('/status.json', 'GET');
45+
46+
return $statusRaw['status'];
47+
}
48+
49+
/**
50+
* Server License data.
51+
*
52+
* @return array<string, string>
53+
*/
54+
public function getLicenseInfo(): array
55+
{
56+
$statusRaw = $this->performRequest('/license.json', 'GET');
57+
58+
return $statusRaw['license'];
59+
}
60+
3761
/**
3862
* Get available companies listing.
3963
*

tests/src/AbraFlexi/RootTest.php

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,59 @@ protected function tearDown(): void
4040
{
4141
}
4242

43-
// /**
44-
// * @covers \AbraFlexi\Root::uploadCertificate
45-
// *
46-
// * @todo Implement testuploadCertificate().
47-
// */
48-
// public function testuploadCertificate(): void
49-
// {
50-
// $this->assertEquals('', $this->object->uploadCertificate());
51-
// // Remove the following lines when you implement this test.
52-
// $this->markTestIncomplete('This test has not been implemented yet.');
53-
// }
54-
//
55-
// /**
56-
// * @covers \AbraFlexi\Root::companies
57-
// *
58-
// * @todo Implement testcompanies().
59-
// */
60-
// public function testcompanies(): void
61-
// {
62-
// $this->assertEquals('', $this->object->companies());
63-
// // Remove the following lines when you implement this test.
64-
// $this->markTestIncomplete('This test has not been implemented yet.');
65-
// }
43+
/**
44+
* @covers \AbraFlexi\Root::getStatus
45+
*/
46+
public function testGetStatus(): void
47+
{
48+
$mock = $this->getMockBuilder(Root::class)
49+
->onlyMethods(['performRequest'])
50+
->getMock();
51+
52+
$response = [
53+
'status' => [
54+
'version' => '2026.2.2',
55+
'licenseName' => 'FlexiBee Systems s.r.o.',
56+
'startupTime' => '2026-02-15T03:55:14.201+01:00',
57+
'memoryUsed' => '5091655184',
58+
],
59+
];
60+
61+
$mock->expects($this->once())
62+
->method('performRequest')
63+
->with('/status.json', 'GET')
64+
->willReturn($response);
65+
66+
$result = $mock->getStatus();
67+
$this->assertIsArray($result);
68+
$this->assertArrayHasKey('version', $result);
69+
$this->assertEquals('2026.2.2', $result['version']);
70+
}
71+
72+
/**
73+
* @covers \AbraFlexi\Root::getLicenseInfo
74+
*/
75+
public function testGetLicenseInfo(): void
76+
{
77+
$mock = $this->getMockBuilder(Root::class)
78+
->onlyMethods(['performRequest'])
79+
->getMock();
80+
81+
$license = [
82+
'@version' => '1.0',
83+
'id' => 'advanced-786',
84+
'name' => 'FlexiBee Systems s.r.o.',
85+
'variant' => 'premium',
86+
];
87+
88+
$mock->expects($this->once())
89+
->method('performRequest')
90+
->with('/license.json', 'GET')
91+
->willReturn(['license' => $license]);
92+
93+
$result = $mock->getLicenseInfo();
94+
$this->assertIsArray($result);
95+
$this->assertArrayHasKey('id', $result);
96+
$this->assertEquals('advanced-786', $result['id']);
97+
}
6698
}

0 commit comments

Comments
 (0)