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