mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-24 15:18:40 +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'])
|
||||
) {
|
||||
$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();
|
||||
|
|
@ -82,7 +85,6 @@ final class MysqlConnection extends ConnectionAbstract
|
|||
} catch (\PDOException $e) {
|
||||
unset($this->con);
|
||||
$this->status = DatabaseStatus::MISSING_DATABASE;
|
||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||
} finally {
|
||||
$this->dbdata['password'] = '****';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,10 @@ final class PostgresConnection extends ConnectionAbstract
|
|||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||
) {
|
||||
$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();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,10 @@ final class SQLiteConnection extends ConnectionAbstract
|
|||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||
) {
|
||||
$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();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,10 @@ final class SqlServerConnection extends ConnectionAbstract
|
|||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||
) {
|
||||
$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();
|
||||
|
|
|
|||
|
|
@ -2960,7 +2960,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$cachedTables = []; // used by conditionals
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -3080,7 +3080,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
// get HasManyQuery (but only for elements which have a 'column' defined)
|
||||
if ($depth > 1 && $relations === RelationType::ALL) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -3363,6 +3363,7 @@ INSERT INTO `tag_l11n` (`tag_l11n_id`, `tag_l11n_tag`, `tag_l11n_title`, `tag_l1
|
|||
*/
|
||||
|
||||
/* C1: conditional values with priorities
|
||||
https://dbfiddle.uk/?rdbms=mariadb_10.4&fiddle=54359372c3481cfee85f423af76665e4
|
||||
SELECT
|
||||
`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`
|
||||
|
|
@ -3390,3 +3391,23 @@ ORDER BY
|
|||
`tag_3`.`tag_id` ASC
|
||||
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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseType() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
unset($db['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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidHost() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
unset($db['host']);
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidPort() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
unset($db['port']);
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabase() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
unset($db['database']);
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidLogin() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
unset($db['login']);
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidPassword() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
unset($db['password']);
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseTypeName() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
$db['db'] = 'invalid';
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseName() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||
$db['database'] = 'invalid';
|
||||
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseType() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
unset($db['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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidHost() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
unset($db['host']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidPort() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
unset($db['port']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabase() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
unset($db['database']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidLogin() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
unset($db['login']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidPassword() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
unset($db['password']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseTypeName() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['postgresql']['admin'];
|
||||
$db['db'] = 'invalid';
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseType() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['sqlite']['admin'];
|
||||
unset($db['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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabase() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['sqlite']['admin'];
|
||||
unset($db['database']);
|
||||
$sqlite = new SQLiteConnection($db);
|
||||
self::assertEquals(DatabaseStatus::FAILURE, $sqlite->getStatus());
|
||||
}
|
||||
|
||||
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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseType() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
unset($db['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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidHost() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
unset($db['host']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidPort() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
unset($db['port']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabase() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
unset($db['database']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidLogin() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
unset($db['login']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidPassword() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
unset($db['password']);
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseTypeName() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
$db['db'] = 'invalid';
|
||||
$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
|
||||
* @group framework
|
||||
*/
|
||||
public function testInvalidDatabaseName() : void
|
||||
{
|
||||
self::expectException(\phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException::class);
|
||||
|
||||
$db = $GLOBALS['CONFIG']['db']['core']['mssql']['admin'];
|
||||
$db['database'] = 'invalid';
|
||||
|
||||
$ssql = new SqlServerConnection($db);
|
||||
self::assertEquals(DatabaseStatus::FAILURE, $ssql->getStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user