diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml index ad19f8a..dd710b4 100644 --- a/.github/workflows/infection.yml +++ b/.github/workflows/infection.yml @@ -31,6 +31,6 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Run Infection - run: vendor/bin/infection --min-msi=86 --min-covered-msi=90 --log-verbosity=none -s + run: vendor/bin/infection --min-msi=88 --min-covered-msi=90 --log-verbosity=none -s env: INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} diff --git a/src/Snippet/Parts.php b/src/Snippet/Parts.php index 73d79e2..b29a04a 100644 --- a/src/Snippet/Parts.php +++ b/src/Snippet/Parts.php @@ -14,7 +14,7 @@ final class Parts /** @return array> */ public static function run(ClickHouseClient $clickHouseClient, string $table, ?bool $active = null) : array { - $whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int) $active); + $whereActiveClause = $active === null ? '' : sprintf(' AND active = %d', $active); /** @var JsonEachRow> $format */ $format = new JsonEachRow(); diff --git a/src/Snippet/ShowCreateTable.php b/src/Snippet/ShowCreateTable.php index 545d658..e2d5649 100644 --- a/src/Snippet/ShowCreateTable.php +++ b/src/Snippet/ShowCreateTable.php @@ -23,6 +23,6 @@ public static function run(ClickHouseClient $clickHouseClient, string $tableName $format ); - return trim($output->data[0]['statement']); + return $output->data[0]['statement']; } } diff --git a/tests/Snippet/TableSizesTest.php b/tests/Snippet/TableSizesTest.php index 464145b..85a8761 100644 --- a/tests/Snippet/TableSizesTest.php +++ b/tests/Snippet/TableSizesTest.php @@ -4,6 +4,7 @@ namespace SimPod\ClickHouseClient\Tests\Snippet; +use DateTimeImmutable; use SimPod\ClickHouseClient\Snippet\TableSizes; use SimPod\ClickHouseClient\Tests\TestCaseBase; use SimPod\ClickHouseClient\Tests\WithClient; @@ -13,8 +14,35 @@ final class TableSizesTest extends TestCaseBase { use WithClient; + public function setUp() : void + { + $this->client->executeQuery( + <<client)); + $this->client->insert('test', [[new DateTimeImmutable(), 1]]); + + self::assertCount(1, TableSizes::run($this->client)); + } + + public function testRunOnNonexistentDatabase() : void + { + self::assertSame([], TableSizes::run($this->client, 'does not exist')); + } + + public function tearDown() : void + { + $this->client->executeQuery('DROP TABLE test'); } }