From f0ad82c5d5aa74f89d92509f138f9d765f845b4d Mon Sep 17 00:00:00 2001 From: alban Date: Sat, 22 Mar 2014 15:41:40 +0100 Subject: [PATCH] [enh] Readies AlterncTest for DbUnit testing --- phpunit/lib/AlterncTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/phpunit/lib/AlterncTest.php b/phpunit/lib/AlterncTest.php index babb48d3..0b313afe 100644 --- a/phpunit/lib/AlterncTest.php +++ b/phpunit/lib/AlterncTest.php @@ -5,4 +5,32 @@ */ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase { + /** + * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection + */ + public function getConnection() + { + global $database,$user,$password; + $pdo = new PDO('mysql:dbname='.$database.';host=127.0.0.1',$user,$password); + return $this->createDefaultDBConnection($pdo); + } + + /** + * + * @param type $file_name + * @return \PHPUnit_Extensions_Database_DataSet_YamlDataSet + * @throws \Exception + */ + public function loadDataSet($file_name) + { + $file = PHPUNIT_DATASETS_PATH."/$file_name"; + if( !is_file($file) ){ + throw new \Exception("missing $file"); + } + $dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file); + return $dataSet; + } + + + } \ No newline at end of file