Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ["8.2", "8.3"]
php-version: ["8.2", "8.3", "8.4", "8.5"]
composer-flags: [""]
name: [""]
include:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"require": {
"php": ">=8.1",
"psr/log": "^1|^2|^3",
"symfony/http-client": "^5.4|^6.4|^7.0"
"symfony/http-client": "^5.4|^6.4|^7.0|^8.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^6.0|^7.0"
"symfony/phpunit-bridge": "^6.0|^7.0|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 7 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ private function doRequest(string $method, string $url, array $options): ConsulR
$options['body'] = json_encode($options['body'], \JSON_THROW_ON_ERROR);
}

$this->logger->info(sprintf('%s "%s"', $method, $url));
$this->logger->debug(sprintf('Requesting %s %s', $method, $url), ['options' => $options]);
$this->logger->info(\sprintf('%s "%s"', $method, $url));
$this->logger->debug(\sprintf('Requesting %s %s', $method, $url), ['options' => $options]);

try {
$response = $this->client->request($method, $url, $options);
} catch (TransportExceptionInterface $e) {
$message = sprintf('Something went wrong when calling consul (%s).', $e->getMessage());
$message = \sprintf('Something went wrong when calling consul (%s).', $e->getMessage());

$this->logger->error($message);

throw new ServerException($message);
}

$this->logger->debug(sprintf("Response:\n%s", $this->formatResponse($response)));
$this->logger->debug(\sprintf("Response:\n%s", $this->formatResponse($response)));

if (400 <= $response->getStatusCode()) {
$message = sprintf('Something went wrong when calling consul (%s).', $response->getStatusCode());
$message = \sprintf('Something went wrong when calling consul (%s).', $response->getStatusCode());

$this->logger->error($message);

Expand All @@ -105,10 +105,10 @@ private function formatResponse(ResponseInterface $response): string

foreach ($response->getHeaders(false) as $key => $values) {
foreach ($values as $value) {
$headers[] = sprintf('%s: %s', $key, $value);
$headers[] = \sprintf('%s: %s', $key, $value);
}
}

return sprintf("%s\n\n%s", implode("\n", $headers), $response->getContent(false));
return \sprintf("%s\n\n%s", implode("\n", $headers), $response->getContent(false));
}
}
20 changes: 10 additions & 10 deletions tests/DsnResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@

class DsnResolverTest extends TestCase
{
public function provideResolveTest(): iterable
{
yield ['http://127.0.0.1:5000', 'http://127.0.0.1:5000'];
yield ['https://127.0.0.1:5000', 'https://127.0.0.1:5000'];
yield ['https://foo:5000', 'https://foo:5000'];
yield ['http://127.0.0.1:5000', '127.0.0.1:5000'];
yield ['http://127.0.0.1:5000', '127.0.0.1:5000'];
yield ['http://127.0.0.1:8500', null];
}

/** @dataProvider provideResolveTest */
public function testResolve(string $expected, ?string $dsn)
{
Expand All @@ -32,4 +22,14 @@ public function testResolve(string $expected, ?string $dsn)
}
}
}

public function provideResolveTest(): iterable
{
yield ['http://127.0.0.1:5000', 'http://127.0.0.1:5000'];
yield ['https://127.0.0.1:5000', 'https://127.0.0.1:5000'];
yield ['https://foo:5000', 'https://foo:5000'];
yield ['http://127.0.0.1:5000', '127.0.0.1:5000'];
yield ['http://127.0.0.1:5000', '127.0.0.1:5000'];
yield ['http://127.0.0.1:8500', null];
}
}