If not created Logger class will be auto created in \DB\IO Recommended to run a CoreLibs\Debug\Logging([...]); and use this class for all ACL\Login, Admin\Backend, DB\IO, Output\Form\Generate calls. Last parameter after DB CONFIG is the log parameter Session create has been moved to a new Create\Session class from the \Basic class and MUST be started before using ACL\Login. Currently ACL\Login will fallback and start it if no session is yet started. See the Readme.md file for which classes use _SESSION data In future the _SESSION settings should be moved to some wrapper class for this so we can unit test sessions Only Output\Form\Generate class call has the new changed with the second parameter no longer beeing the table width setting but the class setting. But as this is a semi retired class and only used for edit_base this is not 100% breaking. All other classes can be used as is and have internal fallback to run as before. Deprecation messages will be added later.
105 lines
2.1 KiB
PHP
105 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Test class for Create\Session
|
|
* @coversDefaultClass \CoreLibs\Create\Session
|
|
* @testdox \CoreLibs\Create\Session method tests
|
|
*/
|
|
final class CoreLibsCreateSessionTest extends TestCase
|
|
{
|
|
/**
|
|
* Undocumented function
|
|
*
|
|
* @return array
|
|
*/
|
|
public function sessionProvider(): array
|
|
{
|
|
return [
|
|
'session parameter' => [
|
|
'sessionNameParameter',
|
|
'p',
|
|
'sessionNameParameter',
|
|
'/^\w+$/'
|
|
],
|
|
'session globals' => [
|
|
'sessionNameGlobals',
|
|
'g',
|
|
'sessionNameGlobals',
|
|
'/^\w+$/'
|
|
],
|
|
'session constant' => [
|
|
'sessionNameConstant',
|
|
'c',
|
|
'sessionNameConstant',
|
|
'/^\w+$/'
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Undocumented function
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function setUp(): void
|
|
{
|
|
if (session_id()) {
|
|
session_destroy();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Undocumented function
|
|
*
|
|
* @dataProvider sessionProvider
|
|
* @testdox startSession $input name for $type will be $expected_n with $expected_i [$_dataName]
|
|
*
|
|
* @param string $input
|
|
* @param string $type
|
|
* @param string|bool $expected_n
|
|
* @param string|bool $expected_i
|
|
* @return void
|
|
*/
|
|
public function testStartSession(string $input, string $type, $expected_n, $expected_i): void
|
|
{
|
|
/* $session_id = '';
|
|
switch ($type) {
|
|
case 'p':
|
|
$session_id = \CoreLibs\Create\Session::startSession($input);
|
|
break;
|
|
case 'g':
|
|
$GLOBALS['SET_SESSION_NAME'] = $input;
|
|
$session_id = \CoreLibs\Create\Session::startSession();
|
|
break;
|
|
case 'c':
|
|
define('SET_SESSION_NAME', $input);
|
|
$session_id = \CoreLibs\Create\Session::startSession();
|
|
break;
|
|
}
|
|
$this->assertMatchesRegularExpression(
|
|
$expected_i,
|
|
(string)$session_id
|
|
);
|
|
$this->assertMatchesRegularExpression(
|
|
$expected_i,
|
|
(string)\CoreLibs\Create\Session::getSessionId()
|
|
);
|
|
$this->assertEquals(
|
|
$expected_n,
|
|
\CoreLibs\Create\Session::getSessionName()
|
|
);
|
|
if ($type == 'g') {
|
|
unset($GLOBALS['SET_SESSION_NAME']);
|
|
} */
|
|
$this->markTestSkipped('No implementation for Create\Session. Cannot run session_start in CLI');
|
|
}
|
|
}
|
|
|
|
// __END__
|