Commit 9a7667f5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

phpdoc: update

parent 858ffb15
Pipeline #1213 passed with stage
in 1 minute and 46 seconds
......@@ -16,32 +16,46 @@ require_once(__DIR__ . '/database/AbstractDatabaseTest.php');
*/
class EvaluateTest extends AbstractDatabaseTest {
/**
*
*/
public function testVars() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
// no variable
$this->assertEquals('nothing', $eval->parse('nothing'));
$this->assertEquals('TestFormName', $eval->parse('{{form:T}}'));
// pure digit variable
$this->store->setVar('a', '1', 'C');
$this->assertEquals('1', $eval->parse('{{a:C}}'));
// variable contains variable
$this->store->setVar('a', '{{b:C}}', 'C');
$this->store->setVar('b', '1234', 'C');
$this->assertEquals('1234', $eval->parse('{{a:C:all}}'));
// multiple vaules, Recursive
$this->store->setVar('m1', 'M1=[{{m2:C:all}}]', 'C');
$this->store->setVar('m2', 'M2=[{{m3:C:all}}]', 'C');
$this->store->setVar('m3', 'Some really nice text', 'C');
$this->assertEquals('These are the variables > m1:M1=[M2=[Some really nice text]], m2:M2=[Some really nice text], m3:Some really nice text - end outer line',
$eval->parse('These are the variables > m1:{{m1:C:all}}, m2:{{m2:C:all}}, m3:{{m3:C:all}} - end outer line'));
try {
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
// no variable
$this->assertEquals('nothing', $eval->parse('nothing'));
$this->assertEquals('TestFormName', $eval->parse('{{form:T}}'));
// pure digit variable
$this->store->setVar('a', '1', 'C');
$this->assertEquals('1', $eval->parse('{{a:C}}'));
// variable contains variable
$this->store->setVar('a', '{{b:C}}', 'C');
$this->store->setVar('b', '1234', 'C');
$this->assertEquals('1234', $eval->parse('{{a:C:all}}'));
// multiple vaules, Recursive
$this->store->setVar('m1', 'M1=[{{m2:C:all}}]', 'C');
$this->store->setVar('m2', 'M2=[{{m3:C:all}}]', 'C');
$this->store->setVar('m3', 'Some really nice text', 'C');
$this->assertEquals('These are the variables > m1:M1=[M2=[Some really nice text]], m2:M2=[Some really nice text], m3:Some really nice text - end outer line',
$eval->parse('These are the variables > m1:{{m1:C:all}}, m2:{{m2:C:all}}, m3:{{m3:C:all}} - end outer line'));
} catch (\Exception $e) {
echo $e->getMessage();
}
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testParse() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
// database: lower case
$this->assertEquals('1DoeJohn0malec2SmithJane0femalea,c', $eval->parse('{{select id,name,firstName,adrId,gender,groups from Person where id < 3 order by id}}'));
......@@ -87,12 +101,16 @@ class EvaluateTest extends AbstractDatabaseTest {
$expected = "idbigint(20)NOPRIauto_incrementnamevarchar(128)YESfirstNamevarchar(128)YESadrIdint(11)NO0genderenum('','male','female')NOmalegroupsset('','a','b','c')NOmodifiedtimestampNOCURRENT_TIMESTAMPon update CURRENT_TIMESTAMPcreateddatetimeNO";
$this->assertEquals($expected, $eval->parse('{{SHOW COLUMNS FROM Person}}'));
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testDbVars() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval->parse('{{INSERT INTO Person (name, firstname) VALUES (\'Holiday\', \'Billie\')}}');
$this->store->setVar('a', '{{b:C:all}}', 'C');
......@@ -100,8 +118,14 @@ class EvaluateTest extends AbstractDatabaseTest {
$this->assertEquals('Holiday', $eval->parse('{{SELECT name FROM Person WHERE name=\'{{a:C:all}}\'}}'));
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testParseArray() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$data = [
'formName' => 'MyTestForm',
......@@ -131,8 +155,14 @@ class EvaluateTest extends AbstractDatabaseTest {
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testParseArrayOfArray() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$data = [
[
'formName' => 'MyTestForm',
......@@ -157,8 +187,14 @@ class EvaluateTest extends AbstractDatabaseTest {
$this->assertEquals($expected, $eval->parseArray($data));
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testSubstituteSql() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$expectArr = [0 => ['name' => 'Holiday', 'firstname' => 'Billie'], 1 => ['name' => 'Holiday', 'firstname' => 'Billie']];
......@@ -200,8 +236,14 @@ class EvaluateTest extends AbstractDatabaseTest {
$this->assertEquals(TOKEN_FOUND_IN_STORE_QUERY, $foundInStore);
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testSubstituteVar() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
// Retrieve in PRIO `FSRD`
$this->store->setVar('a', '1234', STORE_TABLE_DEFAULT, true);
......@@ -269,8 +311,14 @@ class EvaluateTest extends AbstractDatabaseTest {
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testSubstituteVarEscape() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
// No escape
$this->store->setVar('a', 'hello', STORE_FORM, true);
......@@ -359,8 +407,14 @@ class EvaluateTest extends AbstractDatabaseTest {
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testSubstituteDefault() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
$eval = new Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
// No escape
$this->store->setVar('a', 'hello', STORE_FORM, true);
......@@ -378,13 +432,25 @@ class EvaluateTest extends AbstractDatabaseTest {
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
protected function setUp() {
$this->store = Store::getInstance('form=TestFormName', true);
parent::setUp();
try {
$this->store = Store::getInstance('form=TestFormName', true);
parent::setUp();
$this->store->setVar('form', 'TestFormName', STORE_TYPO3);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
} catch (\Exception $e) {
echo $e->getMessage();
}
$this->store->setVar('form', 'TestFormName', STORE_TYPO3);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
}
}
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