Files
FOSSBilling/tests/includes/BBDatabaseTestCase.php
T
Belle Aerni 32d011225b Rector & PHP-CS-Fixer Improvements (#2047)
* Added the rector cache to the action

* Enabled PHP-CS fixer for the tests & library folder

* Use the PHP-CS-Fixer Cache

* Fix the tests

* Ensure the Sentry placeholder isn't messed up from CS changes

* Typo..
2024-01-08 00:10:00 +00:00

49 lines
1.2 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
abstract class BBDatabaseTestCase extends Testcase
{
private static ?\PDO $pdo = null;
private $conn;
protected $_seedFilesPath;
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);
}
}