2014-03-12 17:43:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This is the abstract class for all tests
|
|
|
|
* @see http://phpunit.de/manual/
|
|
|
|
*/
|
2014-03-19 09:15:54 +00:00
|
|
|
abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase
|
2014-03-12 17:43:26 +00:00
|
|
|
{
|
2014-03-22 14:41:40 +00:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2014-03-27 17:02:55 +00:00
|
|
|
* @param string $fileList
|
2014-03-22 14:41:40 +00:00
|
|
|
* @return \PHPUnit_Extensions_Database_DataSet_YamlDataSet
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
2014-03-27 09:20:26 +00:00
|
|
|
public function loadDataSet($fileList)
|
2014-03-22 14:41:40 +00:00
|
|
|
{
|
2014-03-27 13:50:44 +00:00
|
|
|
if (empty($fileList)) {
|
|
|
|
throw new \Exception("No files specified");
|
|
|
|
}
|
2014-03-27 09:20:26 +00:00
|
|
|
if( !is_array($fileList)){
|
|
|
|
$fileList = array($fileList);
|
2014-03-22 14:41:40 +00:00
|
|
|
}
|
2014-03-27 09:20:26 +00:00
|
|
|
$datasetList = array();
|
|
|
|
foreach ($fileList as $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);
|
|
|
|
$datasetList[] = $dataSet;
|
|
|
|
}
|
|
|
|
$compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList);
|
2014-08-01 15:50:49 +00:00
|
|
|
return $compositeDataSet;
|
2014-03-22 14:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-27 13:50:44 +00:00
|
|
|
}
|