1212use Tinderbox \Clickhouse \Common \MergedFiles ;
1313use Tinderbox \Clickhouse \Common \TempTable ;
1414use Tinderbox \Clickhouse \Exceptions \TransportException ;
15+ use Tinderbox \Clickhouse \Support \ServerTrait ;
1516use Tinderbox \Clickhouse \Transport \HttpTransport ;
1617
1718/**
1819 * @covers \Tinderbox\Clickhouse\Transport\HttpTransport
1920 */
2021class HttpTransportTest extends TestCase
2122{
23+ use ServerTrait;
24+
2225 protected function getMockedTransport (array $ responses ) : HttpTransport
2326 {
2427 $ mock = new MockHandler ($ responses );
@@ -35,11 +38,6 @@ protected function getQuery() : Query
3538 return new Query ($ this ->getServer (), 'select * from table ' );
3639 }
3740
38- protected function getServer () : Server
39- {
40- return new Server (CLICKHOUSE_SERVER_HOST , CLICKHOUSE_SERVER_PORT , 'default ' , 'default ' );
41- }
42-
4341 protected function getTransport () : HttpTransport
4442 {
4543 return new HttpTransport ();
@@ -379,11 +377,10 @@ public function testConnectionWithPassword()
379377 $ this ->expectException (TransportException::class);
380378 $ this ->expectExceptionMessageRegExp ('/Wrong password for user default/ ' );
381379
382- $ transport ->read ([
383- new Query (new Server ('127.0.0.1 ' , 8123 , 'default ' ,'default ' , 'pass ' ), 'select 1 ' , [
384- new TempTable ('name ' , new FileFromString ('aaa ' ), ['string ' => 'String ' ], Format::TSV )
385- ])
386- ]);
380+ $ server = $ this ->getServer ('default ' , 'default ' , 'pass ' );
381+ $ file = new TempTable ('name ' , new FileFromString ('aaa ' ), ['string ' => 'String ' ], Format::TSV );
382+
383+ $ transport ->read ([new Query ($ server , 'select 1 ' , [$ file ])]);
387384 }
388385
389386 public function testConnectionWithPasswordOnWrite ()
@@ -393,10 +390,10 @@ public function testConnectionWithPasswordOnWrite()
393390 $ this ->expectException (TransportException::class);
394391 $ this ->expectExceptionMessageRegExp ('/Wrong password for user default/ ' );
395392
393+ $ server = $ this ->getServer ('default ' , 'default ' , 'pass ' );
394+
396395 $ transport ->write ([
397- new Query (new Server ('127.0.0.1 ' , 8123 , 'default ' ,'default ' , 'pass ' ), 'insert into table 1 ' , [
398- new FileFromString ('aaa ' )
399- ])
396+ new Query ($ server , 'insert into table ' , [new FileFromString ('aaa ' )])
400397 ]);
401398 }
402399
0 commit comments