mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 04:40:45 +09:00
* Update rector config to include tests * Run Rector against the tests * Delete test-results * Update .gitignore * Correctly set the PHP min to 8.1, split the configs * Corrected PHPDoc * Deleted tests we can't really get to pass PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so). No way to disable the exception as far as we can tell
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
abstract class BBDatabaseTestCase extends Testcase
|
|
{
|
|
static private ?\PDO $pdo = null;
|
|
private $conn = NULL;
|
|
|
|
protected $_seedFilesPath = NULL;
|
|
protected $_initialSeedFile = 'initial.xml';
|
|
|
|
final public function getConnection()
|
|
{
|
|
if ($this->conn === null) {
|
|
if (self::$pdo == null) {
|
|
self::$pdo = new PDO( 'mysql:dbname='.BB_DB_NAME.';host=127.0.0.1;port='.BB_DB_PORT, BB_DB_USER, BB_DB_PASSWORD );
|
|
}
|
|
$this->conn = $this->createDefaultDBConnection(self::$pdo, BB_DB_NAME);
|
|
}
|
|
|
|
return $this->conn;
|
|
}
|
|
|
|
/**
|
|
* Returns the seed files folder path
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSeedFilesPath()
|
|
{
|
|
if ($this->_seedFilesPath == NULL) {
|
|
$this->_seedFilesPath = PATH_TESTS.'/fixtures';
|
|
}
|
|
|
|
return rtrim($this->_seedFilesPath, '/') . '/';
|
|
}
|
|
|
|
/**
|
|
* Retrieve from flat XML files data used to populate the database
|
|
*
|
|
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
|
|
*/
|
|
protected function getDataSet()
|
|
{
|
|
return $this->createFlatXmlDataSet($this->getSeedFilesPath() . $this->_initialSeedFile);
|
|
}
|
|
} |