From 81bb1c5268e5475b39b94a8dfd4d282a996d6c6a Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Mon, 10 Feb 2025 08:15:20 +0100 Subject: [PATCH] refs #1480. Fixed test --- src/Dto/Input/ImageInput.php | 3 ++- src/Entity/Image.php | 4 ++-- tests/Functional/ImageTest.php | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Dto/Input/ImageInput.php b/src/Dto/Input/ImageInput.php index 844d0de..e2ac465 100644 --- a/src/Dto/Input/ImageInput.php +++ b/src/Dto/Input/ImageInput.php @@ -132,9 +132,10 @@ final class ImageInput foreach ($this->imageRepositories as $repository) { $repositoriesToAdd[] = $repository->getEntity(); } + } else { + $repositoriesToAdd[] = $image->getClient()?->getRepository(); } - $repositoriesToAdd[] = $image->getClient()?->getRepository(); $image->setRepositories( $repositoriesToAdd ?? [] ); $image->setRemotePc($this->remotePc); diff --git a/src/Entity/Image.php b/src/Entity/Image.php index 453d20c..c8a326b 100644 --- a/src/Entity/Image.php +++ b/src/Entity/Image.php @@ -191,7 +191,7 @@ class Image extends AbstractEntity return $this->repositories; } - public function setRepositories(?array $repositories = []): static + public function setRepositories(array $repositories): static { $this->repositories->clear(); @@ -202,7 +202,7 @@ class Image extends AbstractEntity return $this; } - public function addRepository(?\App\Entity\ImageRepository $repository): static + public function addRepository(\App\Entity\ImageRepository $repository): static { if (!$this->repositories->contains($repository)) { $this->repositories->add($repository); diff --git a/tests/Functional/ImageTest.php b/tests/Functional/ImageTest.php index 028a83e..9b323c7 100644 --- a/tests/Functional/ImageTest.php +++ b/tests/Functional/ImageTest.php @@ -56,7 +56,13 @@ class ImageTest extends AbstractTest } - /* + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ public function testCreateImage(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); @@ -82,6 +88,13 @@ class ImageTest extends AbstractTest } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ public function testUpdateImage(): void { UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); @@ -102,7 +115,6 @@ class ImageTest extends AbstractTest 'name' => self::IMAGE_UPDATE, ]); } - */ /** * @throws TransportExceptionInterface