New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MySQL Sandbox to default install #835

Closed
pento opened this Issue Feb 22, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@pento

pento commented Feb 22, 2016

MySQL Sandbox is a super useful tool for rapidly installing and configuring different versions of MySQL, to test against.

Also, I'm not sure if this could be turned into a more general solution, but my wp-tests-config.php includes this chunk, for quickly switching between DB versions:

$current_db = '5.6.17';

if ( $current_db ) {
    define( 'DB_USER', 'msandbox' );
    define( 'DB_PASSWORD', 'msandbox' );

    exec( '~/sandboxes/msb_' . str_replace( '.', '_', $current_db ) . '/start' );
    if ( false === strpos( $GLOBALS['argv'][0], 'install.php' ) ) {
        register_shutdown_function( 'exec', '~/sandboxes/msb_' . str_replace( '.', '_', $current_db ) . '/stop' );
    }
} else {
    define( 'DB_USER', 'wp' );
    define( 'DB_PASSWORD', 'wp' );
}

switch( $current_db ) {
    case '5.0.88':
        define( 'DB_HOST', '127.0.0.1:5088' );
        break;

    case '5.0.96':
        define( 'DB_HOST', '127.0.0.1:5096' );
        break;

    case '5.6.17':
        define( 'DB_HOST', '127.0.0.1:5617' );
        break;

    default:
        define( 'DB_HOST', 'localhost' );
        break;
}

define( 'DB_NAME', 'wordpress_unit_tests' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );

@jeremyfelt jeremyfelt added the feature label Feb 26, 2016

@jeremyfelt

This comment has been minimized.

Member

jeremyfelt commented Feb 26, 2016

Big +1 for this.

@pento

This comment has been minimized.

pento commented Feb 29, 2016

I just realised I could make that switching code a bunch simpler:

$current_db = '5.6.17';

if ( $current_db ) {
    define( 'DB_USER', 'msandbox' );
    define( 'DB_PASSWORD', 'msandbox' );
    define( 'DB_HOST', '127.0.0.1:' . str_replace( '.', '', $current_db ) );

    exec( '~/sandboxes/msb_' . str_replace( '.', '_', $current_db ) . '/start' );
    if ( false === strpos( $GLOBALS['argv'][0], 'install.php' ) ) {
        register_shutdown_function( 'exec', '~/sandboxes/msb_' . str_replace( '.', '_', $current_db ) . '/stop' );
    }
} else {
    define( 'DB_USER', 'wp' );
    define( 'DB_PASSWORD', 'wp' );
    define( 'DB_HOST', 'localhost' );
}

define( 'DB_NAME', 'wordpress_unit_tests' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );

It needs some sanity checking to make sure the version exists.

@jeremyfelt

This comment has been minimized.

Member

jeremyfelt commented Dec 13, 2016

The default DB config provided by VVV should be MariaDB 10.0 (see #876). We should also provide a config for MySQL Sandbox as part of vvv-utilities to make bouncing around and testing easier.

@tomjn

This comment has been minimized.

Member

tomjn commented Nov 4, 2017

This would be useful, but as it hasn't been touched in a year and we now have the VVV Utilities system, there's no reason it couldn't be added that way so I'm closing this out

@tomjn tomjn closed this Nov 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment