Skip to main content
Commonmark migration
Source Link

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

#Update:#

Update:

The _create_temporary_tables() function is now hooked to the 'query' filter, instead of 'dbdelta_create_queries'. See changeset 27041. So now to remove it you would do:

remove_filter( 'query', array( $this, '_create_temporary_tables' ) );

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

#Update:#

The _create_temporary_tables() function is now hooked to the 'query' filter, instead of 'dbdelta_create_queries'. See changeset 27041. So now to remove it you would do:

remove_filter( 'query', array( $this, '_create_temporary_tables' ) );

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

Update:

The _create_temporary_tables() function is now hooked to the 'query' filter, instead of 'dbdelta_create_queries'. See changeset 27041. So now to remove it you would do:

remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
Updating with a note about a hook change.
Source Link
J.D.
  • 3.9k
  • 17
  • 36

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

#Update:#

The _create_temporary_tables() function is now hooked to the 'query' filter, instead of 'dbdelta_create_queries'. See changeset 27041. So now to remove it you would do:

remove_filter( 'query', array( $this, '_create_temporary_tables' ) );

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

#Update:#

The _create_temporary_tables() function is now hooked to the 'query' filter, instead of 'dbdelta_create_queries'. See changeset 27041. So now to remove it you would do:

remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
The previous example was incomplete
Source Link
J.D.
  • 3.9k
  • 17
  • 36

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this line before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this line before your DROP queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries:

remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );

You may also need to add this before your CREATE TABLE queries:

remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );

The WP_UnitTestCase::_create_temporary_tables() function is the one that filters the queries to make tables temporary. It is added in the setUp(), and removed in the tearDown().

Source Link
J.D.
  • 3.9k
  • 17
  • 36
Loading