1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-26 18:58:21 +02:00

Use test db

This commit is contained in:
Laurent Cozic 2017-06-03 19:00:07 +01:00
parent 00cc28cdc4
commit da8a40c381
3 changed files with 14 additions and 4 deletions

View File

@ -7,6 +7,11 @@ class Eloquent {
private $capsule_ = null;
public function __construct($dbParams, $mimeTypes, $paths, $cache) {
// TODO: find better way to pass around test db config
if (isset($_SERVER['JOPLIN_TESTING']) && $_SERVER['JOPLIN_TESTING']) {
$dbParams = $_SERVER['JOPLIN_TESTING_DB_CONFIG'];
}
$this->capsule_ = new \Illuminate\Database\Capsule\Manager();
$dbParamsDefaults = array(

View File

@ -17,7 +17,7 @@ class BaseControllerTestCase extends WebTestCase {
} else {
$client->request($method, $path);
}
} catch (Exception $e) {
} catch (\Exception $e) {
if (method_exists($e, 'toErrorArray')) return $e->toErrorArray();
return array(
'error' => $e->getMessage(),

View File

@ -1,5 +1,6 @@
<?php
$_SERVER['JOPLIN_TESTING'] = true;
require_once dirname(__FILE__) . '/BaseTestCase.php';
require_once dirname(__FILE__) . '/BaseControllerTestCase.php';
@ -21,7 +22,7 @@ exec($cmd);
$capsule = new \Illuminate\Database\Capsule\Manager();
$capsule->addConnection([
$capsuleConfig = [
'driver' => 'mysql',
'host' => $dbConfig['host'],
'database' => $dbConfig['dbName'],
@ -30,6 +31,10 @@ $capsule->addConnection([
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
];
$capsule->bootEloquent();
$capsule->addConnection($capsuleConfig);
$_SERVER['JOPLIN_TESTING_DB_CONFIG'] = $capsuleConfig;
$capsule->bootEloquent();