Skip to content

Commit 7942ce3

Browse files
committed
Fixed phpcs tests issues
1 parent d80d7e1 commit 7942ce3

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

tests/Parser/ParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function parseProvider()
2828
['parser/parse'],
2929
['parser/parse2'],
3030
['parser/parseDelimiter'],
31-
['parser/ansi/parseAnsi']
31+
['parser/ansi/parseAnsi'],
3232
];
3333
}
3434

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function runParserTest($name)
100100
*/
101101
$data = $this->getData($name);
102102

103-
if (strpos($name,'/ansi/') !== false) {
103+
if (strpos($name, '/ansi/') !== false) {
104104
// set mode if appropriate
105105
Context::setMode('ANSI_QUOTES');
106106
}

tools/TestGenerator.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Exception;
77
use PhpMyAdmin\SqlParser\Lexer;
88
use PhpMyAdmin\SqlParser\Parser;
9+
use PhpMyAdmin\SqlParser\Context;
910
use function count;
1011
use function file_exists;
1112
use function file_get_contents;
@@ -120,7 +121,7 @@ public static function generate($query, $type = 'parser')
120121
* @param string $output the output file
121122
* @param string $debug the debug file
122123
*/
123-
public static function build($type, $input, $output, $debug = null)
124+
public static function build($type, $input, $output, $debug = null, $ansi = false)
124125
{
125126
// Support query types: `lexer` / `parser`.
126127
if (! in_array($type, ['lexer', 'parser'])) {
@@ -139,8 +140,16 @@ public static function build($type, $input, $output, $debug = null)
139140
throw new Exception('No input query specified.');
140141
}
141142

143+
if ($ansi === true) {
144+
// set ANSI_QUOTES for ansi tests
145+
Context::setMode('ANSI_QUOTES');
146+
}
147+
142148
$test = static::generate($query, $type);
143149

150+
// unset mode, reset to default every time, to be sure
151+
Context::setMode();
152+
144153
// Writing test's data.
145154
file_put_contents($output, serialize($test));
146155

@@ -200,7 +209,8 @@ public static function buildAll($input, $output, $debug = null)
200209
strpos($inputFile, 'lex') !== false ? 'lexer' : 'parser',
201210
$inputFile,
202211
$outputFile,
203-
$debugFile
212+
$debugFile,
213+
strpos($inputFile, 'ansi') !== false
204214
);
205215
} else {
206216
sprintf("Test for %s already built!\n", $inputFile);

0 commit comments

Comments
 (0)