Skip to content

Commit 6d09118

Browse files
committed
Add a MySQL-judged REGEXP test suite
Check the REGEXP functions against what MySQL 8.4 returns. A case is a pattern, a subject, and a match type, where a null match type runs without the argument. Each function has a test class that runs its checks through the driver: REGEXP_LIKE(), REGEXP_INSTR() for the start and end of the first match, REGEXP_SUBSTR(), and REGEXP_REPLACE() with a template that shows every match and capture group. The cases take the patterns of REGEXP, RLIKE, and REGEXP_*() from the MySQL server test suite, with their own subjects and a fixed set of varied subjects. Each class lists the cases that are expected to fail, where any of its checks fails, and its test fails when they differ. Cases that fail only with some PHP or PCRE versions are listed under version checks, with the cause of each. The tests of REGEXP_INSTR(), REGEXP_SUBSTR(), and REGEXP_REPLACE() are skipped until these functions exist. "tests/tools/generate-regexp-test-data.php" rebuilds the data from a MySQL server.
1 parent 15f3130 commit 6d09118

7 files changed

Lines changed: 13749 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require_once __DIR__ . '/WP_MySQL_On_SQLite_Regexp_Test_Case.php';
4+
5+
/**
6+
* Check REGEXP_INSTR() against MySQL's results for the REGEXP test cases.
7+
*/
8+
class WP_MySQL_On_SQLite_Regexp_Instr_Tests extends WP_MySQL_On_SQLite_Regexp_Test_Case {
9+
const CHECKS = array( 'regexp_instr', 'regexp_instr_end' );
10+
11+
protected function setUp(): void {
12+
$this->markTestSkipped( 'REGEXP_INSTR() is not supported yet.' );
13+
}
14+
}

0 commit comments

Comments
 (0)