Skip to content

Instantly share code, notes, and snippets.

@paulgibbs
Created August 9, 2016 14:20
Show Gist options
  • Save paulgibbs/fef62bd8cb6dc67dc65abdbc02b7c7ff to your computer and use it in GitHub Desktop.
Save paulgibbs/fef62bd8cb6dc67dc65abdbc02b7c7ff to your computer and use it in GitHub Desktop.
Hack wp unit tests to kind-of work with the 'sqlite-integration' plugin
Index: testcase.php
===================================================================
--- testcase.php (revision 37854)
+++ testcase.php (working copy)
@@ -138,7 +138,10 @@
*/
function tearDown() {
global $wpdb, $wp_query, $wp, $post;
- $wpdb->query( 'ROLLBACK' );
+
+ //$wpdb->query( 'ROLLBACK' );
+ exec( 'cp /srv/www/buddypress.dev/src/wp-content/database/sqlite-backup /srv/www/buddypress.dev/src/wp-content/database/.ht.sqlite' );
+
if ( is_multisite() ) {
while ( ms_is_switched() ) {
restore_current_blog();
@@ -148,8 +151,8 @@
$wp = new WP();
$post = null;
remove_theme_support( 'html5' );
- remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
- remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );
+ /*remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
+ remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );*/
remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
$this->_restore_hooks();
wp_set_current_user( 0 );
@@ -258,11 +261,12 @@
}
function start_transaction() {
- global $wpdb;
+ exec( 'cp /srv/www/buddypress.dev/src/wp-content/database/.ht.sqlite /srv/www/buddypress.dev/src/wp-content/database/sqlite-backup' );
+ /*global $wpdb;
$wpdb->query( 'SET autocommit = 0;' );
$wpdb->query( 'START TRANSACTION;' );
add_filter( 'query', array( $this, '_create_temporary_tables' ) );
- add_filter( 'query', array( $this, '_drop_temporary_tables' ) );
+ add_filter( 'query', array( $this, '_drop_temporary_tables' ) );*/
}
/**
@@ -271,8 +275,9 @@
* @since 4.1.0
*/
public static function commit_transaction() {
- global $wpdb;
- $wpdb->query( 'COMMIT;' );
+ exec( 'cp /srv/www/buddypress.dev/src/wp-content/database/.ht.sqlite /srv/www/buddypress.dev/src/wp-content/database/sqlite-backup' );
+ /*global $wpdb;
+ $wpdb->query( 'COMMIT;' );*/
}
function _create_temporary_tables( $query ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment