Skip to content

Commit e28cda5

Browse files
committed
Prepare test fixtures for SQLite 3.0
Populate the wp_posts columns required by the 3.0 schema. Create export fixtures through the import command so the driver's table metadata stays synchronized.
1 parent 9e74cfe commit e28cda5

1 file changed

Lines changed: 29 additions & 22 deletions

File tree

‎features/bootstrap/SQLiteFeatureContext.php‎

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ public function theSqliteDatabaseContainsSomeSampleData() {
107107
$this->connectToDatabase();
108108
$this->db->exec(
109109
"
110-
INSERT OR REPLACE INTO wp_posts (ID, post_title, post_content, post_type, post_status)
111-
VALUES (1, 'Sample Post', 'This is a sample post content.', 'post', 'publish');
110+
INSERT OR REPLACE INTO wp_posts (
111+
ID, post_title, post_content, post_excerpt, to_ping, pinged,
112+
post_content_filtered, post_type, post_status
113+
)
114+
VALUES (
115+
1, 'Sample Post', 'This is a sample post content.', '', '', '', '', 'post', 'publish'
116+
);
112117
"
113118
);
114119

@@ -274,36 +279,38 @@ public function theSqlStringEscapeBytesShouldBePreserved() {
274279
* @Given /^the SQLite database contains a test table with alphanumeric string hash values$/
275280
*/
276281
public function theSqliteDatabaseContainsATestTableWithAlphanumericStringHashValues() {
277-
$this->connectToDatabase();
278-
279-
// Create a test table with hash values that look like scientific notation
280-
$this->db->exec( 'DROP TABLE IF EXISTS test_export_alphanumeric_string' );
281-
$this->db->exec(
282-
'
282+
$this->create_file(
283+
'test_export_alphanumeric_string_setup.sql',
284+
"
285+
DROP TABLE IF EXISTS test_export_alphanumeric_string;
283286
CREATE TABLE test_export_alphanumeric_string (
284287
id INTEGER PRIMARY KEY,
285288
hash_value TEXT
286-
)
287-
'
288-
);
289-
290-
// Insert test data with values that might be mistaken for scientific notation
291-
$this->db->exec(
289+
);
290+
INSERT INTO test_export_alphanumeric_string (id, hash_value) VALUES (1, '123e99');
292291
"
293-
INSERT INTO test_export_alphanumeric_string (id, hash_value) VALUES
294-
(1, '123e99')
295-
"
292+
);
293+
$this->wpcli_tests_invoke_proc(
294+
$this->proc( 'wp sqlite import test_export_alphanumeric_string_setup.sql' ),
295+
'run'
296296
);
297297
}
298298

299299
/**
300300
* @Given /^the SQLite database contains a table with a backtick in its name$/
301301
*/
302302
public function theSqliteDatabaseContainsATableWithABacktickInItsName() {
303-
$this->connectToDatabase();
304-
305-
$this->db->exec( 'DROP TABLE IF EXISTS `test``table`' );
306-
$this->db->exec( 'CREATE TABLE `test``table` (id INTEGER PRIMARY KEY, value TEXT)' );
307-
$this->db->exec( "INSERT INTO `test``table` (id, value) VALUES (1, 'Test value')" );
303+
$this->create_file(
304+
'test_export_identifier_setup.sql',
305+
"
306+
DROP TABLE IF EXISTS `test``table`;
307+
CREATE TABLE `test``table` (id INTEGER PRIMARY KEY, value TEXT);
308+
INSERT INTO `test``table` (id, value) VALUES (1, 'Test value');
309+
"
310+
);
311+
$this->wpcli_tests_invoke_proc(
312+
$this->proc( 'wp sqlite import test_export_identifier_setup.sql' ),
313+
'run'
314+
);
308315
}
309316
}

0 commit comments

Comments
 (0)