Passed
Pull Request — master (#311)
by William
12:43
created

ReplaceStatementTest::testBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace PhpMyAdmin\SqlParser\Tests\Builder;
4
5
use PhpMyAdmin\SqlParser\Parser;
6
use PhpMyAdmin\SqlParser\Tests\TestCase;
7
8
class ReplaceStatementTest extends TestCase
9
{
10
    public function testBuilder()
11
    {
12
        $parser = new Parser(
13
            'REPLACE INTO tbl(col1, col2, col3) VALUES (1, "str", 3.14)'
14
        );
15
        $stmt = $parser->statements[0];
16
        $this->assertEquals(
17
            'REPLACE INTO tbl(`col1`, `col2`, `col3`) VALUES (1, "str", 3.14)',
18
            $stmt->build()
19
        );
20
    }
21
22
    public function testBuilderSet()
23
    {
24
        $parser = new Parser(
25
            'REPLACE INTO tbl(col1, col2, col3) SET col1=1, col2="str", col3=3.14'
26
        );
27
        $stmt = $parser->statements[0];
28
        $this->assertEquals(
29
            'REPLACE INTO tbl(`col1`, `col2`, `col3`) SET col1 = 1, col2 = "str", col3 = 3.14',
30
            $stmt->build()
31
        );
32
    }
33
34
    public function testBuilderSelect()
35
    {
36
        $parser = new Parser(
37
            'REPLACE INTO tbl(col1, col2, col3) SELECT col1, col2, col3 FROM tbl2'
38
        );
39
        $stmt = $parser->statements[0];
40
        $this->assertEquals(
41
            'REPLACE INTO tbl(`col1`, `col2`, `col3`) SELECT col1, col2, col3 FROM tbl2',
42
            $stmt->build()
43
        );
44
    }
45
46
    public function testBuilderSelectDelayed()
47
    {
48
        $parser = new Parser(
49
            'REPLACE DELAYED INTO tbl(col1, col2, col3) SELECT col1, col2, col3 FROM tbl2'
50
        );
51
        $stmt = $parser->statements[0];
52
        $this->assertEquals(
53
            'REPLACE DELAYED INTO tbl(`col1`, `col2`, `col3`) SELECT col1, col2, col3 FROM tbl2',
54
            $stmt->build()
55
        );
56
    }
57
}
58