* Support php 5.3 for sql parser lib.

This commit is contained in:
qixinzhi
2023-02-10 11:24:24 +08:00
parent 7c2e937eda
commit 7c122a0b29
648 changed files with 13815 additions and 279048 deletions
@@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Tests\Components;
use PhpMyAdmin\SqlParser\Components\Array2d;
@@ -10,20 +8,20 @@ use PhpMyAdmin\SqlParser\Tests\TestCase;
class Array2dTest extends TestCase
{
public function testParse(): void
public function testParse()
{
$parser = new Parser();
$arrays = Array2d::parse($parser, $this->getTokensList('(1, 2) +'));
$this->assertEquals(
[
array(
1,
2,
],
),
$arrays[0]->values
);
}
public function testBuild(): void
public function testBuild()
{
$arrays = Array2d::parse(new Parser(), $this->getTokensList('(1, 2), (3, 4), (5, 6)'));
$this->assertEquals(
@@ -32,60 +30,76 @@ class Array2dTest extends TestCase
);
}
public function testParseErr1(): void
public function testParseErr1()
{
$parser = new Parser();
Array2d::parse($parser, $this->getTokensList('(1, 2 +'));
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
public function testParseErr2(): void
public function testParseErr2()
{
$parser = new Parser();
Array2d::parse($parser, $this->getTokensList('(1, 2 TABLE'));
$this->markTestIncomplete('This test has not been implemented yet.');
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
public function testParseErr3(): void
public function testParseErr3()
{
$parser = new Parser();
Array2d::parse($parser, $this->getTokensList(')'));
$this->assertCount(1, $parser->errors);
$this->assertCount(
1,
$parser->errors
);
$this->assertEquals(
'An opening bracket followed by a set of values was expected.',
$parser->errors[0]->getMessage()
);
}
public function testParseErr4(): void
public function testParseErr4()
{
$parser = new Parser();
Array2d::parse($parser, $this->getTokensList('TABLE'));
$this->assertCount(1, $parser->errors);
$this->assertCount(
1,
$parser->errors
);
$this->assertEquals(
'An opening bracket followed by a set of values was expected.',
$parser->errors[0]->getMessage()
);
}
public function testParseErr5(): void
public function testParseErr5()
{
$parser = new Parser();
Array2d::parse($parser, $this->getTokensList('(1, 2),'));
$this->assertCount(1, $parser->errors);
$this->assertCount(
1,
$parser->errors
);
$this->assertEquals(
'An opening bracket followed by a set of values was expected.',
$parser->errors[0]->getMessage()
);
}
public function testParseErr6(): void
public function testParseErr6()
{
$parser = new Parser();
Array2d::parse($parser, $this->getTokensList('(1, 2),(3)'));
$this->assertCount(1, $parser->errors);
$this->assertCount(
1,
$parser->errors
);
$this->assertEquals(
'2 values were expected, but found 1.',
$parser->errors[0]->getMessage()