Add basic Test run class
This commit is contained in:
58
www/lib/Test/DB/TestDB.php
Normal file
58
www/lib/Test/DB/TestDB.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TEST sets for DB::IO
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Test\DB;
|
||||||
|
|
||||||
|
use CoreLibs\DB\IO;
|
||||||
|
|
||||||
|
class TestDB
|
||||||
|
{
|
||||||
|
/** @var IO */
|
||||||
|
private $db;
|
||||||
|
/** @var array<mixed> */
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->config = [
|
||||||
|
'db_name' => $_ENV['DB_NAME_TEST'] ?? '',
|
||||||
|
'db_user' => $_ENV['DB_USER_TEST'] ?? '',
|
||||||
|
'db_pass' => $_ENV['DB_PASS_TEST'] ?? '',
|
||||||
|
'db_host' => $_ENV['DB_HOST_TEST'] ?? '',
|
||||||
|
'db_port' => 5432,
|
||||||
|
'db_schema' => 'public',
|
||||||
|
'db_type' => 'pgsql',
|
||||||
|
'db_encoding' => '',
|
||||||
|
'db_ssl' => 'allow'
|
||||||
|
];
|
||||||
|
$this->db = new IO($this->config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function testDBa(): void
|
||||||
|
{
|
||||||
|
$this->db->dbInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRunDB(): void
|
||||||
|
{
|
||||||
|
$this->testDBa();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// __ENB__
|
||||||
@@ -8,8 +8,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
|
use Test\DB;
|
||||||
|
|
||||||
class Test
|
class Test
|
||||||
{
|
{
|
||||||
|
/** @var DB\TestDB */
|
||||||
|
private $test_db;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -17,6 +21,9 @@ class Test
|
|||||||
$this->testPrivate();
|
$this->testPrivate();
|
||||||
$this->testProtected();
|
$this->testProtected();
|
||||||
$this->testPublic();
|
$this->testPublic();
|
||||||
|
|
||||||
|
// call intern
|
||||||
|
$this->test_db = new DB\TestDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
@@ -56,6 +63,16 @@ class Test
|
|||||||
$string = 'TEST Public';
|
$string = 'TEST Public';
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testClasses(): void
|
||||||
|
{
|
||||||
|
$this->test_db->testRunDB();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
Reference in New Issue
Block a user