Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 287241a

Browse files
committed
Do not pre-create WP schema for metadata tests
1 parent 4f889bf commit 287241a

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

tests/WP_SQLite_Driver_Metadata_Tests.php

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,13 @@ public static function setUpBeforeClass(): void {
3333

3434
// Before each test, we create a new database
3535
public function setUp(): void {
36-
global $blog_tables;
37-
$queries = explode( ';', $blog_tables );
38-
3936
$this->sqlite = new PDO( 'sqlite::memory:' );
4037
$this->engine = new WP_SQLite_Driver(
4138
array(
4239
'connection' => $this->sqlite,
4340
'database' => 'wp',
4441
)
4542
);
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-
}
7243
}
7344

7445
public function testCountTables() {
@@ -480,6 +451,9 @@ private function assertTableEmpty( $table_name, $empty_var ) {
480451
}
481452

482453
public function testTruncateTable() {
454+
$this->assertQuery(
455+
'CREATE TABLE wp_comments ( comment_author TEXT, comment_content TEXT )'
456+
);
483457

484458
$this->assertQuery(
485459
"INSERT INTO wp_comments ( comment_author, comment_content ) VALUES ( 'PhpUnit', 'Testing' )"

0 commit comments

Comments
 (0)