Commit e876eb51 authored by Marc Egger's avatar Marc Egger
Browse files

create tests dir outside of Source, create phpunit.xml, move some tests and make them work

parent 8b9ff4fe
Pipeline #1174 passed with stage
in 1 minute and 31 seconds
<phpunit bootstrap="Source/bootstrap.php">
<testsuites>
<testsuite name="qfq">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">Source/core/helper</directory>
<directory suffix=".php">Source/core/database</directory>
</whitelist>
</filter>
</phpunit>
\ No newline at end of file
......@@ -3,15 +3,9 @@
* @author Carsten Rose <carsten.rose@math.uzh.ch>
*/
//namespace qfq;
namespace qfq;
use qfq\Store;
//use qfq;
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../../core/store/Store.php');
require_once(__DIR__ . '/../../core/store/Sip.php');
require_once(__DIR__ . '/../../../../Source/bootstrap.php');
use PHPUnit\Framework\TestCase;
......@@ -27,17 +21,17 @@ abstract class AbstractDatabaseTest extends TestCase {
static protected $mysqli = null;
/**
* @var qfq\Database
* @var Database
*/
protected $dbArray = array();
/**
* @var qfq\Store
* @var Store
*/
protected $store = null;
/**
* @var qfq\Sip
* @var Sip
*/
protected $sip = null;
......@@ -68,9 +62,9 @@ abstract class AbstractDatabaseTest extends TestCase {
protected function setUp() {
// Init the store also reads db credential configuration
$this->store = qfq\Store::getInstance('', true);
$this->store = Store::getInstance('', true);
$this->sip = new qfq\Sip(true);
$this->sip = new Sip(true);
$this->sip->sipUniqId('badcaffee1234');
// SWITCH to TestDB
......@@ -82,7 +76,7 @@ abstract class AbstractDatabaseTest extends TestCase {
// $this->store->setVar('DB_1_NAME', $dbNamePhpUnit, STORE_SYSTEM);
$dbName = $this->store->getVar('DB_NAME_TEST', STORE_SYSTEM);
if ($dbName == '') {
throw new \qfq\CodeException('Missing DB_NAME_TEST in ' . CONFIG_QFQ_PHP, ERROR_MISSING_REQUIRED_PARAMETER);
throw new CodeException('Missing DB_NAME_TEST in ' . CONFIG_QFQ_PHP, ERROR_MISSING_REQUIRED_PARAMETER);
} else {
$this->store->setVar('DB_1_NAME', $dbName, STORE_SYSTEM);
}
......@@ -90,12 +84,12 @@ abstract class AbstractDatabaseTest extends TestCase {
$dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
if ($dbIndexData != $dbIndexQfq) {
throw new \qfq\CodeException('phpUnit Tests are not prepared for MultiDB tests');
throw new CodeException('phpUnit Tests are not prepared for MultiDB tests');
}
if (empty($this->dbArray)) {
$this->dbArray[DB_INDEX_DEFAULT] = new qfq\Database();
$this->dbArray[DB_INDEX_DEFAULT] = new Database();
}
/// Establish additional mysqli access
......
......@@ -3,9 +3,9 @@
* @author Carsten Rose <carsten.rose@math.uzh.ch>
*/
namespace qfq;
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../../core/exceptions/DbException.php');
/**
* Class DatabaseTest
......
......@@ -8,13 +8,17 @@
namespace qfq;
use PHPUnit\Framework\TestCase;
require_once(__DIR__ . '/../../../../Source/bootstrap.php');
require_once(__DIR__ . '/../../../bootstrap.php');
use PHPUnit\Framework\TestCase;
/**
* Class BindParamTest
* @package qfq
*/
class BindParamTest extends TestCase {
/**
* @covers \qfq\BindParam
* @covers qfq\BindParam
*/
public function testParamInitiallyEmptyString() {
$bp = new BindParam;
......@@ -22,8 +26,8 @@ class BindParamTest extends TestCase {
return $bp;
}
/**
* @covers \qfq\BindParam::add
* @covers \qfq\BindParam::get
* @covers qfq\BindParam::add
* @covers qfq\BindParam::get
* @depends testParamInitiallyEmptyString
*/
public function testAddValues($bp) {
......
......@@ -8,8 +8,7 @@
namespace qfq;
require_once(__DIR__ . '/../../core/helper/Sanitize.php');
require_once(__DIR__ . '/../../core/exceptions/CodeException.php');
require_once(__DIR__ . '/../../../../Source/bootstrap.php');
use PHPUnit\Framework\TestCase;
......
......@@ -8,9 +8,7 @@
namespace qfq;
require_once(__DIR__ . '/../../core/helper/Support.php');
require_once(__DIR__ . '/../../core/BuildFormPlain.php');
require_once(__DIR__ . '/../../core/Evaluate.php');
require_once(__DIR__ . '/../../../../Source/bootstrap.php');
use PHPUnit\Framework\TestCase;
......
......@@ -6,12 +6,9 @@
* Time: 9:16 PM
*/
namespace qfq;
require_once(__DIR__ . '/../../core/helper/Token.php');
#use qfq;
require_once(__DIR__ . '/../../../../Source/bootstrap.php');
use PHPUnit\Framework\TestCase;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment