@@ -18,4 +18,83 @@ public function testBuilder(): void
1818
1919 $ this ->assertEquals ($ query , $ stmt ->build ());
2020 }
21+
22+ public function testBuilderShort (): void
23+ {
24+ $ query = 'CALL foo ' ;
25+
26+ $ parser = new Parser ($ query );
27+ $ stmt = $ parser ->statements [0 ];
28+
29+ $ this ->assertEquals ($ query . '() ' , $ stmt ->build ());
30+ }
31+
32+ public function testBuilderWithDbName (): void
33+ {
34+ $ query = 'CALL mydb.foo() ' ;
35+
36+ $ parser = new Parser ($ query );
37+ $ stmt = $ parser ->statements [0 ];
38+
39+ $ this ->assertEquals ($ query , $ stmt ->build ());
40+ }
41+
42+ public function testBuilderWithDbNameShort (): void
43+ {
44+ $ query = 'CALL mydb.foo ' ;
45+
46+ $ parser = new Parser ($ query );
47+ $ stmt = $ parser ->statements [0 ];
48+
49+ $ this ->assertEquals ($ query . '() ' , $ stmt ->build ());
50+ }
51+
52+ public function testBuilderWithDbNameAndParams (): void
53+ {
54+ $ query = 'CALL mydb.foo(@bar, @baz); ' ;
55+
56+ $ parser = new Parser ($ query );
57+ $ stmt = $ parser ->statements [0 ];
58+
59+ $ this ->assertEquals ('CALL mydb.foo(@bar,@baz) ' , $ stmt ->build ());
60+ }
61+
62+ public function testBuilderMultiCallsShort (): void
63+ {
64+ $ query = 'call e;call f ' ;
65+
66+ $ parser = new Parser ($ query );
67+ $ stmt = $ parser ->statements [0 ];
68+
69+ $ this ->assertEquals ('CALL e() ' , $ stmt ->build ());
70+ $ stmt = $ parser ->statements [1 ];
71+
72+ $ this ->assertEquals ('CALL f() ' , $ stmt ->build ());
73+ }
74+
75+ public function testBuilderMultiCalls (): void
76+ {
77+ $ query = 'call e();call f ' ;
78+
79+ $ parser = new Parser ($ query );
80+ $ stmt = $ parser ->statements [0 ];
81+
82+ $ this ->assertEquals ('CALL e() ' , $ stmt ->build ());
83+ $ stmt = $ parser ->statements [1 ];
84+
85+ $ this ->assertEquals ('CALL f() ' , $ stmt ->build ());
86+ }
87+
88+ public function testBuilderMultiCallsArgs (): void
89+ {
90+ $ query = 'call e("foo");call f ' ;
91+
92+ $ parser = new Parser ($ query );
93+ $ stmt = $ parser ->statements [0 ];
94+
95+ $ this ->assertEquals ('CALL e("foo") ' , $ stmt ->build ());
96+ $ stmt = $ parser ->statements [1 ];
97+
98+ $ this ->assertEquals ('CALL f() ' , $ stmt ->build ());
99+ }
21100}
0 commit comments