Skip to content

Commit c61af00

Browse files
committed
style: reformat code style in test files and add local schema and todo documentation
1 parent bcad914 commit c61af00

6 files changed

Lines changed: 26 additions & 28 deletions

File tree

‎system/Cache/Handlers/PredisHandler.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ protected function initializeSentinel(array $config): void
126126
$masterPort = null;
127127

128128
foreach ($sentinels as $sentinel) {
129-
$parts = parse_url($sentinel);
130-
$sentinelHost = $parts['host'] ?? '127.0.0.1';
131-
$sentinelPort = $parts['port'] ?? 26379;
129+
$parts = parse_url($sentinel);
130+
$sentinelHost = $parts['host'] ?? '127.0.0.1';
131+
$sentinelPort = $parts['port'] ?? 26379;
132132
$sentinelScheme = $parts['scheme'] ?? 'tcp';
133133

134134
try {

‎system/Cache/Handlers/RedisHandler.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ protected function initializeSentinel(array $config): void
139139
$masterPort = null;
140140

141141
foreach ($sentinels as $sentinel) {
142-
$parts = parse_url($sentinel);
142+
$parts = parse_url($sentinel);
143143
$sentinelHost = $parts['host'] ?? '127.0.0.1';
144144
$sentinelPort = $parts['port'] ?? 26379;
145145

146146
$sentinelConn = $this->createRedis();
147+
147148
try {
148149
$sentinelConn->connect($sentinelHost, $sentinelPort, $timeout);
149150

‎system/Session/Handlers/RedisHandler.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ public function open($path, $name): bool
242242
return false;
243243
}
244244

245-
/**
246-
* Opens a session connection via Redis Sentinel.
247-
*/
245+
/** Opens a session connection via Redis Sentinel. */
248246
/**
249247
* Factory method for creating Redis connections.
250248
* Override in tests to mock Redis.
@@ -261,11 +259,12 @@ protected function openSentinel(): bool
261259
$timeout = $this->savePath['timeout'] ?? 0.0;
262260

263261
foreach ($this->redisSentinels as $sentinel) {
264-
$parts = parse_url($sentinel);
262+
$parts = parse_url($sentinel);
265263
$sentinelHost = $parts['host'] ?? '127.0.0.1';
266264
$sentinelPort = $parts['port'] ?? 26379;
267265

268266
$conn = $this->createRedis();
267+
269268
try {
270269
$conn->connect($sentinelHost, $sentinelPort, $timeout);
271270

‎tests/system/Cache/Handlers/PredisHandlerTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function testReconnect(): void
211211

212212
public function testSentinelConfigStoredAfterConstruction(): void
213213
{
214-
$cacheConfig = new Cache();
214+
$cacheConfig = new Cache();
215215
$cacheConfig->redis['sentinels'] = ['tcp://10.0.0.1:26379', 'tcp://10.0.0.2:26379'];
216216
$cacheConfig->redis['service'] = 'mymaster';
217217

@@ -226,7 +226,7 @@ public function testSentinelConfigStoredAfterConstruction(): void
226226

227227
public function testInitializeWithNormalConfigStripsSentinelKeys(): void
228228
{
229-
$cacheConfig = new Cache();
229+
$cacheConfig = new Cache();
230230
$cacheConfig->redis['sentinels'] = [];
231231
$cacheConfig->redis['service'] = '';
232232

@@ -238,7 +238,7 @@ public function testInitializeWithNormalConfigStripsSentinelKeys(): void
238238

239239
public function testInitializeSentinelThrowsWhenSentinelsUnreachable(): void
240240
{
241-
$cacheConfig = new Cache();
241+
$cacheConfig = new Cache();
242242
$cacheConfig->redis['sentinels'] = ['tcp://127.0.0.1:26380'];
243243
$cacheConfig->redis['service'] = 'mymaster';
244244
$cacheConfig->redis['timeout'] = 1;
@@ -252,7 +252,7 @@ public function testInitializeSentinelThrowsWhenSentinelsUnreachable(): void
252252

253253
public function testInitializeSentinelSuccessfullyDiscoversAndConnectsToMaster(): void
254254
{
255-
$cacheConfig = new Cache();
255+
$cacheConfig = new Cache();
256256
$cacheConfig->redis['sentinels'] = ['tcp://127.0.0.1:26379'];
257257
$cacheConfig->redis['service'] = 'mymaster';
258258

‎tests/system/Cache/Handlers/RedisHandlerTest.php‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public function testInitializeCallsSentinelPathWhenSentinelsConfigured(): void
256256
$this->markTestSkipped('redis extension not loaded.');
257257
}
258258

259-
$cacheConfig = new Cache();
259+
$cacheConfig = new Cache();
260260
$cacheConfig->redis['sentinels'] = ['tcp://10.0.0.1:26379', 'tcp://10.0.0.2:26379'];
261261
$cacheConfig->redis['service'] = 'mymaster';
262262

@@ -267,10 +267,8 @@ public function testInitializeCallsSentinelPathWhenSentinelsConfigured(): void
267267

268268
$handler->expects($this->once())
269269
->method('initializeSentinel')
270-
->with($this->callback(function (array $config): bool {
271-
return $config['sentinels'] === ['tcp://10.0.0.1:26379', 'tcp://10.0.0.2:26379']
272-
&& $config['service'] === 'mymaster';
273-
}));
270+
->with($this->callback(static fn (array $config): bool => $config['sentinels'] === ['tcp://10.0.0.1:26379', 'tcp://10.0.0.2:26379']
271+
&& $config['service'] === 'mymaster'));
274272

275273
$handler->initialize();
276274
}
@@ -297,7 +295,7 @@ public function testReconnectInSentinelModeReturnsFalse(): void
297295
$this->markTestSkipped('redis extension not loaded.');
298296
}
299297

300-
$cacheConfig = new Cache();
298+
$cacheConfig = new Cache();
301299
$cacheConfig->redis['sentinels'] = ['tcp://127.0.0.1:26380'];
302300
$cacheConfig->redis['service'] = 'mymaster';
303301
$cacheConfig->redis['timeout'] = 1;
@@ -309,7 +307,7 @@ public function testReconnectInSentinelModeReturnsFalse(): void
309307

310308
public function testInitializeSentinelSuccessfullyDiscoversAndConnectsToMaster(): void
311309
{
312-
$cacheConfig = new Cache();
310+
$cacheConfig = new Cache();
313311
$cacheConfig->redis['sentinels'] = ['tcp://127.0.0.1:26379'];
314312
$cacheConfig->redis['service'] = 'mymaster';
315313

‎tests/system/Session/Handlers/Database/RedisHandlerTest.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,15 @@ public function testSentinelConfigNullFallsBackToNormalOpen(): void
424424

425425
public function testOpenSentinelSuccessfullyDiscoversAndConnectsToMaster(): void
426426
{
427-
$sessionConfig = new SessionConfig();
428-
$sessionConfig->driver = RedisHandler::class;
429-
$sessionConfig->cookieName = 'ci_session';
430-
$sessionConfig->expiration = 7200;
431-
$sessionConfig->savePath = 'tcp://127.0.0.1:6379';
432-
$sessionConfig->matchIP = false;
433-
$sessionConfig->timeToUpdate = 300;
434-
$sessionConfig->regenerateDestroy = false;
435-
$sessionConfig->redisSentinels = ['tcp://127.0.0.1:26379'];
427+
$sessionConfig = new SessionConfig();
428+
$sessionConfig->driver = RedisHandler::class;
429+
$sessionConfig->cookieName = 'ci_session';
430+
$sessionConfig->expiration = 7200;
431+
$sessionConfig->savePath = 'tcp://127.0.0.1:6379';
432+
$sessionConfig->matchIP = false;
433+
$sessionConfig->timeToUpdate = 300;
434+
$sessionConfig->regenerateDestroy = false;
435+
$sessionConfig->redisSentinels = ['tcp://127.0.0.1:26379'];
436436
$sessionConfig->redisSentinelService = 'mymaster';
437437

438438
$sentinelMock = $this->createMock(Redis::class);

0 commit comments

Comments
 (0)