Skip to content

Commit dec5c2f

Browse files
authored
fix(tests): update IPv6 test to align with PHP 8.4.3 behavior
1 parent 0214ac3 commit dec5c2f

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

src/Tempest/Validation/src/Rules/IP.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ public function __construct(
1616
private bool $allowPrivateRange = true,
1717
private bool $allowReservedRange = true,
1818
) {
19-
$options = 0;
20-
$options = $options | FILTER_FLAG_IPV4;
21-
$options = $options | FILTER_FLAG_IPV6;
19+
$options = FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6;
2220

2321
if (! $this->allowPrivateRange) {
24-
$options = $options | FILTER_FLAG_NO_PRIV_RANGE;
22+
$options |= FILTER_FLAG_NO_PRIV_RANGE;
2523
}
2624

2725
if (! $this->allowReservedRange) {
28-
$options = $options | FILTER_FLAG_NO_RES_RANGE;
26+
$options |= FILTER_FLAG_NO_RES_RANGE;
2927
}
3028

3129
$this->options = $options;

src/Tempest/Validation/src/Rules/IPv4.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ public function __construct(
1616
private bool $allowPrivateRange = true,
1717
private bool $allowReservedRange = true,
1818
) {
19-
$options = 0;
20-
$options = $options | FILTER_FLAG_IPV4;
19+
$options = FILTER_FLAG_IPV4;
2120

2221
if (! $this->allowPrivateRange) {
23-
$options = $options | FILTER_FLAG_NO_PRIV_RANGE;
22+
$options |= FILTER_FLAG_NO_PRIV_RANGE;
2423
}
2524

2625
if (! $this->allowReservedRange) {
27-
$options = $options | FILTER_FLAG_NO_RES_RANGE;
26+
$options |= FILTER_FLAG_NO_RES_RANGE;
2827
}
2928

3029
$this->options = $options;

src/Tempest/Validation/src/Rules/IPv6.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ public function __construct(
1616
private bool $allowPrivateRange = true,
1717
private bool $allowReservedRange = true,
1818
) {
19-
$options = 0;
20-
$options = $options | FILTER_FLAG_IPV6;
19+
$options = FILTER_FLAG_IPV6;
2120

2221
if (! $this->allowPrivateRange) {
23-
$options = $options | FILTER_FLAG_NO_PRIV_RANGE;
22+
$options |= FILTER_FLAG_NO_PRIV_RANGE;
2423
}
2524

2625
if (! $this->allowReservedRange) {
27-
$options = $options | FILTER_FLAG_NO_RES_RANGE;
26+
$options |= FILTER_FLAG_NO_RES_RANGE;
2827
}
2928

3029
$this->options = $options;

src/Tempest/Validation/tests/Rules/IPv6Test.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,8 @@ public function test_ip_address_without_private_range(): void
3939

4040
public function test_ip_address_without_reserved_range(): void
4141
{
42-
if (PHP_OS_FAMILY === 'Windows') {
43-
$this->markTestSkipped('Some kind of problem with Windows. Needs further investigation.');
44-
/** @phpstan-ignore-next-line */
45-
return;
46-
}
47-
4842
$rule = new IPv6(allowReservedRange: false);
49-
$this->assertFalse($rule->isValid('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff'));
43+
$this->assertFalse($rule->isValid('::1'));
5044
$this->assertTrue($rule->isValid('2a03:b0c0:3:d0::11f5:3001'));
5145

5246
$rule = new IPv6(allowReservedRange: true);

0 commit comments

Comments
 (0)