Skip to content

Commit 158aaba

Browse files
committed
0.17.12
1 parent afd2f20 commit 158aaba

File tree

2 files changed

+112
-2
lines changed

2 files changed

+112
-2
lines changed

phpunit.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
</whitelist>
1818
</filter>
1919
<php>
20-
<const name="phpunit_clickhouse_host" value="10.211.5.3"/>
21-
<!--<const name="phpunit_clickhouse_host" value="192.168.1.20"/>-->
20+
<const name="phpunit_clickhouse_host" value="tabix.dev7"/>
2221
<const name="phpunit_clickhouse_port" value="8123"/>
2322
<const name="phpunit_clickhouse_user" value="default"/>
2423
<const name="phpunit_clickhouse_pass" value=""/>

tests/02_ProgressAndEscapeTest.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
/**
6+
* Class ClientTest
7+
*/
8+
class ProgressAndEscapeTest extends TestCase
9+
{
10+
/**
11+
* @var \ClickHouseDB\Client
12+
*/
13+
private $db;
14+
15+
/**
16+
* @var
17+
*/
18+
private $tmp_path;
19+
20+
/**
21+
* @throws Exception
22+
*/
23+
public function setUp()
24+
{
25+
date_default_timezone_set('Europe/Moscow');
26+
27+
if (!defined('phpunit_clickhouse_host')) {
28+
throw new Exception("Not set phpunit_clickhouse_host in phpUnit.xml");
29+
}
30+
31+
$tmp_path = rtrim(phpunit_clickhouse_tmp_path, '/') . '/';
32+
33+
if (!is_dir($tmp_path)) {
34+
throw new Exception("Not dir in phpunit_clickhouse_tmp_path");
35+
}
36+
37+
$this->tmp_path = $tmp_path;
38+
39+
$config = [
40+
'host' => phpunit_clickhouse_host,
41+
'port' => phpunit_clickhouse_port,
42+
'username' => phpunit_clickhouse_user,
43+
'password' => phpunit_clickhouse_pass,
44+
45+
];
46+
47+
$this->db = new ClickHouseDB\Client($config);
48+
49+
50+
$this->db->ping();
51+
52+
53+
54+
}
55+
56+
/**
57+
*
58+
*/
59+
public function tearDown()
60+
{
61+
//
62+
}
63+
64+
65+
public function testEscape()
66+
{
67+
// chr(0....255);
68+
$this->db->settings()->set('max_block_size', 100);
69+
70+
$bind['k1']=1;
71+
$bind['k2']=2;
72+
73+
$select=[];
74+
for($z=0;$z<200;$z++)
75+
{
76+
$bind['k'.$z]=chr($z);
77+
$select[]=":k{$z} as k{$z}";
78+
}
79+
arsort($bind);
80+
81+
82+
$rows=$this->db->select("SELECT ".implode(",\n",$select),$bind)->rows();
83+
print_r($rows);
84+
85+
}
86+
87+
public function testProgressFunction()
88+
{
89+
global $resultTest;
90+
91+
92+
$this->db->settings()->set('max_block_size', 1);
93+
$this->setUp();
94+
95+
$this->db->progressFunction(function ($data) {
96+
global $resultTest;
97+
$resultTest=$data;
98+
});
99+
$st=$this->db->select('SELECT number,sleep(0.2) FROM system.numbers limit 5');
100+
101+
// read_rows + read_bytes + total_rows
102+
$this->assertArrayHasKey('read_rows',$resultTest);
103+
$this->assertArrayHasKey('read_bytes',$resultTest);
104+
$this->assertArrayHasKey('total_rows',$resultTest);
105+
106+
$this->assertGreaterThan(3,$resultTest['read_rows']);
107+
$this->assertGreaterThan(3,$resultTest['read_bytes']);
108+
109+
}
110+
111+
}

0 commit comments

Comments
 (0)