Make WordPress Core

Changeset 37654


Ignore:
Timestamp:
06/08/2016 03:03:16 AM (8 years ago)
Author:
pento
Message:

Tests: Disable foreign_key_checks while dropping existing tables.

To ensure a clean run, the test suite drops all tables before installing, by simply looping over the table list and dropping them if they exist. This works well for Core, but may fail when a plugin has created a table with foreign key constraints in a previous test run.

Many plugins choose to base their test suite on the Core setup, so making life easier for them is a plus, even if Core doesn't directly need this change.

Props javorszky.

Fixes #37046.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/install.php

    r36721 r37654  
    4141echo "Installing..." . PHP_EOL;
    4242
     43$wpdb->query( "SET foreign_key_checks = 0" );
    4344foreach ( $wpdb->tables() as $table => $prefixed_table ) {
    4445    $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
     
    5253        $wpdb->$table = $prefixed_table;
    5354}
     55$wpdb->query( "SET foreign_key_checks = 1" );
    5456
    5557// Prefill a permalink structure so that WP doesn't try to determine one itself.
Note: See TracChangeset for help on using the changeset viewer.