mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 15:18:41 +00:00
make db connection throw less exceptions
This commit is contained in:
parent
a0bb408b6a
commit
3db14eb5b6
|
|
@ -68,7 +68,10 @@ final class MysqlConnection extends ConnectionAbstract
|
||||||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||||
) {
|
) {
|
||||||
$this->status = DatabaseStatus::FAILURE;
|
$this->status = DatabaseStatus::FAILURE;
|
||||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
$this->dbdata['password'] = '****';
|
||||||
|
//throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
@ -82,7 +85,6 @@ final class MysqlConnection extends ConnectionAbstract
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
unset($this->con);
|
unset($this->con);
|
||||||
$this->status = DatabaseStatus::MISSING_DATABASE;
|
$this->status = DatabaseStatus::MISSING_DATABASE;
|
||||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
|
||||||
} finally {
|
} finally {
|
||||||
$this->dbdata['password'] = '****';
|
$this->dbdata['password'] = '****';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,10 @@ final class PostgresConnection extends ConnectionAbstract
|
||||||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||||
) {
|
) {
|
||||||
$this->status = DatabaseStatus::FAILURE;
|
$this->status = DatabaseStatus::FAILURE;
|
||||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
$this->dbdata['password'] = '****';
|
||||||
|
//throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,10 @@ final class SQLiteConnection extends ConnectionAbstract
|
||||||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||||
) {
|
) {
|
||||||
$this->status = DatabaseStatus::FAILURE;
|
$this->status = DatabaseStatus::FAILURE;
|
||||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
$this->dbdata['password'] = '****';
|
||||||
|
//throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,10 @@ final class SqlServerConnection extends ConnectionAbstract
|
||||||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||||
) {
|
) {
|
||||||
$this->status = DatabaseStatus::FAILURE;
|
$this->status = DatabaseStatus::FAILURE;
|
||||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
$this->dbdata['password'] = '****';
|
||||||
|
//throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
|
||||||
|
|
@ -2960,7 +2960,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$cachedTables = []; // used by conditionals
|
$cachedTables = []; // used by conditionals
|
||||||
|
|
||||||
foreach (static::$hasMany as $member => $value) {
|
foreach (static::$hasMany as $member => $value) {
|
||||||
if ($value['writeonly'] ?? false === true || isset($value['column'])) {
|
if ($value['writeonly'] ?? false === true || isset($value['column'])) { // @todo: conflict with getQuery()???!?!?!?!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3080,7 +3080,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
// get HasManyQuery (but only for elements which have a 'column' defined)
|
// get HasManyQuery (but only for elements which have a 'column' defined)
|
||||||
if ($depth > 1 && $relations === RelationType::ALL) {
|
if ($depth > 1 && $relations === RelationType::ALL) {
|
||||||
foreach (static::$hasMany as $member => $rel) {
|
foreach (static::$hasMany as $member => $rel) {
|
||||||
if (isset($rel['self']) || !isset($rel['column'])) {
|
if (isset($rel['self']) || !isset($rel['column'])) { // @todo: conflict with getHasMany()???!?!?!?!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3363,6 +3363,7 @@ INSERT INTO `tag_l11n` (`tag_l11n_id`, `tag_l11n_tag`, `tag_l11n_title`, `tag_l1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* C1: conditional values with priorities
|
/* C1: conditional values with priorities
|
||||||
|
https://dbfiddle.uk/?rdbms=mariadb_10.4&fiddle=54359372c3481cfee85f423af76665e4
|
||||||
SELECT
|
SELECT
|
||||||
`tag_3`.`tag_id` as tag_id_3, `tag_3`.`tag_bla` as tag_bla_3,
|
`tag_3`.`tag_id` as tag_id_3, `tag_3`.`tag_bla` as tag_bla_3,
|
||||||
`tag_l11n_2`.`tag_l11n_title` as tag_l11n_title_2, `tag_l11n_2`.`tag_l11n_language`
|
`tag_l11n_2`.`tag_l11n_title` as tag_l11n_title_2, `tag_l11n_2`.`tag_l11n_language`
|
||||||
|
|
@ -3390,3 +3391,23 @@ ORDER BY
|
||||||
`tag_3`.`tag_id` ASC
|
`tag_3`.`tag_id` ASC
|
||||||
LIMIT 25;
|
LIMIT 25;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* C2: try this
|
||||||
|
SELECT
|
||||||
|
`tag_3`.`tag_id` as tag_id_3,
|
||||||
|
COALESCE(`tag_l11n_2`.`tag_l11n_title`, `tag_l11n_3`.`tag_l11n_title`, `tag_l11n_4`.`tag_l11n_title`) as tag_l11n_title_2
|
||||||
|
FROM
|
||||||
|
`tag` as tag_3
|
||||||
|
LEFT JOIN
|
||||||
|
`tag_l11n` as tag_l11n_2 ON `tag_3`.`tag_id` = `tag_l11n_2`.`tag_l11n_tag`
|
||||||
|
AND `tag_l11n_2`.`tag_l11n_language` = 'it'
|
||||||
|
LEFT JOIN
|
||||||
|
`tag_l11n` as tag_l11n_3 ON `tag_3`.`tag_id` = `tag_l11n_3`.`tag_l11n_tag`
|
||||||
|
AND `tag_l11n_3`.`tag_l11n_language` = 'en'
|
||||||
|
LEFT JOIN
|
||||||
|
`tag_l11n` as tag_l11n_4 ON `tag_3`.`tag_id` = `tag_l11n_4`.`tag_l11n_tag`
|
||||||
|
AND `tag_l11n_4`.`tag_l11n_language` NOT IN ('en', 'it')
|
||||||
|
ORDER BY
|
||||||
|
`tag_3`.`tag_id` ASC
|
||||||
|
LIMIT 25;
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -52,122 +52,114 @@ class MysqlConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database type throws a InvalidConnectionConfigException
|
* @testdox A missing database type returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseType() : void
|
public function testInvalidDatabaseType() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
unset($db['db']);
|
unset($db['db']);
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database host throws a InvalidConnectionConfigException
|
* @testdox A missing database host returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidHost() : void
|
public function testInvalidHost() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
unset($db['host']);
|
unset($db['host']);
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database port throws a InvalidConnectionConfigException
|
* @testdox A missing database port returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidPort() : void
|
public function testInvalidPort() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
unset($db['port']);
|
unset($db['port']);
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database throws a InvalidConnectionConfigException
|
* @testdox A missing database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabase() : void
|
public function testInvalidDatabase() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
unset($db['database']);
|
unset($db['database']);
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database login throws a InvalidConnectionConfigException
|
* @testdox A missing database login returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidLogin() : void
|
public function testInvalidLogin() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
unset($db['login']);
|
unset($db['login']);
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database password throws a InvalidConnectionConfigException
|
* @testdox A missing database password returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidPassword() : void
|
public function testInvalidPassword() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
unset($db['password']);
|
unset($db['password']);
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A invalid database type throws a InvalidConnectionConfigException
|
* @testdox A invalid database type returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseTypeName() : void
|
public function testInvalidDatabaseTypeName() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
$db['db'] = 'invalid';
|
$db['db'] = 'invalid';
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A invalid database throws a InvalidConnectionConfigException
|
* @testdox A invalid database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
* @covers phpOMS\DataStorage\Database\Connection\MysqlConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseName() : void
|
public function testInvalidDatabaseName() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
$db['database'] = 'invalid';
|
$db['database'] = 'invalid';
|
||||||
|
|
||||||
$mysql = new MysqlConnection($db);
|
$mysql = new MysqlConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $mysql->getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,100 +50,93 @@ class PostgresConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database type throws a InvalidConnectionConfigException
|
* @testdox A missing database type returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseType() : void
|
public function testInvalidDatabaseType() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
unset($db['db']);
|
unset($db['db']);
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database host throws a InvalidConnectionConfigException
|
* @testdox A missing database host returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidHost() : void
|
public function testInvalidHost() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
unset($db['host']);
|
unset($db['host']);
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database port throws a InvalidConnectionConfigException
|
* @testdox A missing database port returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidPort() : void
|
public function testInvalidPort() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
unset($db['port']);
|
unset($db['port']);
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database throws a InvalidConnectionConfigException
|
* @testdox A missing database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabase() : void
|
public function testInvalidDatabase() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
unset($db['database']);
|
unset($db['database']);
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database login throws a InvalidConnectionConfigException
|
* @testdox A missing database login returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidLogin() : void
|
public function testInvalidLogin() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
unset($db['login']);
|
unset($db['login']);
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database password throws a InvalidConnectionConfigException
|
* @testdox A missing database password returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidPassword() : void
|
public function testInvalidPassword() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
unset($db['password']);
|
unset($db['password']);
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A invalid database type throws a InvalidConnectionConfigException
|
* @testdox A invalid database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
* @covers phpOMS\DataStorage\Database\Connection\PostgresConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseTypeName() : void
|
public function testInvalidDatabaseTypeName() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||||
$db['db'] = 'invalid';
|
$db['db'] = 'invalid';
|
||||||
$psql = new PostgresConnection($db);
|
$psql = new PostgresConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $psql->getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,31 +48,29 @@ class SQLiteConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database type throws a InvalidConnectionConfigException
|
* @testdox A missing database type returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseType() : void
|
public function testInvalidDatabaseType() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['sqlite']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['sqlite']['admin'];
|
||||||
unset($db['db']);
|
unset($db['db']);
|
||||||
$sqlite = new SQLiteConnection($db);
|
$sqlite = new SQLiteConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $sqlite->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database throws a InvalidConnectionConfigException
|
* @testdox A missing database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabase() : void
|
public function testInvalidDatabase() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['sqlite']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['sqlite']['admin'];
|
||||||
unset($db['database']);
|
unset($db['database']);
|
||||||
$sqlite = new SQLiteConnection($db);
|
$sqlite = new SQLiteConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $sqlite->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass() : void
|
public static function tearDownAfterClass() : void
|
||||||
|
|
|
||||||
|
|
@ -51,115 +51,106 @@ class SqlServerConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database type throws a InvalidConnectionConfigException
|
* @testdox A missing database type returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseType() : void
|
public function testInvalidDatabaseType() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
unset($db['db']);
|
unset($db['db']);
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database host throws a InvalidConnectionConfigException
|
* @testdox A missing database host returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidHost() : void
|
public function testInvalidHost() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
unset($db['host']);
|
unset($db['host']);
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database port throws a InvalidConnectionConfigException
|
* @testdox A missing database port returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidPort() : void
|
public function testInvalidPort() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
unset($db['port']);
|
unset($db['port']);
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database throws a InvalidConnectionConfigException
|
* @testdox A missing database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabase() : void
|
public function testInvalidDatabase() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
unset($db['database']);
|
unset($db['database']);
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database login throws a InvalidConnectionConfigException
|
* @testdox A missing database login returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidLogin() : void
|
public function testInvalidLogin() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
unset($db['login']);
|
unset($db['login']);
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database password throws a InvalidConnectionConfigException
|
* @testdox A missing database password returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidPassword() : void
|
public function testInvalidPassword() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
unset($db['password']);
|
unset($db['password']);
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A invalid database type throws a InvalidConnectionConfigException
|
* @testdox A invalid database type returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseTypeName() : void
|
public function testInvalidDatabaseTypeName() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||||
$db['db'] = 'invalid';
|
$db['db'] = 'invalid';
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A invalid database throws a InvalidConnectionConfigException
|
* @testdox A invalid database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SqlServerConnection
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatabaseName() : void
|
public function testInvalidDatabaseName() : void
|
||||||
{
|
{
|
||||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
|
||||||
|
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
|
||||||
$db['database'] = 'invalid';
|
$db['database'] = 'invalid';
|
||||||
|
|
||||||
$ssql = new SqlServerConnection($db);
|
$ssql = new SqlServerConnection($db);
|
||||||
|
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user