From 5c08aa924882178b39c841132a1de3e4dcf3cca8 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 16 Oct 2015 11:13:00 +1300 Subject: [PATCH] ENH: allow specify database by filename --- code/TestSessionController.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/code/TestSessionController.php b/code/TestSessionController.php index 0e33201..1031bd4 100644 --- a/code/TestSessionController.php +++ b/code/TestSessionController.php @@ -94,9 +94,24 @@ class TestSessionController extends Controller { $this->environment->startTestSession($params, $id); // Optionally import database - if(!empty($params['importDatabasePath'])) { + if(!empty($params['importDatabasePath']) || !empty($params['importDatabaseFilename'])) { + $absPath = ''; + + // by path + if(!empty($params['importDatabasePath'])) { + $absPath = $params['importDatabasePath']; + + // by filename + }else if(!empty($params['importDatabaseFilename'])) { + foreach($this->getDatabaseTemplates() as $tAbsPath => $tFilename){ + if($tFilename === $params['importDatabaseFilename']){ + $absPath = $tAbsPath; + break; + } + } + } $this->environment->importDatabase( - $params['importDatabasePath'], + $absPath, !empty($params['requireDefaultRecords']) ? $params['requireDefaultRecords'] : false ); } else if(!empty($params['requireDefaultRecords']) && $params['requireDefaultRecords']) { @@ -377,4 +392,4 @@ class TestSessionController extends Controller { return $params; } -} \ No newline at end of file +}