Skip to content

Commit 00e84f4

Browse files
committed
Fix testProgressFunction
1 parent cc48283 commit 00e84f4

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Transport/Http.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,14 @@ public function __findXClickHouseProgress($handle)
434434
if (!$header_size) {
435435
return false;
436436
}
437-
$pos = strrpos($header, 'X-ClickHouse-Progress');
438437

438+
$pos = strrpos($header, 'X-ClickHouse-Summary:');
439439
if (!$pos) {
440440
return false;
441441
}
442442

443443
$last = substr($header, $pos);
444-
$data = @json_decode(str_ireplace('X-ClickHouse-Progress:', '', $last), true);
444+
$data = @json_decode(str_ireplace('X-ClickHouse-Summary:', '', $last), true);
445445

446446
if ($data && is_callable($this->xClickHouseProgress)) {
447447

@@ -657,7 +657,7 @@ public function selectAsync($sql, array $bindings = [], $whereInFile = null, $wr
657657
/**
658658
* @param callable $callback
659659
*/
660-
public function setProgressFunction(callable $callback)
660+
public function setProgressFunction(callable $callback) : void
661661
{
662662
$this->xClickHouseProgress = $callback;
663663
}

tests/ProgressAndEscapeTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,24 @@ public function testProgressFunction()
2828
global $resultTest;
2929

3030
$this->client->settings()->set('max_block_size', 1);
31-
3231
$this->client->progressFunction(function ($data) {
3332
global $resultTest;
3433
$resultTest=$data;
3534
});
36-
$st=$this->client->select('SELECT number,sleep(0.2) FROM system.numbers limit 4');
35+
$st=$this->client->select('SELECT number,sleep(0.1) FROM system.numbers limit 2 UNION ALL SELECT number,sleep(0.1) FROM system.numbers limit 12');
3736

3837
// read_rows + read_bytes + total_rows
3938
$this->assertArrayHasKey('read_rows',$resultTest);
4039
$this->assertArrayHasKey('read_bytes',$resultTest);
40+
$this->assertArrayHasKey('written_rows',$resultTest);
41+
$this->assertArrayHasKey('written_bytes',$resultTest);
4142

4243
if (isset($resultTest['total_rows']))
4344
{
4445
$this->assertArrayHasKey('total_rows',$resultTest);
4546
} else {
4647
$this->assertArrayHasKey('total_rows_to_read',$resultTest);
4748
}
48-
49-
50-
5149
$this->assertGreaterThan(3,$resultTest['read_rows']);
5250
$this->assertGreaterThan(3,$resultTest['read_bytes']);
5351
}

0 commit comments

Comments
 (0)