[wp-trac] [WordPress Trac] #37046: Unit test initial setup fails if plugins added tables with foreign key constraints
WordPress Trac
noreply at wordpress.org
Tue Jun 7 18:07:42 UTC 2016
#37046: Unit test initial setup fails if plugins added tables with foreign key
constraints
------------------------------+-----------------------------
Reporter: javorszky | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Build/Test Tools | Version: trunk
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
When setting up a new test run, the script would drop all tables and
recreate them from scratch. See here:
https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/install.php?marks=43-45#L43
Relevant code copied:
{{{
foreach ( $wpdb->tables() as $table => $prefixed_table ) {
$wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
}
}}}
If there's a foreign key constraint on a table that has not been dropped
yet that references one that's being dropped, MySQL (and MariaDB) will
return an error about the foreign key constraint failing, and won't
actually drop the table.
This can lead to dirty state for the next test.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37046>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list