Skip to content

Commit b0820e3

Browse files
committed
Fix setTimeout tests
1 parent 56709c6 commit b0820e3

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/Client.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function addQueryDegeneration(Degeneration $degeneration)
164164
*
165165
* @return bool
166166
*/
167-
public function enableQueryConditions()
167+
public function enableQueryConditions(): bool
168168
{
169169
return $this->transport->addQueryDegeneration(new Conditions());
170170
}
@@ -174,18 +174,20 @@ public function enableQueryConditions()
174174
*
175175
* @param string $host
176176
*/
177-
public function setHost($host)
177+
public function setHost($host): void
178178
{
179179
$this->connectHost = $host;
180180
$this->transport()->setHost($host);
181181
}
182182

183183
/**
184+
* max_execution_time , in int value (seconds)
185+
*
184186
* @return Settings
185187
*/
186-
public function setTimeout(int $timeout)
188+
public function setTimeout(int|float $timeout):Settings
187189
{
188-
return $this->settings()->max_execution_time($timeout);
190+
return $this->settings()->max_execution_time(intval($timeout));
189191
}
190192

191193
/**
@@ -199,7 +201,7 @@ public function getTimeout(): int
199201
/**
200202
* ConnectTimeOut in seconds ( support 1.5 = 1500ms )
201203
*/
202-
public function setConnectTimeOut(float $connectTimeOut)
204+
public function setConnectTimeOut(float $connectTimeOut): void
203205
{
204206
$this->transport()->setConnectTimeOut($connectTimeOut);
205207
}
@@ -215,7 +217,7 @@ public function getConnectTimeOut(): float
215217
/**
216218
* @return Http
217219
*/
218-
public function transport()
220+
public function transport(): Http
219221
{
220222
if (!$this->transport) {
221223
throw new \InvalidArgumentException('Empty transport class');
@@ -227,23 +229,23 @@ public function transport()
227229
/**
228230
* @return string
229231
*/
230-
public function getConnectHost()
232+
public function getConnectHost(): string
231233
{
232234
return $this->connectHost;
233235
}
234236

235237
/**
236238
* @return string
237239
*/
238-
public function getConnectPassword()
240+
public function getConnectPassword(): string
239241
{
240242
return $this->connectPassword;
241243
}
242244

243245
/**
244246
* @return string
245247
*/
246-
public function getConnectPort()
248+
public function getConnectPort(): string
247249
{
248250
return $this->connectPort;
249251
}

tests/FormatQueryTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ public function testClientTimeoutSettings()
6262
$this->client->database('default');
6363

6464
$timeout = 0.55; // un support, "clickhouse source - Seconds"
65-
$this->client->setTimeout($timeout); // 1500 ms
65+
$this->client->setTimeout($timeout); // 550 ms
66+
$this->client->select('SELECT 123,123 as ping ')->rows();
67+
$this->assertSame(intval($timeout), intval($this->client->getTimeout()));
68+
69+
$timeout = 2.55; // un support, "clickhouse source - Seconds"
70+
$this->client->setTimeout($timeout); // 550 ms
6671
$this->client->select('SELECT 123,123 as ping ')->rows();
6772
$this->assertSame(intval($timeout), intval($this->client->getTimeout()));
6873

@@ -76,7 +81,10 @@ public function testClientTimeoutSettings()
7681
$timeout = 5.14;
7782
$this->client->setConnectTimeOut($timeout); // 5 seconds
7883
$this->client->select('SELECT 123,123 as ping ')->rows();
84+
85+
7986
$this->assertSame(5.14, $this->client->getConnectTimeOut());
87+
8088
}
8189

8290

0 commit comments

Comments
 (0)