Skip to content
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 · 5 comments
Closed

Add MySQL Sandbox to default install #835

pento opened this issue Feb 22, 2016 · 5 comments

Comments

@pento
Copy link

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
Copy link
Member

Big +1 for this.

@pento
Copy link
Author

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
Copy link
Member

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
Copy link
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 as completed Nov 4, 2017
@lock
Copy link

lock bot commented Feb 22, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants