Skip to content

Commit 4885bcd

Browse files
tests: adjust Service model tests for new structure
1 parent 671162e commit 4885bcd

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsServiceTestCase.inc

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,12 @@ class APIModelsServiceTestCase extends TestCase {
2222
}
2323
}
2424

25-
/**
26-
* Checks that the `get_service_name_choices()` method correctly identifies all available service names.
27-
*/
28-
public function test_get_service_name_choices(): void {
29-
# Ensure expected services are found in the method's response
30-
$expected_services = ['unbound', 'ntpd', 'syslogd', 'dhcpd', 'dpinger', 'sshd'];
31-
32-
# Loop through each expected service and ensure it is found
33-
foreach ($expected_services as $service) {
34-
$this->assert_is_true(in_array($service, (new Service())->get_service_name_choices()));
35-
}
36-
}
37-
38-
/**
39-
* Checks that the `get_id_by_name()` correctly obtains the ID of the Service object with a specific `name`
40-
*/
41-
public function test_get_id_by_name(): void {
42-
# Create a Service object to test with
43-
$test_service = new Service();
44-
45-
# Obtain the ID of the `sshd` service and ensure the correct ID was given
46-
$sshd_id = $test_service->get_id_by_name('sshd');
47-
$this->assert_equals($sshd_id, $test_service->query(['name' => 'sshd'])->first()->id);
48-
}
49-
5025
/**
5126
* Checks that a Service can be stopped, started and restarted.
5227
*/
5328
public function test_can_perform_service_actions(): void {
54-
# Define a Service to test with
55-
$test_service = new Service(data: ['name' => 'ntpd']);
29+
# Obtain a Service to test with
30+
$test_service = Service::query(name: "ntpd")->first();
5631

5732
# Ensure the service can be stopped
5833
$test_service->action->value = 'stop';

0 commit comments

Comments
 (0)