WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/13/2016 11:38:29 AM (4 years ago)
Author:
ocean90
Message:

Database: Add unit test to test that a column type change for a table name with a hyphen is working after [37583].

Fixes #31679.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dbdelta.php

    r37583 r38044  
    802802        $this->assertEmpty( $updates );
    803803    }
     804
     805    /**
     806     * @ticket 31679
     807     */
     808    function test_column_type_change_with_hyphens_in_name() {
     809        global $wpdb;
     810
     811        $schema = "
     812            CREATE TABLE {$wpdb->prefix}dbdelta_test2 (
     813                `foo-bar` varchar(255) DEFAULT NULL
     814            )
     815        ";
     816
     817        $wpdb->query( $schema );
     818
     819        $schema_update = "
     820            CREATE TABLE {$wpdb->prefix}dbdelta_test2 (
     821                `foo-bar` text DEFAULT NULL
     822            )
     823        ";
     824
     825        $updates = dbDelta( $schema_update );
     826
     827        $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test2" );
     828
     829        $this->assertSame(
     830            array(
     831                "{$wpdb->prefix}dbdelta_test2.foo-bar" => "Changed type of {$wpdb->prefix}dbdelta_test2.foo-bar from varchar(255) to text",
     832            ),
     833            $updates
     834        );
     835    }
    804836}
Note: See TracChangeset for help on using the changeset viewer.