Exemplo n.º 1
0
require_once dirname(__FILE__) . '/../bootstrap/unit.php';
if (!checkMysql()) {
    return true;
}
$t = new lime_test(3);
$t->comment('Mysql Drop Command');
// Setup
createAdminUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsername, $tempAdminPassword);
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
$t->comment('MysqlDropCommand executed by admin user with password');
$cmd = new nbMysqlDropCommand();
$commandLine = sprintf('%s %s %s', $dbName, $tempAdminUsername, $tempAdminPassword);
$t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'MysqlDrop executed successfully');
//TearDown
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsername);
// Setup
createAdminUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsernameWithNoPassword);
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
$t->comment('MysqlDropCommand executed by admin user without password');
$cmd = new nbMysqlDropCommand();
$commandLine = sprintf('%s %s', $dbName, $tempAdminUsernameWithNoPassword);
$t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'MysqlDrop executed successfully');
//TearDown
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $tempAdminUsernameWithNoPassword);
// Setup
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
$cmd = new nbMysqlDropCommand();
$parser = new nbCommandLineParser();
$parser->setDefaultConfigurationDirs(dirname(__FILE__) . '/../data/config');
$commandLine = '--config-file=mysql-plugin.yml';
$t->ok($cmd->run($parser, $commandLine), 'MysqlDrop executed successfully from config file');
Exemplo n.º 2
0
$fs->delete($dumpFile);
dropDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $username);
// Setup
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
createDatabaseUserWithGrantsOnDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName, $username);
$cmd = new nbMysqlDumpCommand();
$commandLine = sprintf('%s %s %s', $dbName, $dumpPath, $username);
$t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'MysqlDump executed successfully');
$timestamp = date('YmdHi', time());
$dumpFile = sprintf('%s/%s/%s-%s.sql', getcwd(), $dumpPath, $dbName, $timestamp);
$t->ok(file_exists($dumpFile), 'Dump file exists');
// Tear Down
$fs->delete($dumpFile);
dropDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $username);
// Setup
createDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
createDatabaseUserWithGrantsOnDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName, $username, $password);
$parser = new nbCommandLineParser();
$parser->setDefaultConfigurationDirs(dirname(__FILE__) . '/../data/config');
$commandLine = '--config-file=mysql-plugin.yml';
$t->ok($cmd->run($parser, $commandLine), 'MysqlDump executed successfully from config file');
$timestamp = date('YmdHi', time());
$dumpFile = sprintf('%s/%s/%s-%s.sql', getcwd(), $dumpPath, $dbName, $timestamp);
$t->ok(file_exists($dumpFile), 'Dump file exists');
// Tear down
$fs->delete($dumpFile);
dropDb($mysqlAdminUsername, $mysqlAdminPassword, $dbName);
dropDatabaseUser($mysqlAdminUsername, $mysqlAdminPassword, $username);