mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 22:18:40 +00:00
get overall coverage to 76%
This commit is contained in:
parent
2cfcb24742
commit
892788ece2
|
|
@ -82,6 +82,10 @@ final class SQLiteConnection extends ConnectionAbstract
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!\is_file($this->dbdata['database'])) {
|
||||||
|
throw new \PDOException();
|
||||||
|
}
|
||||||
|
|
||||||
$this->con = new \PDO($this->dbdata['db'] . ':' . $this->dbdata['database']);
|
$this->con = new \PDO($this->dbdata['db'] . ':' . $this->dbdata['database']);
|
||||||
$this->con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
|
$this->con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
|
||||||
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
$this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
|
||||||
|
|
@ -148,37 +148,37 @@ $CONFIG = [
|
||||||
'sqlite' => [
|
'sqlite' => [
|
||||||
'admin' => [
|
'admin' => [
|
||||||
'db' => 'sqlite', /* db type */
|
'db' => 'sqlite', /* db type */
|
||||||
'database' => __DIR__ . '/test.sqlite', /* db name */
|
'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */
|
||||||
'weight' => 1000, /* db table prefix */
|
'weight' => 1000, /* db table prefix */
|
||||||
'datetimeformat' => 'Y-m-d H:i:s',
|
'datetimeformat' => 'Y-m-d H:i:s',
|
||||||
],
|
],
|
||||||
'insert' => [
|
'insert' => [
|
||||||
'db' => 'sqlite', /* db type */
|
'db' => 'sqlite', /* db type */
|
||||||
'database' => __DIR__ . '/test.sqlite', /* db name */
|
'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */
|
||||||
'weight' => 1000, /* db table prefix */
|
'weight' => 1000, /* db table prefix */
|
||||||
'datetimeformat' => 'Y-m-d H:i:s',
|
'datetimeformat' => 'Y-m-d H:i:s',
|
||||||
],
|
],
|
||||||
'select' => [
|
'select' => [
|
||||||
'db' => 'sqlite', /* db type */
|
'db' => 'sqlite', /* db type */
|
||||||
'database' => __DIR__ . '/test.sqlite', /* db name */
|
'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */
|
||||||
'weight' => 1000, /* db table prefix */
|
'weight' => 1000, /* db table prefix */
|
||||||
'datetimeformat' => 'Y-m-d H:i:s',
|
'datetimeformat' => 'Y-m-d H:i:s',
|
||||||
],
|
],
|
||||||
'update' => [
|
'update' => [
|
||||||
'db' => 'sqlite', /* db type */
|
'db' => 'sqlite', /* db type */
|
||||||
'database' => __DIR__ . '/test.sqlite', /* db name */
|
'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */
|
||||||
'weight' => 1000, /* db table prefix */
|
'weight' => 1000, /* db table prefix */
|
||||||
'datetimeformat' => 'Y-m-d H:i:s',
|
'datetimeformat' => 'Y-m-d H:i:s',
|
||||||
],
|
],
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'db' => 'sqlite', /* db type */
|
'db' => 'sqlite', /* db type */
|
||||||
'database' => __DIR__ . '/test.sqlite', /* db name */
|
'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */
|
||||||
'weight' => 1000, /* db table prefix */
|
'weight' => 1000, /* db table prefix */
|
||||||
'datetimeformat' => 'Y-m-d H:i:s',
|
'datetimeformat' => 'Y-m-d H:i:s',
|
||||||
],
|
],
|
||||||
'schema' => [
|
'schema' => [
|
||||||
'db' => 'sqlite', /* db type */
|
'db' => 'sqlite', /* db type */
|
||||||
'database' => __DIR__ . '/test.sqlite', /* db name */
|
'database' => __DIR__ . '/../Localization/Defaults/localization.sqlite', /* db name */
|
||||||
'weight' => 1000, /* db table prefix */
|
'weight' => 1000, /* db table prefix */
|
||||||
'datetimeformat' => 'Y-m-d H:i:s',
|
'datetimeformat' => 'Y-m-d H:i:s',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,21 @@ final class SQLiteConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(DatabaseStatus::FAILURE, $sqlite->getStatus());
|
self::assertEquals(DatabaseStatus::FAILURE, $sqlite->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @testdox Valid sqlite connection data result in a valid database connection
|
||||||
|
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection<extended>
|
||||||
|
* @group framework
|
||||||
|
*/
|
||||||
|
public function testInvalidDatabasePath() : void
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
$db['database'] = 'invalid.sqlite';
|
||||||
|
|
||||||
|
$sqlite = new SQLiteConnection($db);
|
||||||
|
$sqlite->connect();
|
||||||
|
self::assertEquals(DatabaseStatus::MISSING_DATABASE, $sqlite->getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A missing database returns a failure
|
* @testdox A missing database returns a failure
|
||||||
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection
|
* @covers phpOMS\DataStorage\Database\Connection\SQLiteConnection
|
||||||
|
|
@ -86,15 +101,17 @@ final class SQLiteConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
$db['database'] = 'invalid';
|
$db['database'] = 'invalid';
|
||||||
|
|
||||||
$mysql = new SQLiteConnection($db);
|
$sqlite = new SQLiteConnection($db);
|
||||||
$mysql->connect();
|
$sqlite->connect();
|
||||||
self::assertEquals(DatabaseStatus::MISSING_DATABASE, $mysql->getStatus());
|
self::assertEquals(DatabaseStatus::MISSING_DATABASE, $sqlite->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public static function tearDownAfterClass() : void
|
public static function tearDownAfterClass() : void
|
||||||
{
|
{
|
||||||
if (\is_file($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database'])) {
|
if (\is_file($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database'])) {
|
||||||
\unlink($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database']);
|
\unlink($GLOBALS['CONFIG']['db']['core']['sqlite']['admin']['database']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user