Make WordPress Core

Ticket #41716: 41716.2.diff

File 41716.2.diff, 1.3 KB (added by danielbachhuber, 7 years ago)
  • tests/phpunit/tests/dbdelta.php

    diff --git a/tests/phpunit/tests/dbdelta.php b/tests/phpunit/tests/dbdelta.php
    index ecf7c8a294..9bdf89472b 100644
    a b class Tests_dbDelta extends WP_UnitTestCase { 
    361361                        $this->markTestSkipped( 'This test requires utf8mb4 support in MySQL.' );
    362362                }
    363363
    364                 $table_name = 'test_truncated_index';
     364                // This table needs to be actually created
     365                remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
     366                remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );
     367
     368                $table_name = "{$wpdb->prefix}test_truncated_index";
    365369
    366                 $create = "CREATE TABLE $table_name (\n a varchar(255) COLLATE utf8mb4_unicode_ci,\n KEY a (a)\n)";
     370                $create = "
     371                        CREATE TABLE $table_name (
     372                                a varchar(255) COLLATE utf8mb4_unicode_ci,
     373                                KEY a_key (a)
     374                        ) ENGINE=InnoDB ROW_FORMAT=COMPACT";
     375
     376                $suppress_errors = $wpdb->suppress_errors();
    367377                $wpdb->query( $create );
     378                $wpdb->suppress_errors( $suppress_errors );
     379                $tables = $wpdb->get_results( "SHOW TABLES LIKE '{$table_name}'" );
     380                if ( empty( $tables ) ) {
     381                        $this->markTestSkipped( 'This test expects table to be created, but index silently truncated.' );
     382                }
    368383
    369384                $actual = dbDelta( $create, false );
    370385
     386                $wpdb->query( "DROP TABLE IF EXISTS $table_name;" );
     387
    371388                $this->assertSame( array(), $actual );
    372389        }
    373390