From fbf718a930d8656d07a0a6000e9612845664fddd Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 16 Oct 2023 13:47:36 +0200 Subject: [PATCH] feat: add `@throws` (#210) --- phpstan.neon.dist | 11 ++++++ src/Client/ClickHouseClient.php | 35 ++++++++++++++++- src/Client/Http/RequestFactory.php | 52 +++++++++++++++++++------ src/Client/PsrClickHouseAsyncClient.php | 38 ++++++++++++------ src/Client/PsrClickHouseClient.php | 8 +++- src/Format/Json.php | 2 + src/Format/JsonCompact.php | 2 + src/Format/JsonEachRow.php | 2 + src/Output/Json.php | 3 ++ src/Output/JsonCompact.php | 3 ++ src/Output/JsonEachRow.php | 3 ++ src/Snippet/CurrentDatabase.php | 8 ++++ src/Snippet/DatabaseSize.php | 10 +++++ src/Snippet/Parts.php | 13 ++++++- src/Snippet/ShowCreateTable.php | 8 ++++ src/Snippet/ShowDatabases.php | 11 +++++- src/Snippet/TableSizes.php | 13 ++++++- src/Snippet/Version.php | 8 ++++ src/Sql/SqlFactory.php | 10 ++++- src/Sql/ValueFormatter.php | 5 +++ tests/ClickHouseVersion.php | 1 + tests/WithClient.php | 24 ++++++++---- 22 files changed, 234 insertions(+), 36 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a33b4a1..b34e9c3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,6 +4,13 @@ parameters: - %currentWorkingDirectory%/src - %currentWorkingDirectory%/tests + exceptions: + check: + missingCheckedExceptionInThrows: true + tooWideThrowType: true + uncheckedExceptionClasses: + - RuntimeException + ignoreErrors: # There's no other way to test-pass without assertions while counting it towards coverage https://github.com/sebastianbergmann/phpunit/issues/3016 - '~Call to static method PHPUnit\\Framework\\Assert::assertTrue\(\) with true will always evaluate to true~' @@ -11,5 +18,9 @@ parameters: # Adds unnecessary maintanence overhead. We rather rely on PHPStan telling us the method returns unhandled FALSE - "~Class DateTime(Immutable)? is unsafe to use. Its methods can return FALSE instead of throwing an exception. Please add 'use Safe\\\\DateTime(Immutable)?;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library~" + # No need to have @throws in some phpunit related methods + - message: "~Method SimPod\\\\ClickHouseClient\\\\Tests\\\\.+?Test(CaseBase)?::(test.+?|provider.+?|setUp(BeforeClass)?|tearDown|setupClickHouseClient|tearDownDataBase)\\(\\) throws checked exception .+? but it's missing from the PHPDoc @throws tag~" + path: tests + includes: - phpstan-baseline.neon diff --git a/src/Client/ClickHouseClient.php b/src/Client/ClickHouseClient.php index 96780fa..a94f557 100644 --- a/src/Client/ClickHouseClient.php +++ b/src/Client/ClickHouseClient.php @@ -4,17 +4,33 @@ namespace SimPod\ClickHouseClient\Client; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; +use SimPod\ClickHouseClient\Exception\CannotInsert; +use SimPod\ClickHouseClient\Exception\ServerError; +use SimPod\ClickHouseClient\Exception\UnsupportedValue; use SimPod\ClickHouseClient\Format\Format; use SimPod\ClickHouseClient\Output\Output; interface ClickHouseClient { - /** @param array $settings */ + /** + * @param array $settings + * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + */ public function executeQuery(string $query, array $settings = []): void; /** * @param array $params * @param array $settings + * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + * @throws UnsupportedValue */ public function executeQueryWithParams(string $query, array $params, array $settings = []): void; @@ -24,6 +40,10 @@ public function executeQueryWithParams(string $query, array $params, array $sett * * @return O * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + * * @template O of Output */ public function select(string $query, Format $outputFormat, array $settings = []): Output; @@ -35,6 +55,11 @@ public function select(string $query, Format $outputFormat, array $settings = [] * * @return O * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + * @throws UnsupportedValue + * * @template O of Output */ public function selectWithParams(string $query, array $params, Format $outputFormat, array $settings = []): Output; @@ -43,6 +68,11 @@ public function selectWithParams(string $query, array $params, Format $outputFor * @param array> $values * @param array|null $columns * @param array $settings + * + * @throws CannotInsert + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError */ public function insert(string $table, array $values, array|null $columns = null, array $settings = []): void; @@ -50,6 +80,9 @@ public function insert(string $table, array $values, array|null $columns = null, * @param array $settings * @param Format $inputFormat * + * @throws ClientExceptionInterface + * @throws ServerError + * * @template O of Output */ public function insertWithFormat(string $table, Format $inputFormat, string $data, array $settings = []): void; diff --git a/src/Client/Http/RequestFactory.php b/src/Client/Http/RequestFactory.php index 4123595..499565a 100644 --- a/src/Client/Http/RequestFactory.php +++ b/src/Client/Http/RequestFactory.php @@ -4,11 +4,13 @@ namespace SimPod\ClickHouseClient\Client\Http; +use InvalidArgumentException; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface; +use RuntimeException; use function http_build_query; use function is_string; @@ -17,12 +19,26 @@ final class RequestFactory { + private UriInterface|null $uri; + + /** @throws InvalidArgumentException */ public function __construct( private RequestFactoryInterface $requestFactory, private StreamFactoryInterface $streamFactory, - private UriFactoryInterface|null $uriFactory = null, - private UriInterface|string $uri = '', + UriFactoryInterface|null $uriFactory = null, + UriInterface|string $uri = '', ) { + if ($uriFactory === null && $uri === '') { + $uri = null; + } elseif (is_string($uri)) { + if ($uriFactory === null) { + throw new InvalidArgumentException('UriFactoryInterface is required when `$uri` is string'); + } + + $uri = $uriFactory->createUri($uri); + } + + $this->uri = $uri; } public function prepareRequest(RequestOptions $requestOptions): RequestInterface @@ -34,20 +50,32 @@ public function prepareRequest(RequestOptions $requestOptions): RequestInterface PHP_QUERY_RFC3986, ); - if ($this->uriFactory === null) { - return $this->requestFactory->createRequest('POST', $query === '' ? '' : '?' . $query) - ->withBody($this->streamFactory->createStream($requestOptions->sql)); + $body = $this->streamFactory->createStream($requestOptions->sql); + + if ($this->uri === null) { + $uri = $query === '' ? '' : '?' . $query; + } else { + $uriQuery = $this->uri->getQuery(); + try { + $uri = $this->uri->withQuery($uriQuery . ($uriQuery !== '' && $query !== '' ? '&' : '') . $query); + } catch (InvalidArgumentException) { + $this->absurd(); + } } - $uri = $this->uri; - if (is_string($uri)) { - $uri = $this->uriFactory->createUri($uri); + $request = $this->requestFactory->createRequest('POST', $uri); + try { + $request = $request->withBody($body); + } catch (InvalidArgumentException) { + $this->absurd(); } - $uriQuery = $uri->getQuery(); - $uri = $uri->withQuery($uriQuery . ($uriQuery !== '' && $query !== '' ? '&' : '') . $query); + return $request; + } - return $this->requestFactory->createRequest('POST', $uri) - ->withBody($this->streamFactory->createStream($requestOptions->sql)); + /** @psalm-return never */ + private function absurd(): void + { + throw new RuntimeException('Called `absurd` function which should never be called'); } } diff --git a/src/Client/PsrClickHouseAsyncClient.php b/src/Client/PsrClickHouseAsyncClient.php index 52c7265..aafa191 100644 --- a/src/Client/PsrClickHouseAsyncClient.php +++ b/src/Client/PsrClickHouseAsyncClient.php @@ -5,6 +5,7 @@ namespace SimPod\ClickHouseClient\Client; use DateTimeZone; +use Exception; use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; use Http\Client\HttpAsyncClient; @@ -31,6 +32,11 @@ public function __construct( $this->sqlFactory = new SqlFactory(new ValueFormatter($clickHouseTimeZone)); } + /** + * {@inheritDoc} + * + * @throws Exception + */ public function select(string $sql, Format $outputFormat, array $settings = []): PromiseInterface { $formatClause = $outputFormat::toSql(); @@ -45,6 +51,11 @@ public function select(string $sql, Format $outputFormat, array $settings = []): ); } + /** + * {@inheritDoc} + * + * @throws Exception + */ public function selectWithParams( string $sql, array $params, @@ -61,6 +72,8 @@ public function selectWithParams( /** * @param array $settings * @param (callable(ResponseInterface):mixed)|null $processResponse + * + * @throws Exception */ private function executeRequest( string $sql, @@ -75,18 +88,21 @@ private function executeRequest( ), ); - return Create::promiseFor($this->asyncClient->sendAsyncRequest($request))->then( - static function (ResponseInterface $response) use ($processResponse) { - if ($response->getStatusCode() !== 200) { - throw ServerError::fromResponse($response); - } + return Create::promiseFor( + $this->asyncClient->sendAsyncRequest($request), + ) + ->then( + static function (ResponseInterface $response) use ($processResponse) { + if ($response->getStatusCode() !== 200) { + throw ServerError::fromResponse($response); + } - if ($processResponse === null) { - return $response; - } + if ($processResponse === null) { + return $response; + } - return $processResponse($response); - }, - ); + return $processResponse($response); + }, + ); } } diff --git a/src/Client/PsrClickHouseClient.php b/src/Client/PsrClickHouseClient.php index a34378e..d2da1bd 100644 --- a/src/Client/PsrClickHouseClient.php +++ b/src/Client/PsrClickHouseClient.php @@ -5,6 +5,7 @@ namespace SimPod\ClickHouseClient\Client; use DateTimeZone; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\ResponseInterface; use SimPod\ClickHouseClient\Client\Http\RequestFactory; @@ -128,7 +129,12 @@ public function insertWithFormat(string $table, Format $inputFormat, string $dat ); } - /** @param array $settings */ + /** + * @param array $settings + * + * @throws ServerError + * @throws ClientExceptionInterface + */ private function executeRequest(string $sql, array $settings = []): ResponseInterface { $request = $this->requestFactory->prepareRequest( diff --git a/src/Format/Json.php b/src/Format/Json.php index 459b744..9c7342f 100644 --- a/src/Format/Json.php +++ b/src/Format/Json.php @@ -4,6 +4,7 @@ namespace SimPod\ClickHouseClient\Format; +use Safe\Exceptions\JsonException; use SimPod\ClickHouseClient\Output\Output; /** @@ -12,6 +13,7 @@ */ final class Json implements Format { + /** @throws JsonException */ public static function output(string $contents): Output { return new \SimPod\ClickHouseClient\Output\Json($contents); diff --git a/src/Format/JsonCompact.php b/src/Format/JsonCompact.php index 7263a66..1e9e1f3 100644 --- a/src/Format/JsonCompact.php +++ b/src/Format/JsonCompact.php @@ -4,6 +4,7 @@ namespace SimPod\ClickHouseClient\Format; +use Safe\Exceptions\JsonException; use SimPod\ClickHouseClient\Output\Output; /** @@ -12,6 +13,7 @@ */ final class JsonCompact implements Format { + /** @throws JsonException */ public static function output(string $contents): Output { return new \SimPod\ClickHouseClient\Output\JsonCompact($contents); diff --git a/src/Format/JsonEachRow.php b/src/Format/JsonEachRow.php index 732cce7..4d669d9 100644 --- a/src/Format/JsonEachRow.php +++ b/src/Format/JsonEachRow.php @@ -4,6 +4,7 @@ namespace SimPod\ClickHouseClient\Format; +use Safe\Exceptions\JsonException; use SimPod\ClickHouseClient\Output\Output; /** @@ -12,6 +13,7 @@ */ final class JsonEachRow implements Format { + /** @throws JsonException */ public static function output(string $contents): Output { return new \SimPod\ClickHouseClient\Output\JsonEachRow($contents); diff --git a/src/Output/Json.php b/src/Output/Json.php index 247d702..1ac07c2 100644 --- a/src/Output/Json.php +++ b/src/Output/Json.php @@ -4,6 +4,8 @@ namespace SimPod\ClickHouseClient\Output; +use Safe\Exceptions\JsonException; + use function Safe\json_decode; /** @@ -26,6 +28,7 @@ final class Json implements Output /** @var array{elapsed: float, rows_read: int, bytes_read: int} */ public array $statistics; + /** @throws JsonException */ public function __construct(string $contentsJson) { // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong diff --git a/src/Output/JsonCompact.php b/src/Output/JsonCompact.php index 6bc92b3..60793dd 100644 --- a/src/Output/JsonCompact.php +++ b/src/Output/JsonCompact.php @@ -4,6 +4,8 @@ namespace SimPod\ClickHouseClient\Output; +use Safe\Exceptions\JsonException; + use function Safe\json_decode; /** @@ -26,6 +28,7 @@ final class JsonCompact implements Output /** @var array{elapsed: float, rows_read: int, bytes_read: int} */ public array $statistics; + /** @throws JsonException */ public function __construct(string $contentsJson) { /** diff --git a/src/Output/JsonEachRow.php b/src/Output/JsonEachRow.php index 9314273..f59a14e 100644 --- a/src/Output/JsonEachRow.php +++ b/src/Output/JsonEachRow.php @@ -4,6 +4,8 @@ namespace SimPod\ClickHouseClient\Output; +use Safe\Exceptions\JsonException; + use function Safe\json_decode; use function sprintf; use function str_replace; @@ -18,6 +20,7 @@ final class JsonEachRow implements Output /** @var list */ public array $data; + /** @throws JsonException */ public function __construct(string $contentsJson) { /** diff --git a/src/Snippet/CurrentDatabase.php b/src/Snippet/CurrentDatabase.php index 1a0cde9..60a53d0 100644 --- a/src/Snippet/CurrentDatabase.php +++ b/src/Snippet/CurrentDatabase.php @@ -4,11 +4,19 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; final class CurrentDatabase { + /** + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + */ public static function run(ClickHouseClient $clickHouseClient): string { /** @var JsonEachRow $format */ diff --git a/src/Snippet/DatabaseSize.php b/src/Snippet/DatabaseSize.php index 110288f..fa159fc 100644 --- a/src/Snippet/DatabaseSize.php +++ b/src/Snippet/DatabaseSize.php @@ -4,12 +4,22 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; +use SimPod\ClickHouseClient\Exception\UnsupportedValue; use SimPod\ClickHouseClient\Format\JsonEachRow; use SimPod\ClickHouseClient\Sql\Expression; final class DatabaseSize { + /** + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + * @throws UnsupportedValue + */ public static function run(ClickHouseClient $clickHouseClient, string|null $databaseName = null): int { /** @var JsonEachRow $format */ diff --git a/src/Snippet/Parts.php b/src/Snippet/Parts.php index f9086d3..dc5633a 100644 --- a/src/Snippet/Parts.php +++ b/src/Snippet/Parts.php @@ -4,14 +4,25 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; +use SimPod\ClickHouseClient\Exception\UnsupportedValue; use SimPod\ClickHouseClient\Format\JsonEachRow; use function sprintf; final class Parts { - /** @return array> */ + /** + * @return array> + * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + * @throws UnsupportedValue + */ public static function run(ClickHouseClient $clickHouseClient, string $table, bool|null $active = null): array { $whereActiveClause = $active === null ? '' : sprintf(' AND active = %d', $active); diff --git a/src/Snippet/ShowCreateTable.php b/src/Snippet/ShowCreateTable.php index 5219b46..28a3c19 100644 --- a/src/Snippet/ShowCreateTable.php +++ b/src/Snippet/ShowCreateTable.php @@ -4,11 +4,19 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; final class ShowCreateTable { + /** + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + */ public static function run(ClickHouseClient $clickHouseClient, string $tableName): string { /** @var JsonEachRow $format */ diff --git a/src/Snippet/ShowDatabases.php b/src/Snippet/ShowDatabases.php index f0ee594..c95c9d7 100644 --- a/src/Snippet/ShowDatabases.php +++ b/src/Snippet/ShowDatabases.php @@ -4,14 +4,23 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; use function array_map; final class ShowDatabases { - /** @return list */ + /** + * @return list + * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + */ public static function run(ClickHouseClient $clickHouseClient): array { /** @var JsonEachRow $format */ diff --git a/src/Snippet/TableSizes.php b/src/Snippet/TableSizes.php index 93280f7..e2fb766 100644 --- a/src/Snippet/TableSizes.php +++ b/src/Snippet/TableSizes.php @@ -4,14 +4,25 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; +use SimPod\ClickHouseClient\Exception\UnsupportedValue; use SimPod\ClickHouseClient\Format\JsonEachRow; use SimPod\ClickHouseClient\Sql\Expression; /** @phpstan-type Entry array{table: string, database: string, size: string, min_date: string, max_date: string} */ final class TableSizes { - /** @return array */ + /** + * @return array + * + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + * @throws UnsupportedValue + */ public static function run(ClickHouseClient $clickHouseClient, string|null $databaseName = null): array { /** @var JsonEachRow $format */ diff --git a/src/Snippet/Version.php b/src/Snippet/Version.php index da9590f..779b962 100644 --- a/src/Snippet/Version.php +++ b/src/Snippet/Version.php @@ -4,11 +4,19 @@ namespace SimPod\ClickHouseClient\Snippet; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; final class Version { + /** + * @throws ClientExceptionInterface + * @throws PcreException + * @throws ServerError + */ public static function run(ClickHouseClient $clickHouseClient): string { /** @var JsonEachRow $format */ diff --git a/src/Sql/SqlFactory.php b/src/Sql/SqlFactory.php index c8724fa..deb9247 100644 --- a/src/Sql/SqlFactory.php +++ b/src/Sql/SqlFactory.php @@ -4,6 +4,9 @@ namespace SimPod\ClickHouseClient\Sql; +use Safe\Exceptions\PcreException; +use SimPod\ClickHouseClient\Exception\UnsupportedValue; + use function Safe\preg_replace; use function sprintf; use function str_replace; @@ -15,7 +18,12 @@ public function __construct(private ValueFormatter $valueFormatter) { } - /** @param array $parameters */ + /** + * @param array $parameters + * + * @throws PcreException + * @throws UnsupportedValue + */ public function createWithParameters(string $query, array $parameters): string { /** @var mixed $value */ diff --git a/src/Sql/ValueFormatter.php b/src/Sql/ValueFormatter.php index 5421ce6..7bcdde1 100644 --- a/src/Sql/ValueFormatter.php +++ b/src/Sql/ValueFormatter.php @@ -7,6 +7,7 @@ use BackedEnum; use DateTimeImmutable; use DateTimeZone; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Exception\UnsupportedValue; use function array_key_first; @@ -29,6 +30,10 @@ public function __construct(private DateTimeZone|null $dateTimeZone = null) { } + /** + * @throws PcreException + * @throws UnsupportedValue + */ public function format(mixed $value, string|null $paramName = null, string|null $sql = null): string { if (is_string($value)) { diff --git a/tests/ClickHouseVersion.php b/tests/ClickHouseVersion.php index 73d401f..e991a3e 100644 --- a/tests/ClickHouseVersion.php +++ b/tests/ClickHouseVersion.php @@ -19,6 +19,7 @@ final class ClickHouseVersion { private const EnvName = 'CLICKHOUSE_VERSION'; + /** @throws RuntimeException */ public static function get(): int { $versionString = $_ENV[self::EnvName]; diff --git a/tests/WithClient.php b/tests/WithClient.php index b279552..9ae908d 100644 --- a/tests/WithClient.php +++ b/tests/WithClient.php @@ -4,12 +4,16 @@ namespace SimPod\ClickHouseClient\Tests; +use InvalidArgumentException; use Nyholm\Psr7\Factory\Psr17Factory; +use Psr\Http\Client\ClientExceptionInterface; +use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseAsyncClient; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Client\Http\RequestFactory; use SimPod\ClickHouseClient\Client\PsrClickHouseAsyncClient; use SimPod\ClickHouseClient\Client\PsrClickHouseClient; +use SimPod\ClickHouseClient\Exception\ServerError; use Symfony\Component\HttpClient\CurlHttpClient; use Symfony\Component\HttpClient\HttplugClient; use Symfony\Component\HttpClient\Psr18Client; @@ -37,7 +41,19 @@ public function setupClickHouseClient(): void $this->restartClickHouseClient(); } - public function restartClickHouseClient(): void + /** @after */ + public function tearDownDataBase(): void + { + $this->controllerClient->executeQuery(sprintf('DROP DATABASE IF EXISTS "%s"', $this->currentDbName)); + } + + /** + * @throws ClientExceptionInterface + * @throws InvalidArgumentException + * @throws PcreException + * @throws ServerError + */ + private function restartClickHouseClient(): void { $databaseName = getenv('CLICKHOUSE_DATABASE'); $username = getenv('CLICKHOUSE_USER'); @@ -101,10 +117,4 @@ public function restartClickHouseClient(): void $this->controllerClient->executeQuery(sprintf('DROP DATABASE IF EXISTS "%s"', $this->currentDbName)); $this->controllerClient->executeQuery(sprintf('CREATE DATABASE "%s"', $this->currentDbName)); } - - /** @after */ - public function tearDownDataBase(): void - { - $this->controllerClient->executeQuery(sprintf('DROP DATABASE IF EXISTS "%s"', $this->currentDbName)); - } }