Commit caddc012 authored by Carsten  Rose's avatar Carsten Rose
Browse files

phpunit: fix problems.

parent c5ea13b0
Pipeline #1217 passed with stage
in 1 minute and 35 seconds
......@@ -33,7 +33,7 @@ class Config {
$content = '<?php' . PHP_EOL . 'return [' . PHP_EOL;
foreach ([$pre . '_NAME', $pre . '_PASSWORD', $pre . '_SERVER', $pre . '_USER', SYSTEM_LDAP_1_RDN, SYSTEM_LDAP_1_PASSWORD] as $key) {
$content .= " '$key' => '" . $config[$key] . "'," . PHP_EOL;
$content .= " '$key' => '" . ($config[$key]??"") . "'," . PHP_EOL;
}
$content .= "];" . PHP_EOL;
......
......@@ -23,6 +23,11 @@ class StoreTest extends TestCase {
private $setUpDone = false;
/**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public function setUp() {
// Client Variables has to setup before the first instantiation of 'Store'
$_GET[CLIENT_RECORD_ID] = '1234';
......@@ -38,6 +43,11 @@ class StoreTest extends TestCase {
}
/**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public function testGetInstance() {
$a = Store::getInstance('', true);
$b = Store::getInstance('', true);
......@@ -47,6 +57,10 @@ class StoreTest extends TestCase {
$this->assertEquals($a, $b, "Both classes should be the same");
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testGetVarStoreTypo3() {
// T3 Bodytext
$this->store->setVar(TYPO3_FORM, "testformnameDoNotChange", STORE_TYPO3);
......@@ -54,6 +68,10 @@ class StoreTest extends TestCase {
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testGetVarStoreSystem() {
// DBUSER in qfq.ini
$val = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
......@@ -61,6 +79,10 @@ class StoreTest extends TestCase {
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testSetVarStoreSystem() {
// set new Sessionname
......@@ -76,7 +98,10 @@ class StoreTest extends TestCase {
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testGetVarStoreClient() {
# Violates SANITIZE class: sanitized string is always an empty string.
......@@ -113,7 +138,12 @@ class StoreTest extends TestCase {
$this->assertEquals('5678', $this->store->getVar('key04', STORE_CLIENT), "Param: POST higher priority than GET");
}
/**
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function testStorePriority() {
//default prio FSRVD
......@@ -136,6 +166,10 @@ class StoreTest extends TestCase {
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testStoreDifferentSanitizeClass() {
//default prio FSRD
......@@ -147,12 +181,20 @@ class StoreTest extends TestCase {
$this->assertEquals('green', $this->store->getVar('color', '', SANITIZE_ALLOW_ALNUMX), "Retrieve 'color' from STORE_FORM");
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testGetVarStore0() {
//default prio FSRD
$this->assertEquals(0, $this->store->getVar('fakename', STORE_ZERO), "Retrieve anything from STORE_ZERO");
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testUnsetStore() {
$this->store->unsetStore(STORE_RECORD);
......@@ -160,6 +202,10 @@ class StoreTest extends TestCase {
$this->assertEquals(false, $this->store->getVar('apple', STORE_RECORD), "Retrieve a value from store.");
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testSetVarArray() {
$this->store->unsetStore(STORE_RECORD);
$arr = ['a' => '1', 'apple' => 'green'];
......@@ -168,7 +214,10 @@ class StoreTest extends TestCase {
$this->assertEquals('green', $this->store->getVar('apple', STORE_RECORD), "Retrieve a value from store.");
}
/**
* @throws CodeException
* @throws UserFormException
*/
public function testSetVarArrayEmpty() {
$this->store->unsetStore(STORE_RECORD);
$arr = array();
......@@ -176,6 +225,11 @@ class StoreTest extends TestCase {
$this->assertEquals(false, $this->store->getVar('apple', STORE_RECORD), "Retrieve a value from store.");
}
/**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public function testSetVar() {
$this->store = Store::getInstance('', true);
......@@ -202,6 +256,9 @@ class StoreTest extends TestCase {
/**
* @expectedException \qfq\UserFormException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public function testConfigMandatoryValues() {
......@@ -215,7 +272,9 @@ class StoreTest extends TestCase {
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public function testAppendToStore() {
$this->store->unsetStore(STORE_RECORD);
......@@ -248,8 +307,7 @@ class StoreTest extends TestCase {
/**
* @param $body
*
* @return string
* @return bool|string
*/
private function createFile($body) {
......@@ -261,6 +319,11 @@ class StoreTest extends TestCase {
return $tmpFileName;
}
/**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public function testConfigIniDefaultValues() {
$body = <<< EOT
......@@ -403,6 +466,8 @@ EOT;
/**
* @expectedException \qfq\UserFormException
*
* @throws CodeException
* @throws UserFormException
*/
public function testGetStore() {
$this->assertEquals(array(), $this->store->getStore('unknownstore'));
......
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