File tree 8 files changed +29
-140
lines changed
8 files changed +29
-140
lines changed Original file line number Diff line number Diff line change 3
3
use PHPUnit \Framework \TestCase ;
4
4
5
5
class WP_SQLite_Driver_Metadata_Tests extends TestCase {
6
-
6
+ /** @var WP_SQLite_Driver */
7
7
private $ engine ;
8
- private $ sqlite ;
9
8
10
- public static function setUpBeforeClass (): void {
11
- // if ( ! defined( 'PDO_DEBUG' )) {
12
- // define( 'PDO_DEBUG', true );
13
- // }
14
- if ( ! defined ( 'FQDB ' ) ) {
15
- define ( 'FQDB ' , ':memory: ' );
16
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
17
- }
18
- error_reporting ( E_ALL & ~E_DEPRECATED );
19
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
20
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
21
- }
22
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
23
- $ GLOBALS ['wpdb ' ] = new stdClass ();
24
- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
25
- $ GLOBALS ['wpdb ' ]->show_errors = true ;
26
- }
27
- return ;
28
- }
9
+ /** @var PDO */
10
+ private $ sqlite ;
29
11
30
12
// Before each test, we create a new database
31
13
public function setUp (): void {
Original file line number Diff line number Diff line change 6
6
* Unit tests using the WordPress table definitions.
7
7
*/
8
8
class WP_SQLite_Driver_Query_Tests extends TestCase {
9
-
9
+ /** @var WP_SQLite_Driver */
10
10
private $ engine ;
11
- private $ sqlite ;
12
11
13
- public static function setUpBeforeClass (): void {
14
- // if ( ! defined( 'PDO_DEBUG' )) {
15
- // define( 'PDO_DEBUG', true );
16
- // }
17
- if ( ! defined ( 'FQDB ' ) ) {
18
- define ( 'FQDB ' , ':memory: ' );
19
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
20
- }
21
- error_reporting ( E_ALL & ~E_DEPRECATED );
22
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
23
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
24
- }
25
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
26
- $ GLOBALS ['wpdb ' ] = new stdClass ();
27
- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
28
- $ GLOBALS ['wpdb ' ]->show_errors = true ;
29
- }
30
- return ;
31
- }
12
+ /** @var PDO */
13
+ private $ sqlite ;
32
14
33
15
/**
34
16
* Before each test, we create a new volatile database and WordPress tables.
Original file line number Diff line number Diff line change 3
3
use PHPUnit \Framework \TestCase ;
4
4
5
5
class WP_SQLite_Driver_Tests extends TestCase {
6
-
6
+ /** @var WP_SQLite_Driver */
7
7
private $ engine ;
8
- private $ sqlite ;
9
8
10
- public static function setUpBeforeClass (): void {
11
- // if ( ! defined( 'PDO_DEBUG' )) {
12
- // define( 'PDO_DEBUG', true );
13
- // }
14
- if ( ! defined ( 'FQDB ' ) ) {
15
- define ( 'FQDB ' , ':memory: ' );
16
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
17
- }
18
- error_reporting ( E_ALL & ~E_DEPRECATED );
19
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
20
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
21
- }
22
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
23
- $ GLOBALS ['wpdb ' ] = new stdClass ();
24
- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
25
- $ GLOBALS ['wpdb ' ]->show_errors = true ;
26
- }
27
- return ;
28
- }
9
+ /** @var PDO */
10
+ private $ sqlite ;
29
11
30
12
// Before each test, we create a new database
31
13
public function setUp (): void {
Original file line number Diff line number Diff line change @@ -21,20 +21,6 @@ class WP_SQLite_Information_Schema_Reconstructor_Tests extends TestCase {
21
21
private $ sqlite ;
22
22
23
23
public static function setUpBeforeClass (): void {
24
- if ( ! defined ( 'FQDB ' ) ) {
25
- define ( 'FQDB ' , ':memory: ' );
26
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
27
- }
28
- error_reporting ( E_ALL & ~E_DEPRECATED );
29
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
30
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
31
- }
32
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
33
- $ GLOBALS ['wpdb ' ] = new class () {
34
- public function set_prefix ( string $ prefix ): void {}
35
- };
36
- }
37
-
38
24
// Mock symbols that are used for WordPress table reconstruction.
39
25
if ( ! defined ( 'ABSPATH ' ) ) {
40
26
define ( 'ABSPATH ' , __DIR__ );
Original file line number Diff line number Diff line change 3
3
use PHPUnit \Framework \TestCase ;
4
4
5
5
class WP_SQLite_Metadata_Tests extends TestCase {
6
-
6
+ /** @var WP_SQLite_Translator */
7
7
private $ engine ;
8
- private $ sqlite ;
9
8
10
- public static function setUpBeforeClass (): void {
11
- // if ( ! defined( 'PDO_DEBUG' )) {
12
- // define( 'PDO_DEBUG', true );
13
- // }
14
- if ( ! defined ( 'FQDB ' ) ) {
15
- define ( 'FQDB ' , ':memory: ' );
16
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
17
- }
18
- error_reporting ( E_ALL & ~E_DEPRECATED );
19
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
20
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
21
- }
22
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
23
- $ GLOBALS ['wpdb ' ] = new stdClass ();
24
- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
25
- $ GLOBALS ['wpdb ' ]->show_errors = true ;
26
- }
27
- return ;
28
- }
9
+ /** @var PDO */
10
+ private $ sqlite ;
29
11
30
12
// Before each test, we create a new database
31
13
public function setUp (): void {
Original file line number Diff line number Diff line change 6
6
* Unit tests using the WordPress table definitions.
7
7
*/
8
8
class WP_SQLite_Query_Tests extends TestCase {
9
-
9
+ /** @var WP_SQLite_Translator */
10
10
private $ engine ;
11
- private $ sqlite ;
12
11
13
- public static function setUpBeforeClass (): void {
14
- // if ( ! defined( 'PDO_DEBUG' )) {
15
- // define( 'PDO_DEBUG', true );
16
- // }
17
- if ( ! defined ( 'FQDB ' ) ) {
18
- define ( 'FQDB ' , ':memory: ' );
19
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
20
- }
21
- error_reporting ( E_ALL & ~E_DEPRECATED );
22
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
23
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
24
- }
25
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
26
- $ GLOBALS ['wpdb ' ] = new stdClass ();
27
- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
28
- $ GLOBALS ['wpdb ' ]->show_errors = true ;
29
- }
30
- return ;
31
- }
12
+ /** @var PDO */
13
+ private $ sqlite ;
32
14
33
15
/**
34
16
* Before each test, we create a new volatile database and WordPress tables.
Original file line number Diff line number Diff line change 3
3
use PHPUnit \Framework \TestCase ;
4
4
5
5
class WP_SQLite_Translator_Tests extends TestCase {
6
-
6
+ /** @var WP_SQLite_Translator */
7
7
private $ engine ;
8
- private $ sqlite ;
9
8
10
- public static function setUpBeforeClass (): void {
11
- // if ( ! defined( 'PDO_DEBUG' )) {
12
- // define( 'PDO_DEBUG', true );
13
- // }
14
- if ( ! defined ( 'FQDB ' ) ) {
15
- define ( 'FQDB ' , ':memory: ' );
16
- define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
17
- }
18
- error_reporting ( E_ALL & ~E_DEPRECATED );
19
- if ( ! isset ( $ GLOBALS ['table_prefix ' ] ) ) {
20
- $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
21
- }
22
- if ( ! isset ( $ GLOBALS ['wpdb ' ] ) ) {
23
- $ GLOBALS ['wpdb ' ] = new stdClass ();
24
- $ GLOBALS ['wpdb ' ]->suppress_errors = false ;
25
- $ GLOBALS ['wpdb ' ]->show_errors = true ;
26
- }
27
- return ;
28
- }
9
+ /** @var PDO */
10
+ private $ sqlite ;
29
11
30
12
// Before each test, we create a new database
31
13
public function setUp (): void {
Original file line number Diff line number Diff line change 21
21
require_once __DIR__ . '/../wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php ' ;
22
22
require_once __DIR__ . '/../wp-includes/sqlite-ast/class-wp-sqlite-information-schema-reconstructor.php ' ;
23
23
24
+ // Configure the test environment.
25
+ error_reporting ( E_ALL & ~E_DEPRECATED );
26
+ define ( 'FQDB ' , ':memory: ' );
27
+ define ( 'FQDBDIR ' , __DIR__ . '/../testdb ' );
28
+
29
+ // Polyfill WPDB globals.
30
+ $ GLOBALS ['table_prefix ' ] = 'wptests_ ' ;
31
+ $ GLOBALS ['wpdb ' ] = new class () {
32
+ public function set_prefix ( string $ prefix ): void {}
33
+ };
34
+
24
35
/**
25
36
* Polyfills for WordPress functions
26
37
*/
You can’t perform that action at this time.
0 commit comments