1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00
joplin/tests/setup.php

34 lines
1.0 KiB
PHP
Raw Normal View History

2016-10-19 17:54:41 +02:00
<?php
require_once dirname(__FILE__) . '/BaseTestCase.php';
2016-12-27 22:25:07 +02:00
$dbConfig = array(
'dbName' => 'notes_test',
'user' => 'root',
'password' => '',
'host' => '127.0.0.1',
);
2016-10-19 17:54:41 +02:00
$structureFile = dirname(dirname(__FILE__)) . '/structure.sql';
2016-12-27 22:25:07 +02:00
$cmd = sprintf("mysql -u %s %s -h %s -e 'DROP DATABASE IF EXISTS %s; CREATE DATABASE %s;'", $dbConfig['user'], empty($dbConfig['password']) ? '' : '-p' . $dbConfig['password'], $dbConfig['host'], $dbConfig['dbName'], $dbConfig['dbName']);
2016-10-19 17:54:41 +02:00
exec($cmd);
2016-12-27 22:25:07 +02:00
$cmd = sprintf("mysql -u %s %s -h %s %s < '%s'", $dbConfig['user'], empty($dbConfig['password']) ? '' : '-p' . $dbConfig['password'], $dbConfig['host'], $dbConfig['dbName'], $structureFile);
2016-10-19 17:54:41 +02:00
exec($cmd);
$capsule = new \Illuminate\Database\Capsule\Manager();
$capsule->addConnection([
'driver' => 'mysql',
2016-12-27 22:25:07 +02:00
'host' => $dbConfig['host'],
'database' => $dbConfig['dbName'],
'username' => $dbConfig['user'],
'password' => $dbConfig['password'],
2016-10-19 17:54:41 +02:00
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
$capsule->bootEloquent();