mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +02:00
41 lines
1.3 KiB
PHP
Executable File
41 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
$_SERVER['JOPLIN_TESTING'] = true;
|
|
|
|
require_once dirname(__FILE__) . '/TestUtils.php';
|
|
require_once dirname(__FILE__) . '/BaseTestCase.php';
|
|
require_once dirname(__FILE__) . '/BaseControllerTestCase.php';
|
|
|
|
$dbConfig = array(
|
|
'dbName' => 'notes_test',
|
|
'user' => 'root',
|
|
'password' => 'pass',
|
|
'host' => '127.0.0.1',
|
|
);
|
|
|
|
$structureFile = dirname(dirname(__FILE__)) . '/structure.sql';
|
|
|
|
$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']);
|
|
exec($cmd);
|
|
|
|
$cmd = sprintf("mysql -u %s %s -h %s %s < '%s'", $dbConfig['user'], empty($dbConfig['password']) ? '' : '-p' . $dbConfig['password'], $dbConfig['host'], $dbConfig['dbName'], $structureFile);
|
|
exec($cmd);
|
|
|
|
$capsule = new \Illuminate\Database\Capsule\Manager();
|
|
|
|
$capsuleConfig = [
|
|
'driver' => 'mysql',
|
|
'host' => $dbConfig['host'],
|
|
'database' => $dbConfig['dbName'],
|
|
'username' => $dbConfig['user'],
|
|
'password' => $dbConfig['password'],
|
|
'charset' => 'utf8',
|
|
'collation' => 'utf8_unicode_ci',
|
|
'prefix' => '',
|
|
];
|
|
|
|
$capsule->addConnection($capsuleConfig);
|
|
|
|
$_SERVER['JOPLIN_TESTING_DB_CONFIG'] = $capsuleConfig;
|
|
|
|
$capsule->bootEloquent(); |