-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathJoinKeywordTest.php
49 lines (43 loc) · 1.62 KB
/
JoinKeywordTest.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
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Tests\Components;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Parsers\JoinKeywords;
use PhpMyAdmin\SqlParser\Tests\TestCase;
class JoinKeywordTest extends TestCase
{
public function testParseIncomplete(): void
{
$component = JoinKeywords::parse(new Parser(), $this->getTokensList('JOIN a'));
$this->assertCount(1, $component);
$this->assertNotNull($component[0]->expr);
$this->assertEquals('a', $component[0]->expr->expr);
$this->assertNull($component[0]->on);
$this->assertNull($component[0]->using);
}
public function testParseIncompleteUsing(): void
{
$component = JoinKeywords::parse(new Parser(), $this->getTokensList('JOIN table2 USING (id)'));
$this->assertCount(1, $component);
$this->assertNotNull($component[0]->expr);
$this->assertEquals('table2', $component[0]->expr->expr);
$this->assertNull($component[0]->on);
$this->assertNotNull($component[0]->using);
$this->assertEquals(['id'], $component[0]->using->values);
}
public function testBuildAll(): void
{
$component = JoinKeywords::parse(
new Parser(),
$this->getTokensList(
'LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) ' .
'ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)',
),
);
$this->assertEquals(
'LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) ' .
'ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)',
JoinKeywords::buildAll($component),
);
}
}