Skip to content

Commit 3315407

Browse files
committed
Adding tests for unquoted strings in square brackets
1 parent 3ec11ff commit 3315407

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/PHPCR/Tests/Util/QOM/Sql2ScannerTest.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function testToken()
2828
/**
2929
* @dataProvider dataTestStringTokenization
3030
*/
31-
public function testStringTokenization()
31+
public function testStringTokenization(string $query)
3232
{
33-
$scanner = new Sql2Scanner('SELECT page.* FROM [nt:unstructured] AS page WHERE name ="Hello world"');
33+
$scanner = new Sql2Scanner($query);
3434
$expected = [
3535
'SELECT',
3636
'page',
@@ -49,7 +49,7 @@ public function testStringTokenization()
4949
$this->expectTokensFromScanner($scanner, $expected);
5050
}
5151

52-
public function dataTestStringTokenization()
52+
public function dataTestStringTokenization(): array
5353
{
5454
$multilineQuery = <<<'SQL'
5555
SELECT page.*
@@ -124,7 +124,7 @@ public function testSQLEscapedStrings2()
124124
$this->expectTokensFromScanner($scanner, $expected);
125125
}
126126

127-
public function testSquareBrakets()
127+
public function testSquareBrackets()
128128
{
129129
$sql = 'WHERE ISSAMENODE(file, ["/home node"])';
130130

@@ -144,6 +144,25 @@ public function testSquareBrakets()
144144
$this->expectTokensFromScanner($scanner, $expected);
145145
}
146146

147+
public function testSquareBracketsWithoutQuotes()
148+
{
149+
$sql = 'WHERE ISSAMENODE(file, [/home node])';
150+
151+
$scanner = new Sql2Scanner($sql);
152+
$expected = [
153+
'WHERE',
154+
'ISSAMENODE',
155+
'(',
156+
'file',
157+
',',
158+
'[/home',
159+
'node]',
160+
')',
161+
];
162+
163+
$this->expectTokensFromScanner($scanner, $expected);
164+
}
165+
147166
public function testTokenizingWithMissingSpaces()
148167
{
149168
$sql = 'SELECT * AS"all"';

0 commit comments

Comments
 (0)