From 68463559b8cb0a9e608c53a8387794ce2d0cd8ea Mon Sep 17 00:00:00 2001 From: Manuel Kress <6232639+windaishi@users.noreply.github.com> Date: Tue, 13 Oct 2020 15:03:45 +0200 Subject: [PATCH] Class Query should not be final We use your nice little package in our project. We added it to our Dependency Injection container as a service. Unfortunately the class `Query` is final. Therefore we can't create mocks for it and therefore can't unit test classes that depend on this service. Example: ``` bulkInserterMock = $this->createMock(Query::class); $this->csvToDatabaseReader = new CsvToDatabaseReader($this->bulkInserterMock); } public function test_readChunk() { $this->csvToDatabaseReader->readChunk(); } } ``` Leads to: ``` Class "Franzose\DoctrineBulkInsert\Query" is declared "final" and cannot be mocked. .../vendor/phpunit/phpunit/src/TextUI/Command.php:204 .../vendor/phpunit/phpunit/src/TextUI/Command.php:163 ``` Also I think there is no reason, this should be final. --- src/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Query.php b/src/Query.php index 109ada1..a614067 100644 --- a/src/Query.php +++ b/src/Query.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Schema\Identifier; -final class Query +class Query { private $connection;