@@ -33,42 +33,13 @@ public static function setUpBeforeClass(): void {
33
33
34
34
// Before each test, we create a new database
35
35
public function setUp (): void {
36
- global $ blog_tables ;
37
- $ queries = explode ( '; ' , $ blog_tables );
38
-
39
36
$ this ->sqlite = new PDO ( 'sqlite::memory: ' );
40
37
$ this ->engine = new WP_SQLite_Driver (
41
38
array (
42
39
'connection ' => $ this ->sqlite ,
43
40
'database ' => 'wp ' ,
44
41
)
45
42
);
46
-
47
- $ translator = $ this ->engine ;
48
-
49
- try {
50
- $ translator ->begin_transaction ();
51
- foreach ( $ queries as $ query ) {
52
- $ query = trim ( $ query );
53
- if ( empty ( $ query ) ) {
54
- continue ;
55
- }
56
-
57
- $ translator ->execute_sqlite_query ( $ query );
58
- }
59
- $ translator ->commit ();
60
- } catch ( PDOException $ err ) {
61
- $ err_data =
62
- $ err ->errorInfo ; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
63
- $ err_code = $ err_data [1 ];
64
- $ translator ->rollback ();
65
- $ message = sprintf (
66
- 'Error occurred while creating tables or indexes...<br />Query was: %s<br /> ' ,
67
- var_export ( $ query , true )
68
- );
69
- $ message .= sprintf ( 'Error message is: %s ' , $ err_data [2 ] );
70
- wp_die ( $ message , 'Database Error! ' );
71
- }
72
43
}
73
44
74
45
public function testCountTables () {
@@ -480,6 +451,9 @@ private function assertTableEmpty( $table_name, $empty_var ) {
480
451
}
481
452
482
453
public function testTruncateTable () {
454
+ $ this ->assertQuery (
455
+ 'CREATE TABLE wp_comments ( comment_author TEXT, comment_content TEXT ) '
456
+ );
483
457
484
458
$ this ->assertQuery (
485
459
"INSERT INTO wp_comments ( comment_author, comment_content ) VALUES ( 'PhpUnit', 'Testing' ) "
0 commit comments