|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace PhpMyAdmin\SqlParser\Tests\Components; |
|
6
|
|
|
|
|
7
|
|
|
use PhpMyAdmin\SqlParser\Components\Array2d; |
|
8
|
|
|
use PhpMyAdmin\SqlParser\Parser; |
|
9
|
|
|
use PhpMyAdmin\SqlParser\Tests\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
class Array2dTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
public function testParse() |
|
14
|
|
|
{ |
|
15
|
|
|
$parser = new Parser(); |
|
16
|
|
|
$arrays = Array2d::parse($parser, $this->getTokensList('(1, 2) +')); |
|
17
|
|
|
$this->assertEquals( |
|
18
|
|
|
[ |
|
19
|
|
|
1, |
|
20
|
|
|
2, |
|
21
|
|
|
], |
|
22
|
|
|
$arrays[0]->values |
|
23
|
|
|
); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testBuild() |
|
27
|
|
|
{ |
|
28
|
|
|
$arrays = Array2d::parse(new Parser(), $this->getTokensList('(1, 2), (3, 4), (5, 6)')); |
|
29
|
|
|
$this->assertEquals( |
|
30
|
|
|
'(1, 2), (3, 4), (5, 6)', |
|
31
|
|
|
Array2d::build($arrays) |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testParseErr1() |
|
36
|
|
|
{ |
|
37
|
|
|
$parser = new Parser(); |
|
38
|
|
|
Array2d::parse($parser, $this->getTokensList('(1, 2 +')); |
|
39
|
|
|
|
|
40
|
|
|
$this->markTestIncomplete( |
|
41
|
|
|
'This test has not been implemented yet.' |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testParseErr2() |
|
46
|
|
|
{ |
|
47
|
|
|
$parser = new Parser(); |
|
48
|
|
|
Array2d::parse($parser, $this->getTokensList('(1, 2 TABLE')); |
|
49
|
|
|
|
|
50
|
|
|
$this->markTestIncomplete( |
|
51
|
|
|
'This test has not been implemented yet.' |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testParseErr3() |
|
56
|
|
|
{ |
|
57
|
|
|
$parser = new Parser(); |
|
58
|
|
|
Array2d::parse($parser, $this->getTokensList(')')); |
|
59
|
|
|
$this->assertCount( |
|
60
|
|
|
1, |
|
61
|
|
|
$parser->errors |
|
62
|
|
|
); |
|
63
|
|
|
$this->assertEquals( |
|
64
|
|
|
'An opening bracket followed by a set of values was expected.', |
|
65
|
|
|
$parser->errors[0]->getMessage() |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testParseErr4() |
|
70
|
|
|
{ |
|
71
|
|
|
$parser = new Parser(); |
|
72
|
|
|
Array2d::parse($parser, $this->getTokensList('TABLE')); |
|
73
|
|
|
$this->assertCount( |
|
74
|
|
|
1, |
|
75
|
|
|
$parser->errors |
|
76
|
|
|
); |
|
77
|
|
|
$this->assertEquals( |
|
78
|
|
|
'An opening bracket followed by a set of values was expected.', |
|
79
|
|
|
$parser->errors[0]->getMessage() |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function testParseErr5() |
|
84
|
|
|
{ |
|
85
|
|
|
$parser = new Parser(); |
|
86
|
|
|
Array2d::parse($parser, $this->getTokensList('(1, 2),')); |
|
87
|
|
|
$this->assertCount( |
|
88
|
|
|
1, |
|
89
|
|
|
$parser->errors |
|
90
|
|
|
); |
|
91
|
|
|
$this->assertEquals( |
|
92
|
|
|
'An opening bracket followed by a set of values was expected.', |
|
93
|
|
|
$parser->errors[0]->getMessage() |
|
94
|
|
|
); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function testParseErr6() |
|
98
|
|
|
{ |
|
99
|
|
|
$parser = new Parser(); |
|
100
|
|
|
Array2d::parse($parser, $this->getTokensList('(1, 2),(3)')); |
|
101
|
|
|
$this->assertCount( |
|
102
|
|
|
1, |
|
103
|
|
|
$parser->errors |
|
104
|
|
|
); |
|
105
|
|
|
$this->assertEquals( |
|
106
|
|
|
'2 values were expected, but found 1.', |
|
107
|
|
|
$parser->errors[0]->getMessage() |
|
108
|
|
|
); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|