From bbc4e647154f1173ed5cd945103a7c5aa5c72e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D?= Date: Sun, 10 Mar 2024 16:12:05 +0100 Subject: [PATCH] chore(tests): UT for PluginData repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rubén D --- .../Plugin/Repositories/PluginData.php | 4 ++++ .../Plugin/Repositories/PluginDataTest.php | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/SP/Infrastructure/Plugin/Repositories/PluginData.php b/lib/SP/Infrastructure/Plugin/Repositories/PluginData.php index c6ad1c67..86f996d4 100644 --- a/lib/SP/Infrastructure/Plugin/Repositories/PluginData.php +++ b/lib/SP/Infrastructure/Plugin/Repositories/PluginData.php @@ -184,6 +184,10 @@ final class PluginData extends BaseRepository implements PluginDataRepository */ public function getByNameBatch(array $names): QueryResult { + if (count($names) === 0) { + return new QueryResult(); + } + $query = $this->queryFactory ->newSelect() ->from(self::TABLE) diff --git a/tests/SPT/Infrastructure/Plugin/Repositories/PluginDataTest.php b/tests/SPT/Infrastructure/Plugin/Repositories/PluginDataTest.php index a1eb1eb0..6916f206 100644 --- a/tests/SPT/Infrastructure/Plugin/Repositories/PluginDataTest.php +++ b/tests/SPT/Infrastructure/Plugin/Repositories/PluginDataTest.php @@ -213,6 +213,15 @@ class PluginDataTest extends UnitaryTestCase $this->pluginData->getByNameBatch($names); } + public function testGetByNameBatchWithNoNames() + { + $this->database + ->expects(self::never()) + ->method('doSelect'); + + $this->pluginData->getByNameBatch([]); + } + /** * @throws ConstraintException * @throws QueryException @@ -244,6 +253,19 @@ class PluginDataTest extends UnitaryTestCase $this->pluginData->deleteByNameBatch($names); } + /** + * @throws ConstraintException + * @throws QueryException + */ + public function testDeleteByNameBatchWithNoNames() + { + $this->database + ->expects(self::never()) + ->method('doQuery'); + + $this->pluginData->deleteByNameBatch([]); + } + public function testGetByItemId() { $callback = new Callback(