From cc7f392399e6bef8670e55668a593c42af4dc483 Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Tue, 5 Nov 2024 16:35:47 +0100 Subject: [PATCH] Run the whole MySQL server test suite in lexer tests --- tests/mysql/WP_MySQL_Lexer_Tests.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/mysql/WP_MySQL_Lexer_Tests.php b/tests/mysql/WP_MySQL_Lexer_Tests.php index b40d6c80..12ef0ed8 100644 --- a/tests/mysql/WP_MySQL_Lexer_Tests.php +++ b/tests/mysql/WP_MySQL_Lexer_Tests.php @@ -3,6 +3,28 @@ use PHPUnit\Framework\TestCase; class WP_MySQL_Lexer_Tests extends TestCase { + /** + * Tokenize the whole MySQL server test suite and make sure + * it produces some tokens and doesn't throw any exceptions. + */ + public function test_tokenize_mysql_test_suite() { + $path = __DIR__ . '/data/queries.csv'; + $handle = @fopen( $path, 'r' ); + if ( false === $handle ) { + $this->fail( "Failed to open file '$path'." ); + } + + try { + while ( ( $record = fgetcsv( $handle ) ) !== false ) { + $query = $record[0]; + $tokens = WP_MySQL_Lexer::tokenize( $query ); + $this->assertNotEmpty( $tokens ); + } + } finally { + fclose( $handle ); + } + } + /** * Numbers vs. identifiers: *