Skip to content

Commit ff3101d

Browse files
committed
refactor: Simplificar testes de criação e parada do servidor para melhor legibilidade e manutenção
1 parent 3341b14 commit ff3101d

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

tests/Server/ReactServerTest.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,11 @@ public function testServerStartsAndStops(): void
3232
self::assertSame($this->loop, $this->server->getLoop());
3333

3434
// Test that server can be created without throwing exceptions
35-
$serverAddress = '127.0.0.1:0'; // Port 0 = let system choose available port
36-
37-
try {
38-
// This should work without blocking
39-
self::assertInstanceOf(ReactServer::class, $this->server);
40-
self::assertTrue(true); // Server creation succeeded
41-
} catch (\Throwable $e) {
42-
self::fail('Server creation should not throw exceptions: ' . $e->getMessage());
43-
}
35+
self::assertInstanceOf(ReactServer::class, $this->server);
36+
37+
// Test that server can be stopped without throwing exceptions
38+
$this->server->stop();
39+
// If no exception is thrown, the test passes
4440
}
4541

4642
public function testServerConfiguration(): void
@@ -70,11 +66,9 @@ public function testServerWithDifferentLogger(): void
7066
public function testServerStopBeforeStart(): void
7167
{
7268
// Test that stopping a server that never started doesn't cause issues
73-
try {
74-
$this->server->stop();
75-
self::assertTrue(true); // Stop should not throw exceptions
76-
} catch (\Throwable $e) {
77-
self::fail('Server stop should not throw exceptions when server was never started: ' . $e->getMessage());
78-
}
69+
self::expectNotToPerformAssertions();
70+
71+
$this->server->stop();
72+
// If no exception is thrown, the test passes
7973
}
8074
}

0 commit comments

Comments
 (0)