Commit 4d5fedb5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Store*.php: fixed bug - setVar() invalidates cache now

parent 7e4116b4
......@@ -57,7 +57,8 @@ class Store {
SYSTEM_DBPW => SANATIZE_ALL,
SYSTEM_DB => SANATIZE_ALNUMX,
SYSTEM_TESTDB => SANATIZE_ALNUMX,
SYSTEM_SESSIONNAME => SANATIZE_ALNUMX
SYSTEM_SESSIONNAME => SANATIZE_ALNUMX,
SYSTEM_DBH => SANATIZE_ALL
];
self::fillSystemStore();
......@@ -142,11 +143,10 @@ class Store {
*/
public static function setVar($key, $value, $store) {
if (isset(self::$raw[$store][$key])) {
throw new CodeException("Raw value already been copied to store '$store'. Do this only one time.", ERROR_VALUE_ALREADY_CODPIED);
}
self::$raw[$store][$key] = $value;
// Invalidate cache to force new sanatize
self::$cache[$store][$key] = null;
}
/**
......@@ -183,7 +183,7 @@ class Store {
continue;
}
// No value in raw? cache 'nothing found' and try next store
// No value in raw? set cache to 'nothing found' and try next store
if (!isset($rawVal)) {
self::$cache[$store][$key] = false;
continue;
......
......@@ -19,6 +19,9 @@ require_once(__DIR__ . '/../../qfq/exceptions/CodeException.php');
class StoreTest extends \PHPUnit_Framework_TestCase {
/**
* @var Store
*/
private $store = null;
public function setUp() {
......@@ -47,12 +50,15 @@ class StoreTest extends \PHPUnit_Framework_TestCase {
public function testGetVarT3Bodytext() {
// T3 Bodytext
$this->store->setVar(T3_BODYTEXT_FORM, "testformnameDoNotChange", STORE_T3_BODYTEXT);
$this->assertEquals('testformnameDoNotChange', $this->store->getVar(T3_BODYTEXT_FORM, STORE_T3_BODYTEXT), "System: " . T3_BODYTEXT_FORM);
// T3 Bodytext
$this->store->setVar(T3_BODYTEXT_DEBUG_SAVE, "6", STORE_T3_BODYTEXT);
$this->assertEquals('6', $this->store->getVar(T3_BODYTEXT_DEBUG_SAVE, STORE_T3_BODYTEXT), "System: " . T3_BODYTEXT_DEBUG_SAVE);
// T3 Bodytext
$this->store->setVar(T3_BODYTEXT_DEBUG_LOAD, "7", STORE_T3_BODYTEXT);
$this->assertEquals('7', $this->store->getVar(T3_BODYTEXT_DEBUG_LOAD, STORE_T3_BODYTEXT), "System: " . T3_BODYTEXT_DEBUG_LOAD);
}
......@@ -62,10 +68,21 @@ class StoreTest extends \PHPUnit_Framework_TestCase {
$dbuser = $this->store->getVar(SYSTEM_DBUSER, STORE_SYSTEM);
$this->assertTrue($dbuser !== false && $dbuser !== '', "System: DBUSER found in qfq.ini");
// Sessionname
}
public function testSetVarSystem() {
// Sessionname: default value
$this->assertEquals('qfq', $this->store->getVar(SYSTEM_SESSIONNAME, STORE_SYSTEM), "System: SESSIONNAME");
// set new Sessionname
$this->store->setVar(SYSTEM_SESSIONNAME, "anothersessionname", STORE_SYSTEM);
$this->assertEquals('anothersessionname', $this->store->getVar(SYSTEM_SESSIONNAME, STORE_SYSTEM), "System: SESSIONNAME");
}
public function testGetVarClient() {
//TODO: CR: phpunit running _all_ tests, fails with this tests always. Found no way to debug the situation.
......
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