[enh] Readies AlterncTest for DbUnit testing

This commit is contained in:
alban 2014-03-22 15:41:40 +01:00
parent b26fc42ac4
commit f0ad82c5d5
1 changed files with 28 additions and 0 deletions

View File

@ -5,4 +5,32 @@
*/ */
abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase 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;
}
} }