diff --git a/tests/Client/InsertTest.php b/tests/Client/InsertTest.php index e54fa43..f204509 100644 --- a/tests/Client/InsertTest.php +++ b/tests/Client/InsertTest.php @@ -33,11 +33,11 @@ public function testInsert(string $tableSql): void ['PageViews' => 6, 'UserID' => 4324182021466249494, 'Duration' => 185, 'Sign' => 1], ]; - $this->client->executeQuery($tableSql); + self::$client->executeQuery($tableSql); - $this->client->insert('UserActivity', $data); + self::$client->insert('UserActivity', $data); - $output = $this->client->select( + $output = self::$client->select( <<<'CLICKHOUSE' SELECT * FROM UserActivity CLICKHOUSE, @@ -57,9 +57,9 @@ public function testInsertUseColumns(string $tableSql): void ['PageViews' => 6, 'UserID' => '4324182021466249494', 'Duration' => 185, 'Sign' => 1], ]; - $this->client->executeQuery($tableSql); + self::$client->executeQuery($tableSql); - $this->client->insert( + self::$client->insert( 'UserActivity', [ [5, 4324182021466249494, 146, -1], @@ -68,7 +68,7 @@ public function testInsertUseColumns(string $tableSql): void ['PageViews', 'UserID', 'Duration', 'Sign'], ); - $output = $this->client->select( + $output = self::$client->select( <<<'CLICKHOUSE' SELECT * FROM UserActivity CLICKHOUSE, @@ -80,7 +80,7 @@ public function testInsertUseColumns(string $tableSql): void public function testInsertEscaping(): void { - $this->client->executeQuery( + self::$client->executeQuery( <<<'CLICKHOUSE' CREATE TABLE a ( b Nullable(String) @@ -94,9 +94,9 @@ public function testInsertEscaping(): void ["\t"], ]; - $this->client->insert('a', $expectedData); + self::$client->insert('a', $expectedData); - $output = $this->client->select( + $output = self::$client->select( <<<'CLICKHOUSE' SELECT * FROM a CLICKHOUSE, @@ -124,7 +124,7 @@ public static function providerInsert(): iterable public function testInsertWithFormat(): void { - $this->client->executeQuery( + self::$client->executeQuery( <<<'CLICKHOUSE' CREATE TABLE UserActivity ( PageViews UInt32, @@ -136,7 +136,7 @@ public function testInsertWithFormat(): void CLICKHOUSE, ); - $this->client->insertWithFormat( + self::$client->insertWithFormat( 'UserActivity', new JsonEachRow(), <<<'JSONEACHROW' @@ -145,7 +145,7 @@ public function testInsertWithFormat(): void JSONEACHROW, ); - $output = $this->client->select( + $output = self::$client->select( <<<'CLICKHOUSE' SELECT * FROM UserActivity CLICKHOUSE @@ -166,13 +166,13 @@ public function testInsertEmptyValuesThrowsException(): void { $this->expectException(CannotInsert::class); - $this->client->insert('table', []); + self::$client->insert('table', []); } public function testInsertToNonExistentTableExpectServerError(): void { $this->expectException(ServerError::class); - $this->client->insert('table', [[1]]); + self::$client->insert('table', [[1]]); } } diff --git a/tests/Client/SelectTest.php b/tests/Client/SelectTest.php index e0bea1e..7de844a 100644 --- a/tests/Client/SelectTest.php +++ b/tests/Client/SelectTest.php @@ -34,7 +34,7 @@ final class SelectTest extends TestCaseBase public function testSelectWithParams(): void { - $client = $this->client; + $client = self::$client; $output = $client->selectWithParams('SELECT {p1:UInt8} AS data', ['p1' => 3], new TabSeparated()); self::assertSame("3\n", $output->contents); @@ -43,7 +43,7 @@ public function testSelectWithParams(): void #[DataProvider('providerJson')] public function testJson(mixed $expectedData, string $sql): void { - $client = $this->client; + $client = self::$client; $output = $client->select($sql, new Json()); self::assertSame($expectedData, $output->data); @@ -82,7 +82,7 @@ public static function providerJson(): iterable #[DataProvider('providerJsonCompact')] public function testJsonCompact(mixed $expectedData, string $sql): void { - $client = $this->client; + $client = self::$client; $output = $client->select($sql, new JsonCompact()); self::assertSame($expectedData, $output->data); @@ -121,7 +121,7 @@ public static function providerJsonCompact(): iterable #[DataProvider('providerJsonEachRow')] public function testJsonEachRow(mixed $expectedData, string $sql): void { - $client = $this->client; + $client = self::$client; $output = $client->select($sql, new JsonEachRow()); self::assertSame($expectedData, $output->data); @@ -159,7 +159,7 @@ public static function providerJsonEachRow(): iterable public function testNull(): void { - $client = $this->client; + $client = self::$client; $client->select('SELECT 1', new Null_()); self::assertTrue(true); @@ -170,6 +170,6 @@ public function testSettingsArePassed(): void self::expectException(ServerError::class); $this->expectExceptionMessageMatches("~DB::Exception: Database `non-existent` (doesn't|does not) exist~"); - $this->client->select('SELECT 1', new JsonCompact(), ['database' => 'non-existent']); + self::$client->select('SELECT 1', new JsonCompact(), ['database' => 'non-existent']); } } diff --git a/tests/Snippet/CurrentDatabaseTest.php b/tests/Snippet/CurrentDatabaseTest.php index 417959e..4a2f198 100644 --- a/tests/Snippet/CurrentDatabaseTest.php +++ b/tests/Snippet/CurrentDatabaseTest.php @@ -18,7 +18,7 @@ public function testRun(): void { self::assertSame( $this->currentDbName, - CurrentDatabase::run($this->client), + CurrentDatabase::run(self::$client), ); } } diff --git a/tests/Snippet/DatabaseSizeTest.php b/tests/Snippet/DatabaseSizeTest.php index 1bc1e66..f779a22 100644 --- a/tests/Snippet/DatabaseSizeTest.php +++ b/tests/Snippet/DatabaseSizeTest.php @@ -18,7 +18,7 @@ final class DatabaseSizeTest extends TestCaseBase public function setUp(): void { - $this->client->executeQuery( + self::$client->executeQuery( <<<'CLICKHOUSE' CREATE TABLE test ( a_date DateTime, @@ -33,9 +33,9 @@ public function setUp(): void public function testRun(): void { - self::assertSame(0, DatabaseSize::run($this->client)); + self::assertSame(0, DatabaseSize::run(self::$client)); - $this->client->insert('test', [[new DateTimeImmutable('2020-08-01 00:11:22'), 1]]); + self::$client->insert('test', [[new DateTimeImmutable('2020-08-01 00:11:22'), 1]]); if (ClickHouseVersion::get() >= 2307) { $expectedSize = 316; @@ -45,11 +45,11 @@ public function testRun(): void $expectedSize = 150; } - self::assertSame($expectedSize, DatabaseSize::run($this->client)); + self::assertSame($expectedSize, DatabaseSize::run(self::$client)); } public function tearDown(): void { - $this->client->executeQuery('DROP TABLE test'); + self::$client->executeQuery('DROP TABLE test'); } } diff --git a/tests/Snippet/PartsTest.php b/tests/Snippet/PartsTest.php index 24bbb0b..0232430 100644 --- a/tests/Snippet/PartsTest.php +++ b/tests/Snippet/PartsTest.php @@ -16,6 +16,6 @@ final class PartsTest extends TestCaseBase public function testRun(): void { - self::assertSame([], Parts::run($this->client, 'system.query_log')); + self::assertSame([], Parts::run(self::$client, 'system.query_log')); } } diff --git a/tests/Snippet/ShowCreateTableTest.php b/tests/Snippet/ShowCreateTableTest.php index fa1f3ca..70c7680 100644 --- a/tests/Snippet/ShowCreateTableTest.php +++ b/tests/Snippet/ShowCreateTableTest.php @@ -24,9 +24,9 @@ public function testRun(): void CREATE TABLE $dbName.test (`date` Date) ENGINE = Memory CLICKHOUSE; - $this->client->executeQuery($sql); + self::$client->executeQuery($sql); - $createTableSql = ShowCreateTable::run($this->client, 'test'); + $createTableSql = ShowCreateTable::run(self::$client, 'test'); // BC $createTableSql = str_replace( diff --git a/tests/Snippet/ShowDatabasesTest.php b/tests/Snippet/ShowDatabasesTest.php index 9456245..d486a2f 100644 --- a/tests/Snippet/ShowDatabasesTest.php +++ b/tests/Snippet/ShowDatabasesTest.php @@ -23,7 +23,7 @@ final class ShowDatabasesTest extends TestCaseBase public function testRun(): void { - $databases = ShowDatabases::run($this->client); + $databases = ShowDatabases::run(self::$client); self::assertGreaterThan(2, count($databases)); // Default, system, at least one test database $databases = array_filter( diff --git a/tests/Snippet/TableSizesTest.php b/tests/Snippet/TableSizesTest.php index 6e7e92b..16214c4 100644 --- a/tests/Snippet/TableSizesTest.php +++ b/tests/Snippet/TableSizesTest.php @@ -17,7 +17,7 @@ final class TableSizesTest extends TestCaseBase public function setUp(): void { - $this->client->executeQuery( + self::$client->executeQuery( <<<'CLICKHOUSE' CREATE TABLE test ( a_date DateTime, @@ -32,18 +32,18 @@ public function setUp(): void public function testRun(): void { - $this->client->insert('test', [[new DateTimeImmutable(), 1]]); + self::$client->insert('test', [[new DateTimeImmutable(), 1]]); - self::assertCount(1, TableSizes::run($this->client)); + self::assertCount(1, TableSizes::run(self::$client)); } public function testRunOnNonexistentDatabase(): void { - self::assertSame([], TableSizes::run($this->client, 'does not exist')); + self::assertSame([], TableSizes::run(self::$client, 'does not exist')); } public function tearDown(): void { - $this->client->executeQuery('DROP TABLE test'); + self::$client->executeQuery('DROP TABLE test'); } } diff --git a/tests/Snippet/VersionTest.php b/tests/Snippet/VersionTest.php index 205f870..f661c4a 100644 --- a/tests/Snippet/VersionTest.php +++ b/tests/Snippet/VersionTest.php @@ -16,6 +16,6 @@ final class VersionTest extends TestCaseBase public function testRun(): void { - self::assertMatchesRegularExpression('~(\d+\.)+\d+~', Version::run($this->client)); + self::assertMatchesRegularExpression('~(\d+\.)+\d+~', Version::run(self::$client)); } }