Skip to content

Commit 4074c52

Browse files
authored
Merge pull request #29 from Automattic/strict-sql-mode
Respect strict/non-strict MySQL modes
2 parents c9b443b + 69493b1 commit 4074c52

7 files changed

+1014
-55
lines changed

.github/workflows/wp-tests-phpunit-run.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@ const fs = require( 'fs' );
1111
const path = require( 'path' );
1212

1313
const expectedErrors = [
14-
'Tests_Comment_WpComment::test_get_instance_should_succeed_for_float_that_is_equal_to_post_id',
15-
'Tests_Cron_getCronArray::test_get_cron_array_output_validation with data set "null"',
1614
'Tests_DB_Charset::test_strip_invalid_text',
1715
'Tests_DB::test_db_reconnect',
1816
'Tests_DB::test_get_col_info',
1917
'Tests_DB::test_process_fields_value_too_long_for_field with data set "invalid chars"',
2018
'Tests_DB::test_process_fields_value_too_long_for_field with data set "too long"',
2119
'Tests_DB::test_process_fields',
22-
'Tests_DB::test_set_allowed_incompatible_sql_mode',
23-
'Tests_DB::test_set_incompatible_sql_mode',
24-
'Tests_DB::test_set_sql_mode',
25-
'Tests_Post_wpPost::test_get_instance_should_succeed_for_float_that_is_equal_to_post_id',
26-
'Tests_Post::test_stick_post_with_unexpected_sticky_posts_option with data set "null"',
2720
];
2821

2922
const expectedFailures = [

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)