Skip to content

Commit fbcc8ab

Browse files
authored
chore: require to specify test coverage (#162)
1 parent e253fa5 commit fbcc8ab

File tree

7 files changed

+59
-10
lines changed

7 files changed

+59
-10
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
bootstrap="tests/bootstrap.php"
99
colors="true"
1010
verbose="true"
11+
forceCoversAnnotation="true"
12+
failOnRisky="true"
1113
>
1214
<coverage>
1315
<include>

src/Exception/ServerError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ final class ServerError extends Exception
1111
{
1212
public static function fromResponse(ResponseInterface $response): self
1313
{
14-
return new self((string) $response->getBody());
14+
return new self($response->getBody()->__toString());
1515
}
1616
}

tests/Client/InsertTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
use SimPod\ClickHouseClient\Tests\TestCaseBase;
1212
use SimPod\ClickHouseClient\Tests\WithClient;
1313

14+
/**
15+
* @covers \SimPod\ClickHouseClient\Client\Http\RequestFactory
16+
* @covers \SimPod\ClickHouseClient\Client\PsrClickHouseClient
17+
* @covers \SimPod\ClickHouseClient\Exception\CannotInsert
18+
* @covers \SimPod\ClickHouseClient\Exception\ServerError
19+
* @covers \SimPod\ClickHouseClient\Format\JsonEachRow
20+
* @covers \SimPod\ClickHouseClient\Format\JsonCompact
21+
*/
1422
final class InsertTest extends TestCaseBase
1523
{
1624
use WithClient;
@@ -30,8 +38,7 @@ public function testInsert(string $tableSql): void
3038
$output = $this->client->select(
3139
<<<'CLICKHOUSE'
3240
SELECT * FROM UserActivity
33-
CLICKHOUSE
34-
,
41+
CLICKHOUSE,
3542
new JsonEachRow()
3643
);
3744

@@ -62,8 +69,7 @@ public function testInsertUseColumns(string $tableSql): void
6269
$output = $this->client->select(
6370
<<<'CLICKHOUSE'
6471
SELECT * FROM UserActivity
65-
CLICKHOUSE
66-
,
72+
CLICKHOUSE,
6773
new JsonEachRow()
6874
);
6975

@@ -91,8 +97,7 @@ public function testInsertEscaping(): void
9197
$output = $this->client->select(
9298
<<<'CLICKHOUSE'
9399
SELECT * FROM a
94-
CLICKHOUSE
95-
,
100+
CLICKHOUSE,
96101
new JsonCompact()
97102
);
98103

tests/Client/SelectAsyncTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
use SimPod\ClickHouseClient\Tests\TestCaseBase;
1212
use SimPod\ClickHouseClient\Tests\WithClient;
1313

14+
/**
15+
* @covers \SimPod\ClickHouseClient\Client\Http\RequestFactory
16+
* @covers \SimPod\ClickHouseClient\Client\PsrClickHouseAsyncClient
17+
* @covers \SimPod\ClickHouseClient\Exception\ServerError
18+
* @covers \SimPod\ClickHouseClient\Format\JsonEachRow
19+
* @covers \SimPod\ClickHouseClient\Format\TabSeparated
20+
*/
1421
final class SelectAsyncTest extends TestCaseBase
1522
{
1623
use WithClient;
@@ -24,7 +31,8 @@ public function testAsyncSelect(): void
2431
CLICKHOUSE;
2532

2633
/** @var JsonEachRow<array{number: string}> $format */
27-
$format = new JsonEachRow();
34+
$format = new JsonEachRow();
35+
2836
$promises = [
2937
$client->select($sql, $format),
3038
$client->select($sql, $format),

tests/Client/SelectTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
use SimPod\ClickHouseClient\Tests\TestCaseBase;
1212
use SimPod\ClickHouseClient\Tests\WithClient;
1313

14+
/**
15+
* @covers \SimPod\ClickHouseClient\Client\Http\RequestFactory
16+
* @covers \SimPod\ClickHouseClient\Client\PsrClickHouseClient
17+
* @covers \SimPod\ClickHouseClient\Exception\ServerError
18+
* @covers \SimPod\ClickHouseClient\Format\Json
19+
* @covers \SimPod\ClickHouseClient\Format\JsonEachRow
20+
* @covers \SimPod\ClickHouseClient\Format\JsonCompact
21+
*/
1422
final class SelectTest extends TestCaseBase
1523
{
1624
use WithClient;

tests/Logger/LoggerChainTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
namespace SimPod\ClickHouseClient\Tests\Logger;
66

7-
use PHPUnit\Framework\TestCase;
87
use SimPod\ClickHouseClient\Logger\LoggerChain;
98
use SimPod\ClickHouseClient\Logger\SqlLogger;
9+
use SimPod\ClickHouseClient\Tests\TestCaseBase;
1010

11-
final class LoggerChainTest extends TestCase
11+
/** @covers \SimPod\ClickHouseClient\Logger\LoggerChain */
12+
final class LoggerChainTest extends TestCaseBase
1213
{
1314
public function testLog(): void
1415
{

tests/Output/JsonEachRowTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimPod\ClickHouseClient\Tests\Output;
6+
7+
use SimPod\ClickHouseClient\Output\JsonEachRow;
8+
use SimPod\ClickHouseClient\Tests\TestCaseBase;
9+
10+
/** @covers \SimPod\ClickHouseClient\Output\JsonEachRow */
11+
final class JsonEachRowTest extends TestCaseBase
12+
{
13+
public function testPropertiesAreSet(): void
14+
{
15+
$format = new JsonEachRow(
16+
<<<'JSON'
17+
{"number":"0"}
18+
{"number":"1"}
19+
20+
JSON
21+
);
22+
23+
self::assertSame([['number' => '0'], ['number' => '1']], $format->data);
24+
}
25+
}

0 commit comments

Comments
 (0)