Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Nov 28, 2020
1 parent 8fc2eb0 commit a306646
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/ConnectionPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testConnectionCloseWhileIdle(): \Generator
$response = yield $this->executeRequest($this->createRequest());
self::assertSame("hello", yield $response->getBody()->buffer());

yield delay(2000);
yield delay(1000);

/** @var Response $response */
$response = yield $this->executeRequest($this->createRequest());
Expand All @@ -40,30 +40,27 @@ protected function setUp(): void
}

$this->socket = Socket\Server::listen('127.0.0.1:0');
$this->socket->unreference();

asyncCall(function () {
yield delay(10);

/** @var Socket\EncryptableSocket $client */
$client = yield $this->socket->accept();
$client->unreference();

yield $client->write("HTTP/1.1 200 OK\r\nconnection: keep-alive\r\ncontent-length: 5\r\n\r\nhello");

yield delay(1000);
yield delay(500);

$client->close();

yield delay(2000);
yield delay(1000);

/** @var Socket\EncryptableSocket $client */
$client = yield $this->socket->accept();
$client->unreference();

yield $client->write("HTTP/1.1 200 OK\r\nconnection: keep-alive\r\ncontent-length: 5\r\n\r\nhello");

$client->close();

$this->socket->close();
});
}

Expand Down

0 comments on commit a306646

Please sign in to comment.