From 9eaab508ab4cb3ebd9319c7148df2198e1348de1 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Wed, 13 Jul 2016 11:38:29 +0000 Subject: [PATCH] Database: Add unit test to test that a column type change for a table name with a hyphen is working after [37583]. Fixes #31679. git-svn-id: https://develop.svn.wordpress.org/trunk@38044 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/dbdelta.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 + ); + } }