From 1b9aa4a83b7dca8f6e6077401a85bcee460dd5b6 Mon Sep 17 00:00:00 2001 From: Nick Amoscato <nick.amoscato@jazz.co> Date: Sun, 19 Nov 2017 12:57:28 -0500 Subject: [PATCH] Move Doctrine driver to new namespace --- doc/drivers.rst | 4 ++-- example/doctrine.php | 4 ++-- .../{DoctrineDriver.php => Doctrine/Driver.php} | 8 ++++---- .../AbstractDriverTest.php} | 14 +++++++------- .../MySQLDriverTest.php} | 8 ++------ .../PostgreSQLDriverTest.php} | 8 ++------ .../SQLiteDriverTest.php} | 8 ++------ 7 files changed, 21 insertions(+), 33 deletions(-) rename src/Driver/{DoctrineDriver.php => Doctrine/Driver.php} (96%) rename tests/Driver/{AbstractDoctrineDriverTest.php => Doctrine/AbstractDriverTest.php} (94%) rename tests/Driver/{MySQLDoctrineDriverTest.php => Doctrine/MySQLDriverTest.php} (78%) rename tests/Driver/{PostgreSQLDoctrineDriverTest.php => Doctrine/PostgreSQLDriverTest.php} (76%) rename tests/Driver/{SQLiteDoctrineDriverTest.php => Doctrine/SQLiteDriverTest.php} (74%) diff --git a/doc/drivers.rst b/doc/drivers.rst index 23e15a77..18f37c95 100644 --- a/doc/drivers.rst +++ b/doc/drivers.rst @@ -175,7 +175,7 @@ And here is the setup of the driver for doctrine dbal: <?php - use Bernard\Driver\DoctrineDriver; + use Bernard\Driver\Doctrine\Driver; use Doctrine\DBAL\DriverManager; $connection = DriverManager::getConnection(array( @@ -186,7 +186,7 @@ And here is the setup of the driver for doctrine dbal: )); - $driver = new DoctrineDriver($connection); + $driver = new Driver($connection); Flatfile -------- diff --git a/example/doctrine.php b/example/doctrine.php index 554b732a..c803b2c4 100644 --- a/example/doctrine.php +++ b/example/doctrine.php @@ -1,6 +1,6 @@ <?php -use Bernard\Driver\DoctrineDriver; +use Bernard\Driver\Doctrine\Driver; use Doctrine\DBAL\DriverManager; /** @@ -16,7 +16,7 @@ function get_driver() { 'driver' => 'pdo_mysql', )); - $doctrineDriver = new DoctrineDriver($connection); + $doctrineDriver = new Driver($connection); //Don't do this in your application. Use a database set up script instead. try { diff --git a/src/Driver/DoctrineDriver.php b/src/Driver/Doctrine/Driver.php similarity index 96% rename from src/Driver/DoctrineDriver.php rename to src/Driver/Doctrine/Driver.php index bcc48fbf..f6fb27b8 100644 --- a/src/Driver/DoctrineDriver.php +++ b/src/Driver/Doctrine/Driver.php @@ -1,6 +1,6 @@ <?php -namespace Bernard\Driver; +namespace Bernard\Driver\Doctrine; use Doctrine\DBAL\Connection; @@ -9,9 +9,9 @@ * * @package Bernard */ -class DoctrineDriver implements \Bernard\Driver +final class Driver implements \Bernard\Driver { - protected $connection; + private $connection; /** * {@inheritdoc} @@ -154,7 +154,7 @@ public function info() * * @return array|null */ - protected function doPopMessage($queueName) + private function doPopMessage($queueName) { $query = 'SELECT id, message FROM bernard_messages WHERE queue = :queue AND visible = :visible diff --git a/tests/Driver/AbstractDoctrineDriverTest.php b/tests/Driver/Doctrine/AbstractDriverTest.php similarity index 94% rename from tests/Driver/AbstractDoctrineDriverTest.php rename to tests/Driver/Doctrine/AbstractDriverTest.php index 1ec32747..4c08ca5a 100644 --- a/tests/Driver/AbstractDoctrineDriverTest.php +++ b/tests/Driver/Doctrine/AbstractDriverTest.php @@ -1,13 +1,13 @@ <?php -namespace Bernard\Tests\Driver; +namespace Bernard\Tests\Driver\Doctrine; use Bernard\Doctrine\MessagesSchema; -use Bernard\Driver\DoctrineDriver; +use Bernard\Driver\Doctrine\Driver; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Schema; -abstract class AbstractDoctrineDriverTest extends \PHPUnit\Framework\TestCase +abstract class AbstractDriverTest extends \PHPUnit\Framework\TestCase { /** * @var \Doctrine\DBAL\Connection @@ -15,7 +15,7 @@ abstract class AbstractDoctrineDriverTest extends \PHPUnit\Framework\TestCase private $connection; /** - * @var DoctrineDriver + * @var Driver */ protected $driver; @@ -30,7 +30,7 @@ public function setUp() } $this->setUpDatabase(); - $this->driver = new DoctrineDriver($this->connection); + $this->driver = new Driver($this->connection); } protected function tearDown() @@ -171,10 +171,10 @@ protected function setUpDatabase() /** * @return \Doctrine\DBAL\Connection */ - protected abstract function createConnection(); + abstract protected function createConnection(); /** * @return bool */ - protected abstract function isSupported(); + abstract protected function isSupported(); } diff --git a/tests/Driver/MySQLDoctrineDriverTest.php b/tests/Driver/Doctrine/MySQLDriverTest.php similarity index 78% rename from tests/Driver/MySQLDoctrineDriverTest.php rename to tests/Driver/Doctrine/MySQLDriverTest.php index 05ce3c21..993ab17c 100644 --- a/tests/Driver/MySQLDoctrineDriverTest.php +++ b/tests/Driver/Doctrine/MySQLDriverTest.php @@ -1,17 +1,13 @@ <?php -namespace Bernard\Tests\Driver; - -use Bernard\Doctrine\MessagesSchema; -use Bernard\Driver\DoctrineDriver; +namespace Bernard\Tests\Driver\Doctrine; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Schema\Schema; /** * @group functional */ -class MySQLDoctrineDriverTest extends AbstractDoctrineDriverTest +class MySQLDriverTest extends AbstractDriverTest { protected function isSupported() { diff --git a/tests/Driver/PostgreSQLDoctrineDriverTest.php b/tests/Driver/Doctrine/PostgreSQLDriverTest.php similarity index 76% rename from tests/Driver/PostgreSQLDoctrineDriverTest.php rename to tests/Driver/Doctrine/PostgreSQLDriverTest.php index 6e0b60a6..dbf72b08 100644 --- a/tests/Driver/PostgreSQLDoctrineDriverTest.php +++ b/tests/Driver/Doctrine/PostgreSQLDriverTest.php @@ -1,17 +1,13 @@ <?php -namespace Bernard\Tests\Driver; - -use Bernard\Doctrine\MessagesSchema; -use Bernard\Driver\DoctrineDriver; +namespace Bernard\Tests\Driver\Doctrine; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Schema\Schema; /** * @group functional */ -class PostgreSQLDoctrineDriverTest extends AbstractDoctrineDriverTest +class PostgreSQLDriverTest extends AbstractDriverTest { protected function isSupported() { diff --git a/tests/Driver/SQLiteDoctrineDriverTest.php b/tests/Driver/Doctrine/SQLiteDriverTest.php similarity index 74% rename from tests/Driver/SQLiteDoctrineDriverTest.php rename to tests/Driver/Doctrine/SQLiteDriverTest.php index f12fb422..b4bcf66f 100644 --- a/tests/Driver/SQLiteDoctrineDriverTest.php +++ b/tests/Driver/Doctrine/SQLiteDriverTest.php @@ -1,17 +1,13 @@ <?php -namespace Bernard\Tests\Driver; - -use Bernard\Doctrine\MessagesSchema; -use Bernard\Driver\DoctrineDriver; +namespace Bernard\Tests\Driver\Doctrine; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Schema\Schema; /** * @group functional */ -class SQLiteDoctrineDriverTest extends AbstractDoctrineDriverTest +class SQLiteDriverTest extends AbstractDriverTest { protected function isSupported() {