. */ $errorMessage = " Use new command.\n $ cd %s $ php ./devTools/core/console.php i:create-test-db \n"; die(sprintf($errorMessage, realpath(__DIR__ . '/../../'))); $rootPath = dirname(__FILE__) . "/../../"; $confPath = $rootPath . "lib/confs/Conf.php"; $pathToAutoload = realpath(__DIR__ . '/../../src/vendor/autoload.php'); require_once $confPath; require_once $pathToAutoload; $c = new Conf(); $testDb = 'test_' . $c->getDbName(); $dbUser = $c->getDbUser(); $dbHost = $c->getDbHost(); $dbPort = $c->getDbPort(); $dbName = $c->getDbName(); $tempFile = tempnam(sys_get_temp_dir(), 'ohrmtestdb'); if ($argc > 1) { $mysqlRootPwd = $argv[1]; } else { $mysqlRootPwd = ""; echo "Please enter mysql root password when prompted.\n"; } $createdbStatement = "DROP DATABASE IF EXISTS `{$testDb}`; CREATE DATABASE `{$testDb}`;USE `{$testDb}`;" ; file_put_contents($tempFile, $createdbStatement); $cmd = "mysqldump -h {$dbHost} --port={$dbPort} -u root -p{$mysqlRootPwd} --add-drop-table --routines --skip-triggers {$dbName} >> {$tempFile}"; $output = ''; $returnStatus = ''; exec($cmd, $output, $returnStatus); if ($returnStatus !== 0) { echo "mysqldump failed.
\n"; exit(1); } $cmd = "mysql -h {$dbHost} --port={$dbPort} -u root -p{$mysqlRootPwd} < {$tempFile}"; exec($cmd, $output, $returnStatus); if ($returnStatus !== 0) { echo "mysql data insert failed.
\n"; exit(2); } unlink($tempFile); echo "test db {$testDb} created.\n"; $coreFixtureService = new \OrangeHRM\Tests\Util\CoreFixtureService(); $coreFixtureService->saveToFixtures(); echo "core fixtures generated.\n";