Fixed test errors

This commit is contained in:
Jan Böhmer 2025-01-03 20:21:17 +01:00
parent afc1dbdd4b
commit 9c99217dee

View file

@ -37,6 +37,7 @@ use App\Entity\Parts\Supplier;
use App\Entity\PriceInformations\Currency;
use App\Entity\PriceInformations\Orderdetail;
use App\Entity\PriceInformations\Pricedetail;
use App\Repository\Parts\CategoryRepository;
use App\Services\InfoProviderSystem\DTOs\FileDTO;
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
@ -158,7 +159,11 @@ final class DTOtoEntityConverter
$entity->setMass($dto->mass);
//Try to map the category to an existing entity (but never create a new one)
$entity->setCategory($this->em->getRepository(Category::class)->findForInfoProvider($dto->category));
if ($dto->category) {
/** @var CategoryRepository<Category> $categoryRepo */
$categoryRepo = $this->em->getRepository(Category::class);
$entity->setCategory($categoryRepo->findForInfoProvider($dto->category));
}
$entity->setManufacturer($this->getOrCreateEntity(Manufacturer::class, $dto->manufacturer));
$entity->setFootprint($this->getOrCreateEntity(Footprint::class, $dto->footprint));