@@ -27,6 +27,19 @@ protected function setUp()
27
27
public function createEngineProvider ()
28
28
{
29
29
return [
30
+ #0
31
+ ["Engine = MergeTree(a, b, 8192) " ,
32
+ ['engine ' => 'MergeTree ' ,
33
+ 'engine_param ' => ['a ' , 'b ' , 8192 ],
34
+ 'merge_tree_fam ' => true ,
35
+ 'date_field ' => 'a ' ,
36
+ 'sampl ' => false ,
37
+ 'primary_key ' => 'b ' ,
38
+ 'granul ' => 8192 ,
39
+ 'ver ' => false
40
+ ]],
41
+
42
+ #1
30
43
["ENGINE = MergeTree(dt, (id, dt), 8192, ver) " ,
31
44
['engine ' => 'MergeTree ' ,
32
45
'engine_param ' => ['dt ' , '(id, dt) ' , 8192 , 'ver ' ],
@@ -38,6 +51,7 @@ public function createEngineProvider()
38
51
'ver ' => 'ver '
39
52
]],
40
53
54
+ #2
41
55
["ENGINE = MergeTree(dt, (id, dt), 8192) " ,
42
56
['engine ' => 'MergeTree ' ,
43
57
'engine_param ' => ['dt ' , '(id, dt) ' , 8192 ],
@@ -49,6 +63,7 @@ public function createEngineProvider()
49
63
'ver ' => ''
50
64
]],
51
65
66
+ #3
52
67
["ENGINE = MergeTree(dt, sampl, (id, dt), 8192) " ,
53
68
['engine ' => 'MergeTree ' ,
54
69
'engine_param ' => ['dt ' , 'sampl ' , '(id, dt) ' , 8192 ],
@@ -60,6 +75,7 @@ public function createEngineProvider()
60
75
'ver ' => ''
61
76
]],
62
77
78
+ #4
63
79
["ENGINE = Log " ,
64
80
['engine ' => 'Log ' ,
65
81
'engine_param ' => ['' ],
@@ -71,11 +87,14 @@ public function createEngineProvider()
71
87
'ver ' => ''
72
88
]],
73
89
90
+ #5
74
91
["ENGINE = Log( " , false ],
92
+
93
+ #6
75
94
["IMAGINE = Log " , false ],
76
- ["Engine = MergeTree(a, b, 8192) " , false ],
77
- ["Engine = MergeTree(a, (), 8192) " , false ],
78
95
96
+ #7
97
+ ["Engine = MergeTree(a, (), 8192) " , false ],
79
98
];
80
99
}
81
100
@@ -101,6 +120,9 @@ public function testParseCreateEngineSql($sql, $regpars)
101
120
}
102
121
}
103
122
} else {
123
+ if (\is_array ($ ans )) {
124
+ print_r ($ ans );
125
+ }
104
126
$ this ->assertFalse (\is_array ($ ans ));
105
127
}
106
128
}
@@ -707,6 +729,32 @@ public function testMakeFieldCreater($name, $type, $default, $creater)
707
729
$ this ->assertEquals ($ creater , $ ans );
708
730
}
709
731
732
+ /**
733
+ * Data provider for testIsValidName
734
+ *
735
+ * @return array of name, isValid, ret_name
736
+ */
737
+ public function isValidNameProvider ()
738
+ {
739
+ return [
740
+ ['id ' , true , false ],
741
+ ['id ' , 'id ' , true ],
742
+ ['' , false , false ],
743
+ ];
744
+ }
745
+
746
+ /**
747
+ * @dataProvider isValidNameProvider
748
+ * @covers ierusalim\ClickHouse\ClickHouseSQLParser::isValidName
749
+ * @todo Implement testMakeFieldCreater().
750
+ */
751
+ public function testIsValidName ($ name , $ isValid , $ ret_name )
752
+ {
753
+ $ ch = $ this ->object ;
754
+ $ ans = $ ch ->isValidName ($ name , $ ret_name );
755
+ $ this ->assertEquals ($ isValid , $ ans );
756
+ }
757
+
710
758
/**
711
759
* Data provider for testParseCreateFields
712
760
*
0 commit comments