Alternc  latest
Alternc logiel libre pour l'hébergement
AlterncTest.php
Go to the documentation of this file.
1 <?php
2 /**
3  * This is the abstract class for all tests
4  * @see http://phpunit.de/manual/
5  */
6 use PHPUnit\Framework\TestCase;
7 use PHPUnit\DbUnit\TestCaseTrait;
8 use PHPUnit\DbUnit\DataSet\YamlDataSet;
9 use PHPUnit\DbUnit\DataSet\CompositeDataSet;
10 
11 abstract class AlterncTest extends TestCase
12 {
13  use TestCaseTrait;
14 
15  /**
16  * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
17  */
18  public function getConnection()
19  {
20  global $database,$user,$password;
21  $pdo = new PDO('mysql:dbname='.$database.';host=127.0.0.1',$user,$password);
22  return $this->createDefaultDBConnection($pdo);
23  }
24 
25  /**
26  *
27  * @param string $fileList
28  * @return \PHPUnit_Extensions_Database_DataSet_YamlDataSet
29  * @throws \Exception
30  */
31  public function loadDataSet($fileList)
32  {
33  if (empty($fileList)) {
34  throw new \Exception("No files specified");
35  }
36  if( !is_array($fileList)){
37  $fileList = array($fileList);
38  }
39  $datasetList = array();
40  foreach ($fileList as $file_name) {
41  $file = PHPUNIT_DATASETS_PATH."/$file_name";
42  if( !is_file($file) ){
43  throw new \Exception("missing $file");
44  }
45  $dataSet = new YamlDataSet($file);
46  $datasetList[] = $dataSet;
47  }
48  $compositeDataSet = new CompositeDataSet($datasetList);
49  return $dataSet;
50  }
51 
52 }
loadDataSet($fileList)
Definition: AlterncTest.php:31
foreach(array(ALTERNC_MAIL, ALTERNC_HTML, ALTERNC_LOGS) as $crdir) $database
Definition: bootstrap.php:83
const PHPUNIT_DATASETS_PATH
Definition: bootstrap.php:20
$user
Definition: bootstrap.php:84
$password
Definition: bootstrap.php:85