diff --git a/tests/phpunit/tests/dbdelta.php b/tests/phpunit/tests/dbdelta.php index 6ef3ef0f02..c4b23b0274 100644 --- a/tests/phpunit/tests/dbdelta.php +++ b/tests/phpunit/tests/dbdelta.php @@ -801,4 +801,36 @@ class Tests_dbDelta extends WP_UnitTestCase { $this->assertEmpty( $updates ); } + + /** + * @ticket 31679 + */ + function test_column_type_change_with_hyphens_in_name() { + global $wpdb; + + $schema = " + CREATE TABLE {$wpdb->prefix}dbdelta_test2 ( + `foo-bar` varchar(255) DEFAULT NULL + ) + "; + + $wpdb->query( $schema ); + + $schema_update = " + CREATE TABLE {$wpdb->prefix}dbdelta_test2 ( + `foo-bar` text DEFAULT NULL + ) + "; + + $updates = dbDelta( $schema_update ); + + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test2" ); + + $this->assertSame( + array( + "{$wpdb->prefix}dbdelta_test2.foo-bar" => "Changed type of {$wpdb->prefix}dbdelta_test2.foo-bar from varchar(255) to text", + ), + $updates + ); + } }