Skip to content

Commit ac9b49a

Browse files
fix(ci): stabilize Redis Sentinel/Cluster tests and coverage config
1 parent 8955354 commit ac9b49a

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<directory>tests</directory>
1010
</testsuite>
1111
</testsuites>
12-
<coverage>
12+
<source>
1313
<include>
1414
<directory suffix=".php">src</directory>
1515
</include>
16-
</coverage>
16+
</source>
1717
</phpunit>

tests/RedisSentinelSessionHandlerTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,24 @@ function createSentinel(string $host, int $port): RedisSentinel
7474
$ref = new ReflectionClass(RedisSentinel::class);
7575
$ctor = $ref->getConstructor();
7676
if ($ctor === null || $ctor->getNumberOfParameters() === 0) {
77-
return new RedisSentinel();
77+
return $ref->newInstance();
7878
}
7979

80-
$address = sprintf('%s:%d', $host, $port);
80+
$params = $ctor->getParameters();
81+
if ($ctor->getNumberOfParameters() === 1) {
82+
$param = $params[0];
83+
if ($param->hasType()) {
84+
$type = $param->getType();
85+
if ($type instanceof ReflectionNamedType && $type->getName() === 'string') {
86+
return $ref->newInstanceArgs([$host]);
87+
}
88+
}
89+
90+
$address = sprintf('%s:%d', $host, $port);
91+
return $ref->newInstanceArgs([[$address]]);
92+
}
8193

82-
return new RedisSentinel([$address]);
94+
return $ref->newInstanceArgs([$host, $port]);
8395
}
8496

8597
class RedisSentinelSessionHandlerTest extends TestCase

0 commit comments

Comments
 (0)