-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathArrayObjTest.php
60 lines (52 loc) · 1.68 KB
/
ArrayObjTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Tests\Components;
use PhpMyAdmin\SqlParser\Components\ArrayObj;
use PhpMyAdmin\SqlParser\Components\Expression;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Parsers\ArrayObjs;
use PhpMyAdmin\SqlParser\Parsers\Expressions;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class ArrayObjTest extends TestCase
{
public function testBuildRaw(): void
{
$component = new ArrayObj(['a', 'b'], []);
$this->assertEquals('(a, b)', $component->build());
}
public function testBuildValues(): void
{
$component = new ArrayObj([], ['a', 'b']);
$this->assertEquals('(a, b)', $component->build());
}
public function testParseType(): void
{
$components = ArrayObjs::parse(
new Parser(),
$this->getTokensList('(1 + 2, 3 + 4)'),
[
'type' => Expressions::class,
'typeOptions' => ['breakOnParentheses' => true],
],
);
$this->assertIsArray($components);
$this->assertInstanceOf(Expression::class, $components[0]);
$this->assertInstanceOf(Expression::class, $components[1]);
$this->assertEquals('1 + 2', $components[0]->expr);
$this->assertEquals('3 + 4', $components[1]->expr);
}
#[DataProvider('parseProvider')]
public function testParse(string $test): void
{
$this->runParserTest($test);
}
/** @return string[][] */
public static function parseProvider(): array
{
return [
['parser/parseArrayErr1'],
['parser/parseArrayErr3'],
];
}
}