Skip to content

Commit 3f2ffea

Browse files
committed
Save constant database name in information schema
1 parent b489eb7 commit 3f2ffea

5 files changed

Lines changed: 492 additions & 517 deletions

tests/WP_SQLite_Driver_Tests.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5998,42 +5998,6 @@ public function testDatabaseNameEmpty(): void {
59985998
new WP_SQLite_Driver( $connection, '' );
59995999
}
60006000

6001-
public function testDatabaseNameMismatch(): void {
6002-
$pdo = new PDO( 'sqlite::memory:' );
6003-
$connection = new WP_SQLite_Connection( array( 'pdo' => $pdo ) );
6004-
6005-
// Create a driver with database name 'db-one'.
6006-
new WP_SQLite_Driver( $connection, 'db-one' );
6007-
6008-
// Create another driver with the same name - no errors.
6009-
new WP_SQLite_Driver( $connection, 'db-one' );
6010-
6011-
// Create a driver with a different name - failure.
6012-
$this->expectException( WP_SQLite_Driver_Exception::class );
6013-
$this->expectExceptionMessage( "Incorrect database name. The database was created with name 'db-one', but 'db-two' is used in the current session." );
6014-
new WP_SQLite_Driver( $connection, 'db-two' );
6015-
}
6016-
6017-
public function testDatabaseNameMismatchWithExistingInformationSchemaTableData(): void {
6018-
$pdo = new PDO( 'sqlite::memory:' );
6019-
$connection = new WP_SQLite_Connection( array( 'pdo' => $pdo ) );
6020-
6021-
// Create a driver with database name 'db-one'.
6022-
$driver = new WP_SQLite_Driver( $connection, 'db-one' );
6023-
6024-
// Create a table so that there is a record in the information schema.
6025-
$driver->query( 'CREATE TABLE t (id INT)' );
6026-
6027-
// Delete all variables, including driver version and database name.
6028-
$pdo->exec( sprintf( 'DELETE FROM %s', WP_SQLite_Driver::GLOBAL_VARIABLES_TABLE_NAME ) );
6029-
6030-
// Create a driver with a different name - failure.
6031-
// An information schema record with a different database name already exists.
6032-
$this->expectException( WP_SQLite_Driver_Exception::class );
6033-
$this->expectExceptionMessage( "Incorrect database name. The database was created with name 'db-one', but 'db-two' is used in the current session." );
6034-
new WP_SQLite_Driver( $connection, 'db-two' );
6035-
}
6036-
60376001
public function testSelectColumnNames(): void {
60386002
$this->assertQuery( 'CREATE TABLE t (id INT, name VARCHAR(255))' );
60396003
$this->assertQuery( 'INSERT INTO t (id, name) VALUES (1, "John"), (2, "Jane")' );

0 commit comments

Comments
 (0)