Skip to content

Commit 50b287d

Browse files
committed
chore: Stabilize CI fixture resolution and DateTime assertions
1 parent d2084d0 commit 50b287d

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

tests/Integration/Support/IntegrationConfig.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class IntegrationConfig
2828
];
2929

3030
private const DEFAULT_CLIENT_CERT_CANDIDATES = [
31+
'tests/fixtures/dummy-client-cert.pem',
3132
'tests/fixtures/oblak.pem',
3233
'tests/fixtures/client.pem',
3334
'tests/Fixtures/client.pem',
@@ -92,9 +93,9 @@ public static function ensureReadyOrFail(): void
9293
{
9394
self::ensureEnvOrFail('RNIDS_EPP_USERNAME');
9495
self::ensureEnvOrFail('RNIDS_EPP_PASSWORD');
96+
self::port();
9597
self::ensureFileOrFail(self::clientCertificatePath(), 'RNIDS client certificate');
9698
self::ensureFileOrFail(self::caCertificatePath(), 'RNIDS CA certificate');
97-
self::port();
9899
}
99100

100101
public static function liveReadinessFailureReason(): ?string
@@ -104,9 +105,11 @@ public static function liveReadinessFailureReason(): ?string
104105
$port = self::DEFAULT_PORT;
105106

106107
foreach ([ 'RNIDS_EPP_USERNAME', 'RNIDS_EPP_PASSWORD' ] as $requiredEnv) {
107-
if (null === self::nonEmptyEnvOrNull($requiredEnv)) {
108-
$issues[] = \sprintf('missing %s', $requiredEnv);
108+
if (null !== self::nonEmptyEnvOrNull($requiredEnv)) {
109+
continue;
109110
}
111+
112+
$issues[] = \sprintf('missing %s', $requiredEnv);
110113
}
111114

112115
try {
@@ -370,7 +373,10 @@ private static function ensureEnvOrFail(string $name): void
370373

371374
if (!\is_string($value) || '' === \trim($value)) {
372375
throw new \RuntimeException(
373-
\sprintf('Missing required environment variable "%s" for RNIDS live integration tests.', $name),
376+
\sprintf(
377+
'Missing required environment variable "%s" for RNIDS live integration tests.',
378+
$name,
379+
),
374380
);
375381
}
376382
}
@@ -413,13 +419,17 @@ private static function port(): int
413419
}
414420

415421
if (!\preg_match('/^\d+$/', $port)) {
416-
throw new \RuntimeException('Environment variable "RNIDS_EPP_PORT" must be an integer between 1 and 65535.');
422+
throw new \RuntimeException(
423+
'Environment variable "RNIDS_EPP_PORT" must be an integer between 1 and 65535.',
424+
);
417425
}
418426

419427
$parsedPort = (int) $port;
420428

421429
if ($parsedPort < 1 || $parsedPort > 65535) {
422-
throw new \RuntimeException('Environment variable "RNIDS_EPP_PORT" must be an integer between 1 and 65535.');
430+
throw new \RuntimeException(
431+
'Environment variable "RNIDS_EPP_PORT" must be an integer between 1 and 65535.',
432+
);
423433
}
424434

425435
return $parsedPort;
@@ -436,7 +446,7 @@ private static function isHostResolvable(string $host): bool
436446
return false;
437447
}
438448

439-
if (\filter_var($host, \FILTER_VALIDATE_IP) !== false) {
449+
if (false !== \filter_var($host, \FILTER_VALIDATE_IP)) {
440450
return true;
441451
}
442452

@@ -446,7 +456,9 @@ private static function isHostResolvable(string $host): bool
446456
private static function isTcpEndpointReachable(string $host, int $port, float $timeoutSeconds): bool
447457
{
448458
$flags = \STREAM_CLIENT_CONNECT;
449-
$context = \stream_context_create([ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false ] ]);
459+
$context = \stream_context_create(
460+
[ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false ] ],
461+
);
450462
$socket = @\stream_socket_client(
451463
\sprintf('tcp://%s:%d', $host, $port),
452464
$errorCode,

tests/Unit/Domain/DomainResponseMapperTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testMapMutationResponses(): void
7777
$mapper = new DomainResponseMapper();
7878
$metadata = new ResponseMetadata(1000, 'ok', 'CL-1', 'SV-1');
7979

80-
self::assertSame([
80+
self::assertEquals([
8181
'createDate' => new \DateTimeImmutable('2024-01-01T00:00:00Z'),
8282
'expirationDate' => new \DateTimeImmutable('2025-01-01T00:00:00Z'),
8383
'name' => 'example.rs',
@@ -90,14 +90,14 @@ public function testMapMutationResponses(): void
9090
),
9191
));
9292

93-
self::assertSame([
93+
self::assertEquals([
9494
'expirationDate' => new \DateTimeImmutable('2026-01-01T00:00:00Z'),
9595
'name' => 'example.rs',
9696
], $mapper->mapRenewResponse(
9797
new DomainRenewResponse($metadata, 'example.rs', new \DateTimeImmutable('2026-01-01T00:00:00Z')),
9898
));
9999

100-
self::assertSame([
100+
self::assertEquals([
101101
'actionClientId' => 'ACT',
102102
'actionDate' => new \DateTimeImmutable('2025-01-01T00:00:00Z'),
103103
'expirationDate' => new \DateTimeImmutable('2026-01-01T00:00:00Z'),

tests/Unit/Host/HostResponseMapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testMapInfoAndCreateResponses(): void
5858
self::assertSame('ok', $mappedInfo['statuses'][0]);
5959
self::assertSame('192.0.2.1', $mappedInfo['ipv4'][0]);
6060

61-
self::assertSame([
61+
self::assertEquals([
6262
'createDate' => new \DateTimeImmutable('2026-02-01T00:00:00.0Z'),
6363
'name' => 'ns1.example.rs',
6464
], $mapper->mapCreateResponse(

0 commit comments

Comments
 (0)