Passed
Branch master (366c16)
by William
03:30
created

IntoKeywordTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 5 1
A testBuildOutfile() 0 4 1
A testBuildValues() 0 4 1
A testParseErr1() 0 4 1
A testBuild() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Tests\Components;
6
7
use PhpMyAdmin\SqlParser\Components\IntoKeyword;
8
use PhpMyAdmin\SqlParser\Parser;
9
use PhpMyAdmin\SqlParser\Tests\TestCase;
10
11
class IntoKeywordTest extends TestCase
12
{
13
    public function testParse()
14
    {
15
        $component = IntoKeyword::parse(new Parser(), $this->getTokensList('OUTFILE "/tmp/outfile.txt"'));
16
        $this->assertEquals($component->type, 'OUTFILE');
17
        $this->assertEquals($component->dest, '/tmp/outfile.txt');
18
    }
19
20
    public function testBuild()
21
    {
22
        $component = IntoKeyword::parse(new Parser(), $this->getTokensList('tbl(`col1`, `col2`)'));
23
        $this->assertEquals('tbl(`col1`, `col2`)', IntoKeyword::build($component));
24
    }
25
26
    public function testBuildValues()
27
    {
28
        $component = IntoKeyword::parse(new Parser(), $this->getTokensList('@a1, @a2, @a3'));
29
        $this->assertEquals('@a1, @a2, @a3', IntoKeyword::build($component));
30
    }
31
32
    public function testBuildOutfile()
33
    {
34
        $component = IntoKeyword::parse(new Parser(), $this->getTokensList('OUTFILE "/tmp/outfile.txt"'));
35
        $this->assertEquals('OUTFILE "/tmp/outfile.txt"', IntoKeyword::build($component));
36
    }
37
38
    public function testParseErr1()
39
    {
40
        $component = IntoKeyword::parse(new Parser(), $this->getTokensList('OUTFILE;'));
41
        $this->assertEquals($component->type, 'OUTFILE');
42
    }
43
}
44