Skip to content

Commit dfb4c25

Browse files
chore: add return type hints to tests DHCPServer tests
1 parent 0026d1e commit dfb4c25

1 file changed

Lines changed: 42 additions & 42 deletions

File tree

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

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
1414
/**
1515
* Ensures that a DHCP server cannot be enabled on an interface that does not have a static IPv4 address.
1616
*/
17-
public function test_cannot_enable_dhcp_server_on_non_static_interface() {
17+
public function test_cannot_enable_dhcp_server_on_non_static_interface(): void {
1818
$this->assert_throws_response(
1919
response_id: 'DHCP_SERVER_CANNOT_ENABLE_WITHOUT_STATIC_IPV4',
2020
code: 400,
21-
callable: function () {
21+
callable: function (): void {
2222
# Use the `lan` DHCP server for this test
2323
$dhcp_server = new DHCPServer(id: 'lan', async: false);
2424

@@ -38,7 +38,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
3838
$this->assert_throws_response(
3939
response_id: 'DHCP_SERVER_CANNOT_BE_ENABLED_WITH_DHCP_RELAY',
4040
code: 400,
41-
callable: function () {
41+
callable: function (): void {
4242
# Use the `lan` DHCP server for this test
4343
$dhcp_server = new DHCPServer(id: 'lan', async: false);
4444

@@ -54,11 +54,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
5454
/**
5555
* Ensures that a DHCP server's `range_from` field cannot be the interface's network address.
5656
*/
57-
public function test_range_from_cannot_network_address() {
57+
public function test_range_from_cannot_network_address(): void {
5858
$this->assert_throws_response(
5959
response_id: 'DHCP_SERVER_RANGE_FROM_CANNOT_BE_NETWORK_ADDRESS',
6060
code: 400,
61-
callable: function () {
61+
callable: function (): void {
6262
# Use the `lan` DHCP server for this test
6363
$dhcp_server = new DHCPServer(id: 'lan', async: false);
6464
$interface = new NetworkInterface(id: 'lan');
@@ -72,11 +72,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
7272
/**
7373
* Ensures that a DHCP server's `range_from` field cannot be greater than `range_to`
7474
*/
75-
public function test_range_from_cannot_be_greater_than_range_to() {
75+
public function test_range_from_cannot_be_greater_than_range_to(): void {
7676
$this->assert_throws_response(
7777
response_id: 'DHCP_SERVER_RANGE_FROM_CANNOT_BE_GREATER_THAN_RANGE_TO',
7878
code: 400,
79-
callable: function () {
79+
callable: function (): void {
8080
# Use the `lan` DHCP server for this test
8181
$dhcp_server = new DHCPServer(id: 'lan', async: false);
8282
$dhcp_server->range_to->value = '192.168.1.1';
@@ -88,11 +88,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
8888
/**
8989
* Ensures that a DHCP server's `range_from` cannot be outside the interface's subnet
9090
*/
91-
public function test_range_from_cannot_be_outside_interface_subnet() {
91+
public function test_range_from_cannot_be_outside_interface_subnet(): void {
9292
$this->assert_throws_response(
9393
response_id: 'DHCP_SERVER_RANGE_FROM_OUTSIDE_OF_SUBNET',
9494
code: 400,
95-
callable: function () {
95+
callable: function (): void {
9696
# Use the `lan` DHCP server for this test
9797
$dhcp_server = new DHCPServer(id: 'lan', async: false);
9898
$dhcp_server->validate_range_from(range_from: '1.2.3.4');
@@ -103,11 +103,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
103103
/**
104104
* Ensures that a DHCP server's `range_to` field cannot be the interface's broadcast address.
105105
*/
106-
public function test_range_to_cannot_broadcast_address() {
106+
public function test_range_to_cannot_broadcast_address(): void {
107107
$this->assert_throws_response(
108108
response_id: 'DHCP_SERVER_RANGE_FROM_CANNOT_BE_BROADCAST_ADDRESS',
109109
code: 400,
110-
callable: function () {
110+
callable: function (): void {
111111
# Use the `lan` DHCP server for this test
112112
$dhcp_server = new DHCPServer(id: 'lan', async: false);
113113
$interface = new NetworkInterface(id: 'lan');
@@ -121,11 +121,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
121121
/**
122122
* Ensures that a DHCP server's `range_to` cannot be outside the interface's subnet
123123
*/
124-
public function test_range_to_cannot_be_outside_interface_subnet() {
124+
public function test_range_to_cannot_be_outside_interface_subnet(): void {
125125
$this->assert_throws_response(
126126
response_id: 'DHCP_SERVER_RANGE_TO_OUTSIDE_OF_SUBNET',
127127
code: 400,
128-
callable: function () {
128+
callable: function (): void {
129129
# Use the `lan` DHCP server for this test
130130
$dhcp_server = new DHCPServer(id: 'lan', async: false);
131131
$dhcp_server->validate_range_to(range_to: '1.2.3.4');
@@ -136,7 +136,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
136136
/**
137137
* Ensures that a DHCP server's primary DHCP pool cannot conflict with an existing virtual IP.
138138
*/
139-
public function test_primary_dhcp_pool_cannot_conflict_with_vip() {
139+
public function test_primary_dhcp_pool_cannot_conflict_with_vip(): void {
140140
# Create a virtual IP to use for testing
141141
$vip = new VirtualIP(interface: 'lan', mode: 'ipalias', subnet: '192.168.1.2', subnet_bits: 24);
142142
$vip->create(apply: true);
@@ -145,7 +145,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
145145
$this->assert_throws_response(
146146
response_id: 'DHCP_SERVER_PRIMARY_POOL_OVERLAPS_EXISTING_OBJECT',
147147
code: 409,
148-
callable: function () {
148+
callable: function (): void {
149149
# Use the `lan` DHCP server for this test
150150
$dhcp_server = new DHCPServer(id: 'lan', async: false);
151151
$dhcp_server->range_from->value = '192.168.1.2';
@@ -161,7 +161,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
161161
/**
162162
* Ensures that the primary DHCP pool cannot conflict with an existing DHCP static mapping.
163163
*/
164-
public function test_dhcp_pool_cannot_conflict_with_static_mapping() {
164+
public function test_dhcp_pool_cannot_conflict_with_static_mapping(): void {
165165
# Add a DHCP static mapping
166166
$static_map = new DHCPServerStaticMapping(
167167
parent_id: 'lan',
@@ -175,7 +175,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
175175
$this->assert_throws_response(
176176
response_id: 'DHCP_SERVER_PRIMARY_POOL_OVERLAPS_EXISTING_OBJECT',
177177
code: 409,
178-
callable: function () {
178+
callable: function (): void {
179179
# Use the `lan` DHCP server for this test
180180
$dhcp_server = new DHCPServer(id: 'lan', async: false);
181181
$dhcp_server->range_from->value = '192.168.1.2';
@@ -191,11 +191,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
191191
/**
192192
* Ensures that the `maxleasetime` cannot be set to a value lower than the `defaultleasttime`.
193193
*/
194-
public function test_maxleasetime_cannot_be_lower_than_defaultleasetime() {
194+
public function test_maxleasetime_cannot_be_lower_than_defaultleasetime(): void {
195195
$this->assert_throws_response(
196196
response_id: 'DHCP_SERVER_MAX_LEASE_TIME_LESS_THAN_DEFAULT',
197197
code: 400,
198-
callable: function () {
198+
callable: function (): void {
199199
# Use the `lan` DHCP server for this test
200200
$dhcp_server = new DHCPServer(id: 'lan', async: false);
201201
$dhcp_server->defaultleasetime->value = 25000;
@@ -207,11 +207,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
207207
/**
208208
* Ensures the DHCP server `gateway` value is a value within the interface's subnet.
209209
*/
210-
public function test_dhcp_server_gateway_in_interface_subnet() {
210+
public function test_dhcp_server_gateway_in_interface_subnet(): void {
211211
$this->assert_throws_response(
212212
response_id: 'DHCP_SERVER_GATEWAY_NOT_WITHIN_SUBNET',
213213
code: 400,
214-
callable: function () {
214+
callable: function (): void {
215215
# Use the `lan` DHCP server for this test
216216
$dhcp_server = new DHCPServer(id: 'lan', async: false);
217217
$dhcp_server->validate_gateway(gateway: '1.2.3.4');
@@ -222,11 +222,11 @@ class APIModelsDHCPServerTestCase extends TestCase {
222222
/**
223223
* Ensures `nonak` cannot be enabled when a `failover_peerip` is set
224224
*/
225-
public function test_no_nonak_with_failover_peerip() {
225+
public function test_no_nonak_with_failover_peerip(): void {
226226
$this->assert_throws_response(
227227
response_id: 'DHCP_SERVER_NONAK_WITH_FAILOVER_PEERIP_NOT_ALLOWED',
228228
code: 400,
229-
callable: function () {
229+
callable: function (): void {
230230
# Use the `lan` DHCP server for this test
231231
$dhcp_server = new DHCPServer(id: 'lan', async: false);
232232
$dhcp_server->failover_peerip->value = '192.168.1.2';
@@ -238,7 +238,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
238238
/**
239239
* Ensures `staticarp` cannot be enabled if there are any static mappings without IPs.
240240
*/
241-
public function test_no_staticarp_with_no_ip_static_mappings() {
241+
public function test_no_staticarp_with_no_ip_static_mappings(): void {
242242
# Add a DHCP static mapping
243243
$static_mapping = new DHCPServerStaticMapping(parent_id: 'lan', mac: '00:00:00:00:00:00', async: false);
244244
$static_mapping->create(apply: true);
@@ -247,7 +247,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
247247
$this->assert_throws_response(
248248
response_id: 'DHCP_SERVER_STATICARP_WITH_NO_IP_STATIC_MAPPINGS',
249249
code: 400,
250-
callable: function () {
250+
callable: function (): void {
251251
# Use the `lan` DHCP server for this test
252252
$dhcp_server = new DHCPServer(id: 'lan', async: false);
253253
$dhcp_server->validate_staticarp(staticarp: true);
@@ -262,7 +262,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
262262
* Ensures the DHCP server process is killed for the assigned interface when `enable` is set to `false` and
263263
* ensures the DHCP server process is respawned when it is re-enabled.
264264
*/
265-
public function test_enable_controls_dhcpd_process() {
265+
public function test_enable_controls_dhcpd_process(): void {
266266
# Disable the DHCP server and ensure the `dhcpd` process is no longer running
267267
$dhcp_server = new DHCPServer(id: 'lan', async: false);
268268
$dhcp_server->enable->value = false;
@@ -284,7 +284,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
284284
/**
285285
* Ensures the `ignorebootp` field correctly sets the dhcpd `ignore bootp` setting.
286286
*/
287-
public function test_ignorebootp_set_dhcpd_ignore_bootp() {
287+
public function test_ignorebootp_set_dhcpd_ignore_bootp(): void {
288288
# Enable `ignorebootp` and ensure it is set in the dhcpd.conf
289289
$dhcp_server = new DHCPServer(id: 'lan', async: false);
290290
$dhcp_server->ignorebootp->value = true;
@@ -300,7 +300,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
300300
/**
301301
* Ensures the `denyunknown` field correctly sets the `deny` setting in dhcpd.conf
302302
*/
303-
public function test_denyunknown_sets_dhcpd_deny() {
303+
public function test_denyunknown_sets_dhcpd_deny(): void {
304304
# Set `denyunknown` to `enabled` and ensure dhcpd.conf denies all unknown clients
305305
$dhcp_server = new DHCPServer(id: 'lan', async: false);
306306
$dhcp_server->denyunknown->value = 'enabled';
@@ -333,7 +333,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
333333
/**
334334
* Ensures the `ignoreclientuids` field correctly sets the dhcpd `ignore-client-uid` setting.
335335
*/
336-
public function test_ignoreclientuids_sets_dhcpd_ignore_client_uids() {
336+
public function test_ignoreclientuids_sets_dhcpd_ignore_client_uids(): void {
337337
# Enable `ignoreclientuids` and ensure it is set in the dhcpd.conf
338338
$dhcp_server = new DHCPServer(id: 'lan', async: false);
339339
$dhcp_server->ignoreclientuids->value = true;
@@ -352,7 +352,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
352352
/**
353353
* Ensures the `disablepingcheck` field correctly sets the dhcpd `ping-check` setting.
354354
*/
355-
public function test_disablepingcheck_sets_dhcpd_ping_check() {
355+
public function test_disablepingcheck_sets_dhcpd_ping_check(): void {
356356
$dhcp_server = new DHCPServer(id: 'lan', async: false);
357357
$dhcp_server->disablepingcheck->value = true;
358358
$dhcp_server->update(apply: true);
@@ -366,7 +366,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
366366
/**
367367
* Ensures the `range_from` and `range_to` field correctly configures the DHCP range in dhcpd.conf
368368
*/
369-
public function test_range_from_and_range_to_sets_dhcpd_range() {
369+
public function test_range_from_and_range_to_sets_dhcpd_range(): void {
370370
$dhcp_server = new DHCPServer(id: 'lan', async: false);
371371
$dhcp_server->range_from->value = '192.168.1.105';
372372
$dhcp_server->range_to->value = '192.168.1.108';
@@ -380,7 +380,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
380380
/**
381381
* Ensures the `winsserver` field correctly sets the WINS servers configured in dhcpd.conf
382382
*/
383-
public function test_winsserver_sets_dhcpd_netbios_nameservers() {
383+
public function test_winsserver_sets_dhcpd_netbios_nameservers(): void {
384384
$dhcp_server = new DHCPServer(id: 'lan', async: false);
385385
$dhcp_server->winsserver->value = ['192.168.1.100', '192.168.1.101'];
386386
$dhcp_server->update(apply: true);
@@ -393,7 +393,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
393393
/**
394394
* Ensures the `dnsserver` field correctly sets the DNS servers configured in dhcpd.conf
395395
*/
396-
public function test_dnsserver_sets_dhcpd_dns_servers() {
396+
public function test_dnsserver_sets_dhcpd_dns_servers(): void {
397397
$dhcp_server = new DHCPServer(id: 'lan', async: false);
398398
$dhcp_server->dnsserver->value = ['192.168.1.100', '192.168.1.101'];
399399
$dhcp_server->update(apply: true);
@@ -406,7 +406,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
406406
/**
407407
* Ensures the `ntpserver` field correctly sets the NTP servers configured in dhcpd.conf
408408
*/
409-
public function test_ntpserver_sets_dhcpd_ntp_servers() {
409+
public function test_ntpserver_sets_dhcpd_ntp_servers(): void {
410410
$dhcp_server = new DHCPServer(id: 'lan', async: false);
411411
$dhcp_server->ntpserver->value = ['192.168.1.100', '192.168.1.101'];
412412
$dhcp_server->update(apply: true);
@@ -419,7 +419,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
419419
/**
420420
* Ensures the `mac_allow` field sets the proper dhcpd settings
421421
*/
422-
public function test_mac_allow_sets_dhcpd_allow_members() {
422+
public function test_mac_allow_sets_dhcpd_allow_members(): void {
423423
$dhcp_server = new DHCPServer(id: 'lan', async: false);
424424
$dhcp_server->mac_allow->value = ['11:22:33:aa:bb:cc'];
425425
$dhcp_server->update(apply: true);
@@ -436,7 +436,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
436436
/**
437437
* Ensures the `mac_deny` field sets the proper dhcpd settings
438438
*/
439-
public function test_mac_deny_sets_dhcpd_deny_members() {
439+
public function test_mac_deny_sets_dhcpd_deny_members(): void {
440440
$dhcp_server = new DHCPServer(id: 'lan', async: false);
441441
$dhcp_server->mac_deny->value = ['11:22:33:aa:bb:cc'];
442442
$dhcp_server->update(apply: true);
@@ -453,7 +453,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
453453
/**
454454
* Ensures the `gateway` field correctly sets the router configured in dhcpd.conf
455455
*/
456-
public function test_gateway_sets_dhcpd_router() {
456+
public function test_gateway_sets_dhcpd_router(): void {
457457
$dhcp_server = new DHCPServer(id: 'lan', async: false);
458458
$dhcp_server->gateway->value = '192.168.1.2';
459459
$dhcp_server->update(apply: true);
@@ -466,7 +466,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
466466
/**
467467
* Ensures the `domain` field correctly sets the domain name configured in dhcpd.conf
468468
*/
469-
public function test_domain_sets_dhcpd_domain_name() {
469+
public function test_domain_sets_dhcpd_domain_name(): void {
470470
$dhcp_server = new DHCPServer(id: 'lan', async: false);
471471
$dhcp_server->domain->value = 'example.com';
472472
$dhcp_server->update(apply: true);
@@ -479,7 +479,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
479479
/**
480480
* Ensures the `domainsearchlist` field correctly sets the domain search configured in dhcpd.conf
481481
*/
482-
public function test_domainsearchlist_sets_dhcpd_domain_search() {
482+
public function test_domainsearchlist_sets_dhcpd_domain_search(): void {
483483
$dhcp_server = new DHCPServer(id: 'lan', async: false);
484484
$dhcp_server->domainsearchlist->value = ['example.com'];
485485
$dhcp_server->update(apply: true);
@@ -492,7 +492,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
492492
/**
493493
* Ensures the `defaultleasetime` field correctly sets the default-lease-time configured in dhcpd.conf
494494
*/
495-
public function test_defaultleasetime_sets_dhcpd_default_lease_time() {
495+
public function test_defaultleasetime_sets_dhcpd_default_lease_time(): void {
496496
$dhcp_server = new DHCPServer(id: 'lan', async: false);
497497
$dhcp_server->defaultleasetime->value = 7201;
498498
$dhcp_server->update(apply: true);
@@ -502,7 +502,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
502502
/**
503503
* Ensures the `maxleasetime` field correctly sets the max-lease-time configured in dhcpd.conf
504504
*/
505-
public function test_maxleasetime_sets_dhcpd_max_lease_time() {
505+
public function test_maxleasetime_sets_dhcpd_max_lease_time(): void {
506506
$dhcp_server = new DHCPServer(id: 'lan', async: false);
507507
$dhcp_server->maxleasetime->value = 86401;
508508
$dhcp_server->update(apply: true);
@@ -512,7 +512,7 @@ class APIModelsDHCPServerTestCase extends TestCase {
512512
/**
513513
* Ensures the `failover_peerip` field correctly sets the failover peer address configured in dhcpd.conf
514514
*/
515-
public function test_failover_peerip_sets_dhcpd_peer_address() {
515+
public function test_failover_peerip_sets_dhcpd_peer_address(): void {
516516
$dhcp_server = new DHCPServer(id: 'lan', async: false);
517517
$dhcp_server->failover_peerip->value = '192.168.1.2';
518518
$dhcp_server->update(apply: true);

0 commit comments

Comments
 (0)