11<?php
22
3- require_once __DIR__ . '/../wp-includes/sqlite-ast/class-wp-sqlite-driver.php ' ;
4- require_once __DIR__ . '/../wp-includes/sqlite-ast/class-wp-sqlite-driver-exception.php ' ;
5- require_once __DIR__ . '/../wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php ' ;
6-
73use PHPUnit \Framework \TestCase ;
84
95/**
106 * Unit tests using the WordPress table definitions.
117 */
128class WP_SQLite_Driver_Query_Tests extends TestCase {
13-
9+ /** @var WP_SQLite_Driver */
1410 private $ engine ;
15- private $ sqlite ;
1611
17- public static function setUpBeforeClass (): void {
18- // if ( ! defined( 'PDO_DEBUG' )) {
19- // define( 'PDO_DEBUG', true );
20- // }
21- if ( ! defined ( 'FQDB ' ) ) {
22- define ( 'FQDB ' , ':memory: ' );
23- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
24- }
25- error_reporting ( E_ALL & ~E_DEPRECATED );
26- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
27- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
28- }
29- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
30- $ GLOBALS ['wpdb ' ] = new stdClass ();
31- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
32- $ GLOBALS ['wpdb ' ]->show_errors = true ;
33- }
34- return ;
35- }
12+ /** @var PDO */
13+ private $ sqlite ;
3614
3715 /**
3816 * Before each test, we create a new volatile database and WordPress tables.
@@ -47,10 +25,8 @@ public function setUp(): void {
4725
4826 $ this ->sqlite = new PDO ( 'sqlite::memory: ' );
4927 $ this ->engine = new WP_SQLite_Driver (
50- array (
51- 'connection ' => $ this ->sqlite ,
52- 'database ' => 'wp ' ,
53- )
28+ new WP_SQLite_Connection ( array ( 'pdo ' => $ this ->sqlite ) ),
29+ 'wp '
5430 );
5531
5632 $ translator = $ this ->engine ;
@@ -462,7 +438,7 @@ public function testRecoverSerialized() {
462438 );
463439 $ option_name = 'serialized_option ' ;
464440 $ option_value = serialize ( $ obj );
465- $ option_value_escaped = $ this ->engine ->get_pdo ()->quote ( $ option_value );
441+ $ option_value_escaped = $ this ->engine ->get_connection ()->quote ( $ option_value );
466442 /* Note well: this is heredoc not nowdoc */
467443 $ insert = <<<QUERY
468444 INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`)
@@ -488,7 +464,7 @@ public function testRecoverSerialized() {
488464 ++$ obj ['two ' ];
489465 $ obj ['pi ' ] *= 2 ;
490466 $ option_value = serialize ( $ obj );
491- $ option_value_escaped = $ this ->engine ->get_pdo ()->quote ( $ option_value );
467+ $ option_value_escaped = $ this ->engine ->get_connection ()->quote ( $ option_value );
492468 /* Note well: this is heredoc not nowdoc */
493469 $ insert = <<<QUERY
494470 INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`)
0 commit comments