Passed
Push — master ( 8591e2...201822 )
by William
13:04 queued 13s
created

CallStatementTest::testBuilderShort()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Tests\Builder;
6
7
use PhpMyAdmin\SqlParser\Parser;
8
use PhpMyAdmin\SqlParser\Tests\TestCase;
9
10
class CallStatementTest extends TestCase
11
{
12
    public function testBuilder(): void
13
    {
14
        $query = 'CALL foo()';
15
16
        $parser = new Parser($query);
17
        $stmt = $parser->statements[0];
18
19
        $this->assertEquals($query, $stmt->build());
20
    }
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 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 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 foo(@bar, @baz);';
55
56
        $parser = new Parser($query);
57
        $stmt = $parser->statements[0];
58
59
        $this->assertEquals('CALL 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
    }
100
}
101