Refactored Database.

This commit is contained in:
Dmitry Khomutov 2018-03-04 15:34:19 +07:00
parent 8b5a874789
commit e23ad3237a
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
16 changed files with 26 additions and 25 deletions

View file

@ -4,6 +4,7 @@ namespace b8;
use b8\Http\Request; use b8\Http\Request;
use b8\Http\Response; use b8\Http\Response;
use PHPCensor\View;
abstract class Controller abstract class Controller
{ {

View file

@ -1,6 +1,8 @@
<?php <?php
namespace b8; namespace PHPCensor;
use b8\Config;
class Database extends \PDO class Database extends \PDO
{ {
@ -76,7 +78,7 @@ class Database extends \PDO
/** /**
* @param string $type * @param string $type
* *
* @return \b8\Database * @return Database
* *
* @throws \Exception * @throws \Exception
*/ */

View file

@ -6,7 +6,7 @@ use PDO;
use PHPCensor\Builder; use PHPCensor\Builder;
use PHPCensor\Model\Build; use PHPCensor\Model\Build;
use PHPCensor\Plugin; use PHPCensor\Plugin;
use b8\Database; use PHPCensor\Database;
/** /**
* MySQL Plugin - Provides access to a MySQL database. * MySQL Plugin - Provides access to a MySQL database.

View file

@ -2,8 +2,6 @@
namespace PHPCensor; namespace PHPCensor;
use b8\Database;
abstract class Store abstract class Store
{ {
/** /**

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Model\BuildError; use PHPCensor\Model\BuildError;
use b8\Exception\HttpException; use b8\Exception\HttpException;
use PHPCensor\Store; use PHPCensor\Store;

View file

@ -3,7 +3,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use b8\Config; use b8\Config;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Model\BuildError; use PHPCensor\Model\BuildError;
/** /**

View file

@ -3,7 +3,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use PHPCensor\Store; use PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Model\BuildMeta; use PHPCensor\Model\BuildMeta;
use b8\Exception\HttpException; use b8\Exception\HttpException;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Model\Build; use PHPCensor\Model\Build;
use b8\Exception\HttpException; use b8\Exception\HttpException;
use PHPCensor\Model\BuildMeta; use PHPCensor\Model\BuildMeta;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Model\Environment; use PHPCensor\Model\Environment;
use PHPCensor\Store; use PHPCensor\Store;
use b8\Exception\HttpException; use b8\Exception\HttpException;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use b8\Exception\HttpException; use b8\Exception\HttpException;
use PHPCensor\Store; use PHPCensor\Store;
use PHPCensor\Model\ProjectGroup; use PHPCensor\Model\ProjectGroup;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Model\Project; use PHPCensor\Model\Project;
use PHPCensor\Store; use PHPCensor\Store;
use b8\Exception\HttpException; use b8\Exception\HttpException;

View file

@ -3,7 +3,7 @@
namespace PHPCensor\Store; namespace PHPCensor\Store;
use PHPCensor\Store; use PHPCensor\Store;
use b8\Database; use PHPCensor\Database;
use b8\Exception\HttpException; use b8\Exception\HttpException;
use PHPCensor\Model\User; use PHPCensor\Model\User;

View file

@ -3,7 +3,7 @@
namespace Tests\b8; namespace Tests\b8;
use b8\Config; use b8\Config;
use b8\Database; use PHPCensor\Database;
class DatabaseMysqlTest extends \PHPUnit_Extensions_Database_TestCase class DatabaseMysqlTest extends \PHPUnit_Extensions_Database_TestCase
{ {
@ -117,8 +117,8 @@ class DatabaseMysqlTest extends \PHPUnit_Extensions_Database_TestCase
$writeConnection = Database::getConnection('write'); $writeConnection = Database::getConnection('write');
$readConnection = Database::getConnection('read'); $readConnection = Database::getConnection('read');
self::assertInstanceOf('\b8\Database', $writeConnection); self::assertInstanceOf('\PHPCensor\Database', $writeConnection);
self::assertInstanceOf('\b8\Database', $readConnection); self::assertInstanceOf('\PHPCensor\Database', $readConnection);
$writeDetails = $writeConnection->getDetails(); $writeDetails = $writeConnection->getDetails();
@ -168,8 +168,8 @@ class DatabaseMysqlTest extends \PHPUnit_Extensions_Database_TestCase
$writeConnection = Database::getConnection('write'); $writeConnection = Database::getConnection('write');
$readConnection = Database::getConnection('read'); $readConnection = Database::getConnection('read');
self::assertInstanceOf('\b8\Database', $writeConnection); self::assertInstanceOf('\PHPCensor\Database', $writeConnection);
self::assertInstanceOf('\b8\Database', $readConnection); self::assertInstanceOf('\PHPCensor\Database', $readConnection);
self::assertEquals('mysql:host=localhost;port=3306;dbname=b8_test', $readConnection->getDsn()); self::assertEquals('mysql:host=localhost;port=3306;dbname=b8_test', $readConnection->getDsn());
} }

View file

@ -3,7 +3,7 @@
namespace Tests\b8; namespace Tests\b8;
use b8\Config; use b8\Config;
use b8\Database; use PHPCensor\Database;
class DatabasePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase class DatabasePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase
{ {
@ -117,8 +117,8 @@ class DatabasePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase
$writeConnection = Database::getConnection('write'); $writeConnection = Database::getConnection('write');
$readConnection = Database::getConnection('read'); $readConnection = Database::getConnection('read');
self::assertInstanceOf('\b8\Database', $writeConnection); self::assertInstanceOf('\PHPCensor\Database', $writeConnection);
self::assertInstanceOf('\b8\Database', $readConnection); self::assertInstanceOf('\PHPCensor\Database', $readConnection);
$writeDetails = $writeConnection->getDetails(); $writeDetails = $writeConnection->getDetails();
@ -168,8 +168,8 @@ class DatabasePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase
$writeConnection = Database::getConnection('write'); $writeConnection = Database::getConnection('write');
$readConnection = Database::getConnection('read'); $readConnection = Database::getConnection('read');
self::assertInstanceOf('\b8\Database', $writeConnection); self::assertInstanceOf('\PHPCensor\Database', $writeConnection);
self::assertInstanceOf('\b8\Database', $readConnection); self::assertInstanceOf('\PHPCensor\Database', $readConnection);
self::assertEquals('pgsql:host=localhost;port=5432;dbname=b8_test', $readConnection->getDsn()); self::assertEquals('pgsql:host=localhost;port=5432;dbname=b8_test', $readConnection->getDsn());
} }

View file

@ -3,7 +3,7 @@
namespace Tests\PHPCensor; namespace Tests\PHPCensor;
use b8\Config; use b8\Config;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Store\Factory; use PHPCensor\Store\Factory;
use PHPCensor\Model\Project; use PHPCensor\Model\Project;
use PHPCensor\Model\ProjectGroup; use PHPCensor\Model\ProjectGroup;

View file

@ -3,7 +3,7 @@
namespace Tests\PHPCensor; namespace Tests\PHPCensor;
use b8\Config; use b8\Config;
use b8\Database; use PHPCensor\Database;
use PHPCensor\Store\Factory; use PHPCensor\Store\Factory;
use PHPCensor\Model\Project; use PHPCensor\Model\Project;
use PHPCensor\Model\ProjectGroup; use PHPCensor\Model\ProjectGroup;