diff --git a/src/DataFixtures/PartFixtures.php b/src/DataFixtures/PartFixtures.php index 3efb8dc8..477d0dd3 100644 --- a/src/DataFixtures/PartFixtures.php +++ b/src/DataFixtures/PartFixtures.php @@ -46,6 +46,7 @@ use App\Entity\Attachments\PartAttachment; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; use App\Entity\Parts\Manufacturer; +use App\Entity\Parts\ManufacturingStatus; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\Storelocation; @@ -83,7 +84,7 @@ class PartFixtures extends Fixture implements DependentFixtureInterface $part->setTags('test, Test, Part2'); $part->setMass(100.2); $part->setNeedsReview(true); - $part->setManufacturingStatus('active'); + $part->setManufacturingStatus(ManufacturingStatus::ACTIVE); $manager->persist($part); /** Part with orderdetails, storelocations and Attachments */ diff --git a/src/Services/LabelSystem/LabelExampleElementsGenerator.php b/src/Services/LabelSystem/LabelExampleElementsGenerator.php index d7c76c73..61cbcc4a 100644 --- a/src/Services/LabelSystem/LabelExampleElementsGenerator.php +++ b/src/Services/LabelSystem/LabelExampleElementsGenerator.php @@ -46,6 +46,7 @@ use App\Entity\LabelSystem\LabelSupportedElement; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; use App\Entity\Parts\Manufacturer; +use App\Entity\Parts\ManufacturingStatus; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\Storelocation; @@ -79,7 +80,7 @@ final class LabelExampleElementsGenerator $part->setMass(123.4); $part->setManufacturerProductNumber('CUSTOM MPN'); $part->setTags('Tag1, Tag2, Tag3'); - $part->setManufacturingStatus('active'); + $part->setManufacturingStatus(ManufacturingStatus::ACTIVE); $part->updateTimestamps(); $part->setFavorite(true); diff --git a/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php b/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php index eb9d7078..0df4d3d7 100644 --- a/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php +++ b/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php @@ -105,11 +105,11 @@ final class PartProvider implements PlaceholderProviderInterface } if ('[[M_STATUS]]' === $placeholder) { - if ('' === $part->getManufacturingStatus()) { + if (null === $part->getManufacturingStatus()) { return ''; } - return $this->translator->trans('m_status.'.$part->getManufacturingStatus()); + return $this->translator->trans($part->getManufacturingStatus()->toTranslationKey()); } $parsedown = new Parsedown(); diff --git a/tests/Services/ImportExportSystem/EntityImporterTest.php b/tests/Services/ImportExportSystem/EntityImporterTest.php index b7dd26d0..f560240c 100644 --- a/tests/Services/ImportExportSystem/EntityImporterTest.php +++ b/tests/Services/ImportExportSystem/EntityImporterTest.php @@ -215,7 +215,7 @@ EOT; $this->assertSame($category, $results[1]->getCategory()); $input = <<assertInstanceOf(Part::class, $error['entity']); - $this->assertSame('Test 2', $error['entity']->getName()); + $this->assertSame('', $error['entity']->getName()); $this->assertContainsOnlyInstancesOf(ConstraintViolation::class, $error['violations']); //Element name must be element name - $this->assertArrayHasKey('Test 2', $errors); + $this->assertArrayHasKey('', $errors); //Check the valid element $this->assertSame('Test 1', $results[0]->getName()); diff --git a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php index 975a5fd5..db3ebad1 100644 --- a/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php +++ b/tests/Services/LabelSystem/PlaceholderProviders/PartProviderTest.php @@ -41,6 +41,7 @@ declare(strict_types=1); namespace App\Tests\Services\LabelSystem\PlaceholderProviders; +use App\Entity\Parts\ManufacturingStatus; use Doctrine\ORM\EntityManager; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; @@ -80,7 +81,7 @@ class PartProviderTest extends WebTestCase $this->target->setMass(1234.2); $this->target->setTags('SMD, Tag1, Tag2'); $this->target->setManufacturerProductNumber('MPN123'); - $this->target->setManufacturingStatus('active'); + $this->target->setManufacturingStatus(ManufacturingStatus::ACTIVE); $this->target->setDescription('Bold *Italic*'); $this->target->setComment('Bold *Italic*');