diff --git a/src/AppBundle/Eloquent.php b/src/AppBundle/Eloquent.php index 481a915c8..d3865cde0 100755 --- a/src/AppBundle/Eloquent.php +++ b/src/AppBundle/Eloquent.php @@ -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( diff --git a/tests/BaseControllerTestCase.php b/tests/BaseControllerTestCase.php index 2db8af968..24cf4b2fe 100644 --- a/tests/BaseControllerTestCase.php +++ b/tests/BaseControllerTestCase.php @@ -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(), diff --git a/tests/setup.php b/tests/setup.php index 84ca33af4..31aa4c75d 100755 --- a/tests/setup.php +++ b/tests/setup.php @@ -1,5 +1,6 @@ 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(); \ No newline at end of file