feat: mention selected port by api client in log messages

This commit is contained in:
Björn Fromme
2026-05-18 12:48:07 +02:00
parent b18b09d4a5
commit de4dadb9e5
2 changed files with 28 additions and 1 deletions
+20 -1
View File
@@ -18,14 +18,17 @@ use Symfony\Component\Serializer\SerializerInterface;
class ApiClientReceiveTest extends TestCase
{
private ApiClient $apiClient;
private LoggerInterface $logger;
protected function setUp(): void
{
$this->logger = $this->createMock(LoggerInterface::class);
$this->apiClient = new ApiClient(
$this->createMock(SerializerInterface::class),
$this->createMock(ApiResponseParser::class),
$this->createMock(FilesystemOperator::class),
$this->createMock(LoggerInterface::class),
$this->logger,
$this->createMock(BookingDataProcessor::class),
new RequestStack(),
new RequestIdGenerator(),
@@ -45,6 +48,16 @@ class ApiClientReceiveTest extends TestCase
rewind($stream);
$this->setOperationStartTime();
$this->setSelectedPort(9000);
$this->logger->expects($this->once())
->method('warning')
->with(
'Server closed connection without sending data',
$this->callback(static function (array $context): bool {
return 9000 === $context['port'];
}),
);
$this->expectException(ImmediateConnectionCloseException::class);
$this->expectExceptionMessage('Server closed connection without sending data');
@@ -77,4 +90,10 @@ class ApiClientReceiveTest extends TestCase
$property = new \ReflectionProperty(ApiClient::class, 'operationStartTime');
$property->setValue($this->apiClient, microtime(true));
}
private function setSelectedPort(int $port): void
{
$property = new \ReflectionProperty(ApiClient::class, 'selectedPort');
$property->setValue($this->apiClient, $port);
}
}