Convert static Session class to normal session class
All static Session:: calls (except for checking valid session name) are converted to object type. This Object is passed on to Login, Admin Backend and any other class that needs basic session checking
This commit is contained in:
@@ -15,6 +15,7 @@ final class CoreLibsACLLoginTest extends TestCase
|
||||
{
|
||||
private static $db;
|
||||
private static $log;
|
||||
private static $session;
|
||||
|
||||
/**
|
||||
* start DB conneciton, setup DB, etc
|
||||
@@ -28,6 +29,8 @@ final class CoreLibsACLLoginTest extends TestCase
|
||||
'The PgSQL extension is not available.'
|
||||
);
|
||||
}
|
||||
// init session
|
||||
self::$session = new \CoreLibs\Create\Session('ACLLoginTest');
|
||||
// logger is always needed
|
||||
// define basic connection set valid and one invalid
|
||||
self::$log = new \CoreLibs\Debug\Logging([
|
||||
@@ -96,7 +99,7 @@ final class CoreLibsACLLoginTest extends TestCase
|
||||
'ACL\Login Tests have not yet been implemented'
|
||||
);
|
||||
|
||||
$login = new \CoreLibs\ACL\Login(self::$db, self::$log);
|
||||
$login = new \CoreLibs\ACL\Login(self::$db, self::$log, self::$session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ final class CoreLibsCreateSessionTest extends TestCase
|
||||
'sessionNameGlobals',
|
||||
'/^\w+$/'
|
||||
],
|
||||
'session constant' => [
|
||||
'sessionNameConstant',
|
||||
'c',
|
||||
'sessionNameConstant',
|
||||
'session name default' => [
|
||||
'',
|
||||
'd',
|
||||
'',
|
||||
'/^\w+$/'
|
||||
],
|
||||
];
|
||||
@@ -64,19 +64,22 @@ final class CoreLibsCreateSessionTest extends TestCase
|
||||
$expected_n,
|
||||
$expected_i
|
||||
): void {
|
||||
// NEEDS MOCKING
|
||||
/* $session_id = '';
|
||||
/*
|
||||
// MOCK class for dummy call
|
||||
$session = new \CoreLibs\Create\Session();
|
||||
$session_id = '';
|
||||
unset($GLOBALS['SET_SESSION_NAME']);
|
||||
switch ($type) {
|
||||
case 'p':
|
||||
$session_id = \CoreLibs\Create\Session::startSession($input);
|
||||
$session_id = $session->startSession($input);
|
||||
break;
|
||||
case 'g':
|
||||
$GLOBALS['SET_SESSION_NAME'] = $input;
|
||||
$session_id = \CoreLibs\Create\Session::startSession();
|
||||
$session_id = $session->startSession();
|
||||
break;
|
||||
case 'c':
|
||||
define('SET_SESSION_NAME', $input);
|
||||
$session_id = \CoreLibs\Create\Session::startSession();
|
||||
case 'd':
|
||||
$expected_n = ini_get('session.name');
|
||||
$session_id = \$session->startSession();
|
||||
break;
|
||||
}
|
||||
$this->assertMatchesRegularExpression(
|
||||
@@ -85,11 +88,11 @@ final class CoreLibsCreateSessionTest extends TestCase
|
||||
);
|
||||
$this->assertMatchesRegularExpression(
|
||||
$expected_i,
|
||||
(string)\CoreLibs\Create\Session::getSessionId()
|
||||
(string)$session->getSessionId()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expected_n,
|
||||
\CoreLibs\Create\Session::getSessionName()
|
||||
$session->getSessionName()
|
||||
);
|
||||
if ($type == 'g') {
|
||||
unset($GLOBALS['SET_SESSION_NAME']);
|
||||
|
||||
Reference in New Issue
Block a user