* Update sqlparser to fit php8.
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\SqlParser\Tests\Lexer;
|
||||
|
||||
use PhpMyAdmin\SqlParser\Exceptions\LexerException;
|
||||
use PhpMyAdmin\SqlParser\Lexer;
|
||||
use PhpMyAdmin\SqlParser\Tests\TestCase;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class LexerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testError()
|
||||
public function testError(): void
|
||||
{
|
||||
$lexer = new Lexer('');
|
||||
|
||||
@@ -26,20 +30,18 @@ class LexerTest extends TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
$lexer->errors,
|
||||
array(
|
||||
[
|
||||
new LexerException('error #1', 'foo', 1, 2),
|
||||
new LexerException('error #2', 'bar', 3, 4),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpMyAdmin\SqlParser\Exceptions\LexerException
|
||||
* @expectedExceptionMessage strict error
|
||||
* @expectedExceptionCode 4
|
||||
*/
|
||||
public function testErrorStrict()
|
||||
public function testErrorStrict(): void
|
||||
{
|
||||
$this->expectExceptionCode(4);
|
||||
$this->expectExceptionMessage('strict error');
|
||||
$this->expectException(LexerException::class);
|
||||
$lexer = new Lexer('');
|
||||
$lexer->strict = true;
|
||||
|
||||
@@ -48,46 +50,51 @@ class LexerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider lexProvider
|
||||
*
|
||||
* @param mixed $test
|
||||
*/
|
||||
public function testLex($test)
|
||||
public function testLex(string $test): void
|
||||
{
|
||||
$this->runParserTest($test);
|
||||
}
|
||||
|
||||
public function lexProvider()
|
||||
/**
|
||||
* @return string[][]
|
||||
*/
|
||||
public function lexProvider(): array
|
||||
{
|
||||
return array(
|
||||
array('lexer/lex'),
|
||||
array('lexer/lexUtf8'),
|
||||
array('lexer/lexBool'),
|
||||
array('lexer/lexComment'),
|
||||
array('lexer/lexCommentEnd'),
|
||||
array('lexer/lexDelimiter'),
|
||||
array('lexer/lexDelimiter2'),
|
||||
array('lexer/lexDelimiterErr1'),
|
||||
array('lexer/lexDelimiterErr2'),
|
||||
array('lexer/lexDelimiterErr3'),
|
||||
array('lexer/lexDelimiterLen'),
|
||||
array('lexer/lexKeyword'),
|
||||
array('lexer/lexKeyword2'),
|
||||
array('lexer/lexNumber'),
|
||||
array('lexer/lexOperator'),
|
||||
array('lexer/lexOperatorStarIsArithmetic'),
|
||||
array('lexer/lexOperatorStarIsWildcard'),
|
||||
array('lexer/lexString'),
|
||||
array('lexer/lexStringErr1'),
|
||||
array('lexer/lexSymbol'),
|
||||
array('lexer/lexSymbolErr1'),
|
||||
array('lexer/lexSymbolErr2'),
|
||||
array('lexer/lexSymbolErr3'),
|
||||
array('lexer/lexSymbolUser'),
|
||||
array('lexer/lexWhitespace'),
|
||||
array('lexer/lexLabel1'),
|
||||
array('lexer/lexLabel2'),
|
||||
array('lexer/lexNoLabel'),
|
||||
array('lexer/lexWildcardThenComment')
|
||||
);
|
||||
return [
|
||||
['lexer/lex'],
|
||||
['lexer/lexUtf8'],
|
||||
['lexer/lexBool'],
|
||||
['lexer/lexComment'],
|
||||
['lexer/lexCommentEnd'],
|
||||
['lexer/lexDelimiter'],
|
||||
['lexer/lexDelimiter2'],
|
||||
['lexer/lexDelimiterErr1'],
|
||||
['lexer/lexDelimiterErr2'],
|
||||
['lexer/lexDelimiterErr3'],
|
||||
['lexer/lexDelimiterLen'],
|
||||
['lexer/lexKeyword'],
|
||||
['lexer/lexKeyword2'],
|
||||
['lexer/lexNumber'],
|
||||
['lexer/lexOperator'],
|
||||
['lexer/lexOperatorStarIsArithmetic'],
|
||||
['lexer/lexOperatorStarIsWildcard'],
|
||||
['lexer/lexString'],
|
||||
['lexer/lexStringErr1'],
|
||||
['lexer/lexSymbol'],
|
||||
['lexer/lexSymbolErr1'],
|
||||
['lexer/lexSymbolErr2'],
|
||||
['lexer/lexSymbolErr3'],
|
||||
['lexer/lexSymbolUser1'],
|
||||
['lexer/lexSymbolUser2'],
|
||||
['lexer/lexSymbolUser3'],
|
||||
['lexer/lexSymbolUser4_mariadb_100400'],
|
||||
['lexer/lexSymbolUser5_mariadb_100400'],
|
||||
['lexer/lexWhitespace'],
|
||||
['lexer/lexLabel1'],
|
||||
['lexer/lexLabel2'],
|
||||
['lexer/lexNoLabel'],
|
||||
['lexer/lexWildcardThenComment'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user