phpunit tests update for acl login, db io, fix smarty extended class
This commit is contained in:
@@ -13,18 +13,73 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
final class CoreLibsACLLoginTest extends TestCase
|
||||
{
|
||||
private static $db;
|
||||
private static $log;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* start DB conneciton, setup DB, etc
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pgsql')) {
|
||||
$this->markTestSkipped(
|
||||
self::markTestSkipped(
|
||||
'The PgSQL extension is not available.'
|
||||
);
|
||||
}
|
||||
// logger is always needed
|
||||
// define basic connection set valid and one invalid
|
||||
self::$log = new \CoreLibs\Debug\Logging([
|
||||
// 'log_folder' => __DIR__ . DIRECTORY_SEPARATOR . 'log',
|
||||
'log_folder' => DIRECTORY_SEPARATOR . 'tmp',
|
||||
'file_id' => 'CoreLibs-ACL-Login-Test',
|
||||
'debug_all' => false,
|
||||
'echo_all' => false,
|
||||
'print_all' => false,
|
||||
]);
|
||||
// if we do have pgsql, we need to create a test DB or check that one
|
||||
// exists and clean the table to zero state
|
||||
self::$db = new \CoreLibs\DB\IO(
|
||||
[
|
||||
'db_name' => 'corelibs_acl_login_test',
|
||||
'db_user' => 'corelibs_acl_login_test',
|
||||
'db_pass' => 'corelibs_acl_login_test',
|
||||
'db_host' => 'localhost',
|
||||
'db_port' => 5432,
|
||||
'db_schema' => 'public',
|
||||
'db_type' => 'pgsql',
|
||||
'db_encoding' => '',
|
||||
'db_ssl' => 'allow', // allow, disable, require, prefer
|
||||
'db_debug' => true,
|
||||
],
|
||||
self::$log
|
||||
);
|
||||
if (!self::$db->dbGetConnectionStatus()) {
|
||||
self::markTestSkipped(
|
||||
'Cannot connect to valid Test DB for ACL\Login test.'
|
||||
);
|
||||
}
|
||||
/*
|
||||
// check if they already exist, drop them
|
||||
if ($db->dbShowTableMetaData('table_with_primary_key') !== false) {
|
||||
$db->dbExec("DROP TABLE table_with_primary_key");
|
||||
$db->dbExec("DROP TABLE table_without_primary_key");
|
||||
$db->dbExec("DROP TABLE test_meta");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* close db
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
if (self::$db->dbGetConnectionStatus()) {
|
||||
self::$db->dbClose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,7 +145,7 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
);
|
||||
if (!$db->dbGetConnectionStatus()) {
|
||||
self::markTestSkipped(
|
||||
'Cannot connect to valid Test DB.'
|
||||
'Cannot connect to valid Test DB for DB\IO test.'
|
||||
);
|
||||
}
|
||||
// check if they already exist, drop them
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class TemplateMethodsTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
}
|
||||
|
||||
protected function assertPreConditions(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
}
|
||||
|
||||
public function testOne(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testTwo(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
$this->assertTrue(false);
|
||||
}
|
||||
|
||||
protected function assertPostConditions(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
}
|
||||
|
||||
protected function onNotSuccessfulTest(\Throwable $t): void
|
||||
{
|
||||
fwrite(STDOUT, __METHOD__ . "\n");
|
||||
throw $t;
|
||||
}
|
||||
}
|
||||
@@ -319,9 +319,15 @@ class SmartyExtend extends \Smarty
|
||||
// if .tpl, put before .tpl
|
||||
// if not .tpl, add _<$this->lang>.tpl
|
||||
if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
|
||||
$this->TEMPLATE_TRANSLATE = str_replace('.tpl', '_' . $this->lang . '.tpl', $this->TEMPLATE_TRANSLATE);
|
||||
$this->TEMPLATE_TRANSLATE = str_replace(
|
||||
'.tpl',
|
||||
'-' . $this->lang . '.' . $this->encoding . '.tpl',
|
||||
$this->TEMPLATE_TRANSLATE
|
||||
);
|
||||
} else {
|
||||
$this->TEMPLATE_TRANSLATE .= '_' . $this->lang . '.tpl';
|
||||
$this->TEMPLATE_TRANSLATE .= '_'
|
||||
. $this->lang . '.' . $this->encoding
|
||||
. '.tpl';
|
||||
}
|
||||
}
|
||||
// if we can't find it, dump it
|
||||
|
||||
Reference in New Issue
Block a user